PostComponent.vue 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. <template>
  2. <div>
  3. <div v-if="!loaded" style="height: 80vh;" class="d-flex justify-content-center align-items-center">
  4. <img src="/img/pixelfed-icon-grey.svg" class="">
  5. </div>
  6. <div v-if="loaded && warning" class="bg-white pt-3 border-bottom">
  7. <div class="container">
  8. <p class="text-center font-weight-bold">You are blocking this account</p>
  9. <p class="text-center font-weight-bold">Click <a href="#" class="cursor-pointer" @click.prevent="warning = false; fetchData()">here</a> to view this status</p>
  10. </div>
  11. </div>
  12. <div v-if="loaded && warning == false" class="postComponent">
  13. <div v-if="profileLayout == 'metro'" class="container px-0">
  14. <div class="card card-md-rounded-0 status-container orientation-unknown shadow-none border">
  15. <div class="row px-0 mx-0">
  16. <div class="d-flex d-md-none align-items-center justify-content-between card-header bg-white w-100">
  17. <div class="d-flex">
  18. <div class="status-avatar mr-2" @click="redirect(statusProfileUrl)">
  19. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;" class="cursor-pointer">
  20. </div>
  21. <div class="username">
  22. <span class="username-link font-weight-bold text-dark cursor-pointer" @click="redirect(statusProfileUrl)">{{ statusUsername }}</span>
  23. <span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
  24. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  25. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  26. </span>
  27. <p v-if="loaded && status.place != null" class="small mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)">{{status.place.name}}, {{status.place.country}}</p>
  28. </div>
  29. </div>
  30. <div v-if="user != false" class="float-right">
  31. <div class="post-actions">
  32. <div class="dropdown">
  33. <button class="btn btn-link text-dark no-caret dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  34. <span class="fas fa-ellipsis-v text-muted"></span>
  35. </button>
  36. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  37. <a class="dropdown-item font-weight-bold" @click="showEmbedPostModal()">Embed</a>
  38. <div v-if="!owner()">
  39. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  40. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile()">Mute Profile</a>
  41. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile()">Block Profile</a>
  42. </div>
  43. <div v-if="ownerOrAdmin()">
  44. <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
  45. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  46. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="col-12 col-md-8 px-0 mx-0">
  54. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center" style="background: #000;">
  55. <div v-if="status.pf_type === 'photo'" class="w-100">
  56. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  57. </div>
  58. <div v-else-if="status.pf_type === 'video'" class="w-100">
  59. <video-presenter :status="status"></video-presenter>
  60. </div>
  61. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  62. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  63. </div>
  64. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  65. <video-album-presenter :status="status"></video-album-presenter>
  66. </div>
  67. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  68. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  69. </div>
  70. <div v-else class="w-100">
  71. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="col-12 col-md-4 px-0 d-flex flex-column border-left border-md-left-0">
  76. <div class="d-md-flex d-none align-items-center justify-content-between card-header py-3 bg-white">
  77. <div class="d-flex align-items-center status-username text-truncate" data-toggle="tooltip" data-placement="bottom" :title="statusUsername">
  78. <div class="status-avatar mr-2" @click="redirect(statusProfileUrl)">
  79. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;" class="cursor-pointer">
  80. </div>
  81. <div class="username">
  82. <span class="username-link font-weight-bold text-dark cursor-pointer" @click="redirect(statusProfileUrl)">{{ statusUsername }}</span>
  83. <span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
  84. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  85. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  86. </span>
  87. <p v-if="loaded && status.place != null" class="small mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)">{{status.place.name}}, {{status.place.country}}</p>
  88. </div>
  89. </div>
  90. <div class="float-right">
  91. <div class="post-actions">
  92. <div v-if="user != false" class="dropdown">
  93. <button class="btn btn-link text-dark no-caret dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  94. <span class="fas fa-ellipsis-v text-muted"></span>
  95. </button>
  96. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  97. <a class="dropdown-item font-weight-bold" @click="showEmbedPostModal()">Embed</a>
  98. <span v-if="!owner()">
  99. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  100. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile">Mute Profile</a>
  101. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile">Block Profile</a>
  102. </span>
  103. <span v-if="ownerOrAdmin()">
  104. <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
  105. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  106. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
  107. </span>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="d-flex flex-md-column flex-column-reverse h-100" style="overflow-y: auto;">
  114. <div class="card-body status-comments pb-5">
  115. <div class="status-comment">
  116. <div v-if="showCaption != true">
  117. <span class="py-3">
  118. <a class="text-dark font-weight-bold mr-1" :href="status.account.url" v-bind:title="status.account.username">{{truncate(status.account.username,15)}}</a>
  119. <span class="text-break">
  120. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  121. <span class="text-primary cursor-pointer pl-1" @click="showCaption = true">Show</span>
  122. </span>
  123. </span>
  124. </div>
  125. <div v-else>
  126. <p :class="[status.content.length > 620 ? 'mb-1 read-more' : 'mb-1']" style="overflow: hidden;">
  127. <a class="font-weight-bold pr-1 text-dark text-decoration-none" :href="statusProfileUrl">{{statusUsername}}</a>
  128. <span class="comment-text" :id="status.id + '-status-readmore'" v-html="status.content"></span>
  129. </p>
  130. </div>
  131. <div v-if="showComments">
  132. <hr>
  133. <div class="postCommentsLoader text-center">
  134. <div class="spinner-border" role="status">
  135. <span class="sr-only">Loading...</span>
  136. </div>
  137. </div>
  138. <div class="postCommentsContainer d-none">
  139. <p v-if="status.reply_count > 10"class="mb-1 text-center load-more-link d-none"><a href="#" class="text-muted" v-on:click="loadMore">Load more comments</a></p>
  140. <div class="comments">
  141. <div v-for="(reply, index) in results" class="pb-3" :key="'tl' + reply.id + '_' + index">
  142. <div v-if="reply.sensitive == true">
  143. <span class="py-3">
  144. <a class="text-dark font-weight-bold mr-1" :href="reply.account.url" v-bind:title="reply.account.username">{{truncate(reply.account.username,15)}}</a>
  145. <span class="text-break">
  146. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  147. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  148. </span>
  149. </span>
  150. </div>
  151. <div v-else>
  152. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  153. <span>
  154. <a class="text-dark font-weight-bold mr-1" :href="reply.account.url" v-bind:title="reply.account.username">{{truncate(reply.account.username,15)}}</a>
  155. <span class="text-break" v-html="reply.content"></span>
  156. </span>
  157. <span class="pl-2" style="min-width:38px">
  158. <span v-on:click="likeReply(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  159. <post-menu :status="reply" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block pl-2" v-on:deletePost="deleteComment(reply.id, index)"></post-menu>
  160. </span>
  161. </p>
  162. <p class="">
  163. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(reply.created_at)" :href="reply.url"></a>
  164. <span v-if="reply.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{reply.favourites_count == 1 ? '1 like' : reply.favourites_count + ' likes'}}</span>
  165. <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index)">Reply</span>
  166. </p>
  167. <div v-if="reply.reply_count > 0" class="cursor-pointer" style="margin-left:30px;" v-on:click="toggleReplies(reply)">
  168. <span class="show-reply-bar"></span>
  169. <span class="comment-reaction font-weight-bold text-muted">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
  170. </div>
  171. <div v-if="reply.thread == true" class="comment-thread">
  172. <div v-for="(s, sindex) in reply.replies" class="pb-3" :key="'cr' + s.id + '_' + index">
  173. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  174. <span>
  175. <a class="text-dark font-weight-bold mr-1" :href="s.account.url" :title="s.account.username">{{s.account.username}}</a>
  176. <span class="text-break" v-html="s.content"></span>
  177. </span>
  178. <span class="pl-2" style="min-width:38px">
  179. <span v-on:click="likeReply(s, $event)"><i v-bind:class="[s.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  180. <post-menu :status="s" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block pl-2" v-on:deletePost="deleteCommentReply(s.id, sindex, index) "></post-menu>
  181. </span>
  182. </p>
  183. <p class="">
  184. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(s.created_at)" :href="s.url"></a>
  185. <span v-if="s.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{s.favourites_count == 1 ? '1 like' : s.favourites_count + ' likes'}}</span>
  186. </p>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="card-body flex-grow-0 py-1">
  197. <div class="reactions my-1">
  198. <h3 v-bind:class="[reactions.liked ? 'fas fa-heart text-danger pr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus"></h3>
  199. <h3 v-if="!status.comments_disabled" class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="replyFocus(status)"></h3>
  200. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'far fa-share-square pr-3 m-0 text-primary cursor-pointer' : 'far fa-share-square pr-3 m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
  201. <h3 @click="lightbox(status.media_attachments[0])" class="fas fa-expand m-0 cursor-pointer"></h3>
  202. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 float-right cursor-pointer' : 'far fa-bookmark m-0 float-right cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
  203. </div>
  204. <div class="reaction-counts font-weight-bold mb-0">
  205. <span style="cursor:pointer;" v-on:click="likesModal">
  206. <span class="like-count">{{status.favourites_count || 0}}</span> likes
  207. </span>
  208. <span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
  209. <span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
  210. </span>
  211. </div>
  212. <div class="timestamp pt-2 d-flex align-items-bottom justify-content-between">
  213. <a v-bind:href="statusUrl" class="small text-muted">
  214. {{timestampFormat()}}
  215. </a>
  216. <span class="small text-muted text-capitalize cursor-pointer" v-on:click="visibilityModal">{{status.visibility}}</span>
  217. </div>
  218. </div>
  219. </div>
  220. <div v-if="showComments && user.length !== 0" class="card-footer bg-white px-2 py-0">
  221. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  222. <li class="nav-item" v-on:click="emojiReaction" v-for="e in emoji">{{e}}</li>
  223. </ul>
  224. </div>
  225. <div v-if="showComments" class="card-footer bg-white sticky-md-bottom p-0">
  226. <div v-if="user.length == 0" class="comment-form-guest p-3">
  227. <a href="/login">Login</a> to like or comment.
  228. </div>
  229. <form v-else class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="statusId" data-truncate="false">
  230. <textarea class="form-control border-0 rounded-0" name="comment" placeholder="Add a comment…" autocomplete="off" autocorrect="off" style="height:56px;line-height: 18px;max-height:80px;resize: none; padding-right:4.2rem;" v-model="replyText"></textarea>
  231. <input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" v-on:click.prevent="postReply" :disabled="replyText.length == 0" />
  232. </form>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <div v-if="profileLayout == 'moment'" class="momentui">
  239. <div class="bg-dark mt-md-n4">
  240. <div class="container" v-on:dblclick="likeStatus">
  241. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center bg-dark">
  242. <div v-if="status.pf_type === 'photo'" class="w-100">
  243. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  244. </div>
  245. <div v-else-if="status.pf_type === 'video'" class="w-100">
  246. <video-presenter :status="status"></video-presenter>
  247. </div>
  248. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  249. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  250. </div>
  251. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  252. <video-album-presenter :status="status"></video-album-presenter>
  253. </div>
  254. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  255. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  256. </div>
  257. <div v-else class="w-100">
  258. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. <div class="bg-white">
  264. <div class="container">
  265. <div class="row pb-5">
  266. <div class="col-12 col-md-8 py-4">
  267. <div class="reactions d-flex align-items-center">
  268. <div class="text-center mr-5">
  269. <div v-bind:class="[reactions.liked ? 'fas fa-heart text-danger m-0 cursor-pointer' : 'far fa-heart m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus" style="font-size:1.575rem">
  270. </div>
  271. <div class="like-count font-weight-bold mt-2 rounded border" style="cursor:pointer;" v-on:click="likesModal">{{status.favourites_count || 0}}</div>
  272. </div>
  273. <div class="text-center">
  274. <div v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'h3 far fa-share-square m-0 text-primary cursor-pointer' : 'h3 far fa-share-square m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus">
  275. </div>
  276. <div class="share-count font-weight-bold mt-2 rounded border" v-if="status.visibility == 'public'" style="cursor:pointer;" v-on:click="sharesModal">{{status.reblogs_count || 0}}</div>
  277. </div>
  278. </div>
  279. <!-- <div class="reaction-counts font-weight-bold mb-0">
  280. <span class="like-count">{{status.favourites_count || 0}}</span> likes
  281. <span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
  282. <span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
  283. </span>
  284. </div> -->
  285. <div class="media align-items-center mt-3">
  286. <div class="media-body">
  287. <h2 class="font-weight-bold">
  288. {{status.content.length < 100 ? status.content.slice(0,100) : 'Untitled Post'}}
  289. </h2>
  290. <p class="lead mb-0">
  291. by <a :href="statusProfileUrl">{{statusUsername}}</a>
  292. <!-- <span class="px-1 text-lighter">•</span>
  293. <a class="font-weight-bold small" href="#">Follow</a> -->
  294. </p>
  295. </div>
  296. <img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="72px" height="72px">
  297. </div>
  298. <hr>
  299. <div>
  300. <p class="lead">
  301. <span v-if="status.place" class="text-truncate">
  302. <i class="fas fa-map-marker-alt text-lighter mr-3"></i> {{status.place.name}}, {{status.place.country}}
  303. </span>
  304. <span v-once class="float-right">
  305. <i class="far fa-clock text-lighter mr-3"></i> {{timeAgo(status.created_at)}} ago
  306. </span>
  307. </p>
  308. <!-- <div v-if="status.content.length > 100" class="lead" v-html="status.content"></div> -->
  309. <!-- <div class="pt-4">
  310. <p class="lead">
  311. <span class="mr-3"><i class="fas fa-camera text-lighter"></i></span>
  312. <span>Nikon D850</span>
  313. </p>
  314. <p class="lead">
  315. <span class="mr-3"><i class="fas fa-ruler-horizontal text-lighter"></i></span>
  316. <span>200-500mm</span>
  317. </p>
  318. <p class="lead">
  319. <span class="mr-3"><i class="fas fa-stream text-lighter"></i></span>
  320. <span>500mm <span class="px-1"></span> ƒ/7.1 <span class="px-1"></span> 1/1600s <span class="px-1"></span> ISO 800</span>
  321. </p>
  322. </div> -->
  323. <div v-if="status.tags" class="pt-4">
  324. <p class="lead">
  325. <a v-for="(tag, index) in status.tags" class="btn btn-outline-dark mr-1 mb-1" :href="tag.url + '?src=mp'">{{tag.name}}</a>
  326. </p>
  327. </div>
  328. </div>
  329. </div>
  330. <div class="col-12 col-md-4 pt-4 pl-md-3">
  331. <p class="lead font-weight-bold">Comments</p>
  332. <div v-if="user && user.length" class="moment-comments">
  333. <div class="form-group">
  334. <textarea class="form-control" rows="3" placeholder="Add a comment ..." v-model="replyText"></textarea>
  335. <p style="padding-top:4px;">
  336. <span class="small text-lighter font-weight-bold">
  337. {{replyText.length}}/{{config.uploader.max_caption_length}}
  338. </span>
  339. <button
  340. :class="[replyText.length > 1 ? 'btn btn-sm font-weight-bold float-right btn-outline-dark ':'btn btn-sm font-weight-bold float-right btn-outline-lighter']"
  341. :disabled="replyText.length == 0 ? 'disabled':''"
  342. @click="postReply"
  343. >Post</button>
  344. </p>
  345. </div>
  346. <hr>
  347. </div>
  348. <div class="comment mt-3" style="max-height: 500px; overflow-y: auto;">
  349. <div v-for="(reply, index) in results" :key="'tl' + reply.id + '_' + index" class="media mb-3">
  350. <img :src="reply.account.avatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px">
  351. <div class="media-body">
  352. <div class="d-flex justify-content-between">
  353. <span class="font-weight-bold">{{reply.account.username}}</span>
  354. <span class="small">
  355. <a class="text-lighter text-decoration-none" :href="reply.url">{{timeAgo(reply.created_at)}}</a>
  356. </span>
  357. </div>
  358. <p v-html="reply.content"></p>
  359. </div>
  360. </div>
  361. <!-- <div class="media mb-3">
  362. <img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px">
  363. <div class="media-body">
  364. <div class="d-flex justify-content-between">
  365. <span class="font-weight-bold">mona</span>
  366. <span class="text-lighter small">2h ago</span>
  367. </div>
  368. <p>Stunning my friend!</p>
  369. </div>
  370. </div>
  371. <div class="media mb-3">
  372. <img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px">
  373. <div class="media-body">
  374. <div class="d-flex justify-content-between">
  375. <span class="font-weight-bold">Andre</span>
  376. <span class="text-lighter small">3h ago</span>
  377. </div>
  378. <p>Wow</p>
  379. </div>
  380. </div> -->
  381. </div>
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. </div>
  387. </div>
  388. <b-modal ref="likesModal"
  389. id="l-modal"
  390. hide-footer
  391. centered
  392. title="Likes"
  393. body-class="list-group-flush p-0">
  394. <div class="list-group">
  395. <div class="list-group-item border-0" v-for="(user, index) in likes" :key="'modal_likes_'+index">
  396. <div class="media">
  397. <a :href="user.url">
  398. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  399. </a>
  400. <div class="media-body">
  401. <p class="mb-0" style="font-size: 14px">
  402. <a :href="user.url" class="font-weight-bold text-dark">
  403. {{user.username}}
  404. </a>
  405. </p>
  406. <p class="text-muted mb-0" style="font-size: 14px">
  407. {{user.display_name}}
  408. </a>
  409. </p>
  410. </div>
  411. </div>
  412. </div>
  413. <infinite-loading @infinite="infiniteLikesHandler" spinner="spiral">
  414. <div slot="no-more"></div>
  415. <div slot="no-results"></div>
  416. </infinite-loading>
  417. </div>
  418. </b-modal>
  419. <b-modal ref="sharesModal"
  420. id="s-modal"
  421. hide-footer
  422. centered
  423. title="Shares"
  424. body-class="list-group-flush p-0">
  425. <div class="list-group">
  426. <div class="list-group-item border-0" v-for="(user, index) in shares" :key="'modal_shares_'+index">
  427. <div class="media">
  428. <a :href="user.url">
  429. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  430. </a>
  431. <div class="media-body">
  432. <div class="d-inline-block">
  433. <p class="mb-0" style="font-size: 14px">
  434. <a :href="user.url" class="font-weight-bold text-dark">
  435. {{user.username}}
  436. </a>
  437. </p>
  438. <p class="text-muted mb-0" style="font-size: 14px">
  439. {{user.display_name}}
  440. </a>
  441. </p>
  442. </div>
  443. <p class="float-right"><!-- <a class="btn btn-primary font-weight-bold py-1" href="#">Follow</a> --></p>
  444. </div>
  445. </div>
  446. </div>
  447. <infinite-loading @infinite="infiniteSharesHandler" spinner="spiral">
  448. <div slot="no-more"></div>
  449. <div slot="no-results"></div>
  450. </infinite-loading>
  451. </div>
  452. </b-modal>
  453. <b-modal
  454. id="lightbox"
  455. ref="lightboxModal"
  456. :hide-header="true"
  457. :hide-footer="true"
  458. centered
  459. size="lg"
  460. body-class="p-0"
  461. >
  462. <div v-if="lightboxMedia" >
  463. <img :src="lightboxMedia.url" :class="lightboxMedia.filter_class + ' img-fluid'" style="min-height: 100%; min-width: 100%">
  464. </div>
  465. </b-modal>
  466. <b-modal ref="embedModal"
  467. id="ctx-embed-modal"
  468. hide-header
  469. hide-footer
  470. centered
  471. rounded
  472. size="md"
  473. body-class="p-2 rounded">
  474. <div>
  475. <textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 12px; height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
  476. <hr>
  477. <button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
  478. <p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
  479. </div>
  480. </b-modal>
  481. </div>
  482. </template>
  483. <style type="text/css" scoped>
  484. .status-comments,
  485. .reactions {
  486. background: #fff;
  487. }
  488. .postPresenterContainer {
  489. background: #fff;
  490. }
  491. @media(min-width: 720px) {
  492. .postPresenterContainer {
  493. min-height: 600px;
  494. }
  495. }
  496. ::-webkit-scrollbar {
  497. width: 0px;
  498. background: transparent;
  499. }
  500. .reply-btn {
  501. position: absolute;
  502. bottom: 12px;
  503. right: 20px;
  504. width: 60px;
  505. text-align: center;
  506. border-radius: 0 3px 3px 0;
  507. }
  508. .text-lighter {
  509. color:#B8C2CC !important;
  510. }
  511. .text-break {
  512. overflow-wrap: break-word;
  513. }
  514. .comments p {
  515. margin-bottom: 0;
  516. }
  517. .comment-reaction {
  518. font-size: 80%;
  519. }
  520. .show-reply-bar {
  521. display: inline-block;
  522. border-bottom: 1px solid #999;
  523. height: 0;
  524. margin-right: 16px;
  525. vertical-align: middle;
  526. width: 24px;
  527. }
  528. .comment-thread {
  529. margin: 4px 0 0 40px;
  530. width: calc(100% - 40px);
  531. }
  532. .emoji-reactions .nav-item {
  533. font-size: 1.2rem;
  534. padding: 9px;
  535. cursor: pointer;
  536. }
  537. .emoji-reactions::-webkit-scrollbar {
  538. width: 0px;
  539. height: 0px;
  540. background: transparent;
  541. }
  542. </style>
  543. <style type="text/css" scoped>
  544. .momentui .bg-dark {
  545. background: #000 !important;
  546. }
  547. .momentui .carousel.slide,
  548. .momentui .carousel-item {
  549. background: #000 !important;
  550. }
  551. .reply-btn[disabled] {
  552. opacity: .3;
  553. color: #3897f0;
  554. }
  555. </style>
  556. <script>
  557. pixelfed.postComponent = {};
  558. export default {
  559. props: [
  560. 'status-id',
  561. 'status-username',
  562. 'status-template',
  563. 'status-url',
  564. 'status-profile-url',
  565. 'status-avatar',
  566. 'status-profile-id',
  567. 'profile-layout'
  568. ],
  569. data() {
  570. return {
  571. config: window.App.config,
  572. status: false,
  573. media: {},
  574. user: false,
  575. reactions: {
  576. liked: false,
  577. shared: false
  578. },
  579. likes: [],
  580. likesPage: 1,
  581. shares: [],
  582. sharesPage: 1,
  583. lightboxMedia: false,
  584. replyText: '',
  585. relationship: {},
  586. results: [],
  587. pagination: {},
  588. min_id: 0,
  589. max_id: 0,
  590. reply_to_profile_id: 0,
  591. thread: false,
  592. showComments: false,
  593. warning: false,
  594. loaded: false,
  595. loading: null,
  596. replyingToId: this.statusId,
  597. replyToIndex: 0,
  598. emoji: window.App.util.emoji,
  599. showReadMore: true,
  600. showCaption: true,
  601. ctxEmbedPayload: false,
  602. copiedEmbed: false,
  603. }
  604. },
  605. beforeMount() {
  606. let u = new URLSearchParams(window.location.search);
  607. if(u.has('ui') && u.get('ui') == 'moment' && this.profileLayout != 'moment') {
  608. this.profileLayout = 'moment';
  609. }
  610. if(u.has('ui') && u.get('ui') == 'metro' && this.profileLayout != 'metro') {
  611. this.profileLayout = 'metro';
  612. }
  613. },
  614. mounted() {
  615. this.fetchRelationships();
  616. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  617. this.showReadMore = false;
  618. } else {
  619. this.showReadMore = true;
  620. }
  621. },
  622. updated() {
  623. $('.carousel').carousel();
  624. if(this.showReadMore == true) {
  625. window.pixelfed.readmore();
  626. }
  627. },
  628. methods: {
  629. showMuteBlock() {
  630. let sid = this.status.account.id;
  631. let uid = this.user.id;
  632. if(sid == uid) {
  633. $('.post-actions .menu-author').removeClass('d-none');
  634. } else {
  635. $('.post-actions .menu-user').removeClass('d-none');
  636. }
  637. },
  638. reportUrl() {
  639. return '/i/report?type=post&id=' + this.status.id;
  640. },
  641. editUrl() {
  642. return this.status.url + '/edit';
  643. },
  644. timestampFormat() {
  645. let ts = new Date(this.status.created_at);
  646. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  647. },
  648. fetchData() {
  649. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  650. .then(response => {
  651. let self = this;
  652. self.status = response.data.status;
  653. self.user = response.data.user;
  654. self.media = self.status.media_attachments;
  655. self.reactions = response.data.reactions;
  656. self.likes = response.data.likes;
  657. self.shares = response.data.shares;
  658. self.likesPage = 2;
  659. self.sharesPage = 2;
  660. this.showMuteBlock();
  661. self.showCaption = !response.data.status.sensitive;
  662. if(self.status.comments_disabled == false) {
  663. self.showComments = true;
  664. this.fetchComments();
  665. }
  666. this.loaded = true;
  667. $('head title').text(this.status.account.username + ' posted a photo: ' + this.status.favourites_count + ' likes');
  668. }).catch(error => {
  669. if(!error.response) {
  670. } else {
  671. switch(error.response.status) {
  672. case 401:
  673. break;
  674. default:
  675. break;
  676. }
  677. }
  678. });
  679. },
  680. likesModal() {
  681. if(this.status.favourites_count == 0 || $('body').hasClass('loggedIn') == false) {
  682. return;
  683. }
  684. this.$refs.likesModal.show();
  685. },
  686. sharesModal() {
  687. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  688. return;
  689. }
  690. this.$refs.sharesModal.show();
  691. },
  692. infiniteLikesHandler($state) {
  693. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  694. axios.get(api, {
  695. params: {
  696. page: this.likesPage,
  697. },
  698. }).then(({ data }) => {
  699. if (data.data.length > 0) {
  700. this.likes.push(...data.data);
  701. this.likesPage++;
  702. $state.loaded();
  703. } else {
  704. $state.complete();
  705. }
  706. });
  707. },
  708. infiniteSharesHandler($state) {
  709. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  710. params: {
  711. page: this.sharesPage,
  712. },
  713. }).then(({ data }) => {
  714. if (data.data.length > 0) {
  715. this.shares.push(...data.data);
  716. this.sharesPage++;
  717. $state.loaded();
  718. } else {
  719. $state.complete();
  720. }
  721. });
  722. },
  723. likeStatus(event) {
  724. if($('body').hasClass('loggedIn') == false) {
  725. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  726. return;
  727. }
  728. axios.post('/i/like', {
  729. item: this.status.id
  730. }).then(res => {
  731. this.status.favourites_count = res.data.count;
  732. if(this.reactions.liked == true) {
  733. this.reactions.liked = false;
  734. let user = this.user.id;
  735. this.likes = this.likes.filter(function(like) {
  736. return like.id !== user;
  737. });
  738. } else {
  739. this.reactions.liked = true;
  740. let user = this.user;
  741. this.likes.push(user);
  742. }
  743. }).catch(err => {
  744. console.error(err);
  745. swal('Error', 'Something went wrong, please try again later.', 'error');
  746. });
  747. },
  748. shareStatus() {
  749. if($('body').hasClass('loggedIn') == false) {
  750. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  751. return;
  752. }
  753. axios.post('/i/share', {
  754. item: this.status.id
  755. }).then(res => {
  756. this.status.reblogs_count = res.data.count;
  757. if(this.reactions.shared == true) {
  758. this.reactions.shared = false;
  759. let user = this.user.id;
  760. this.shares = this.shares.filter(function(reaction) {
  761. return reaction.id !== user;
  762. });
  763. } else {
  764. this.reactions.shared = true;
  765. let user = this.user;
  766. this.shares.push(user);
  767. }
  768. }).catch(err => {
  769. console.error(err);
  770. swal('Error', 'Something went wrong, please try again later.', 'error');
  771. });
  772. },
  773. bookmarkStatus() {
  774. if($('body').hasClass('loggedIn') == false) {
  775. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  776. return;
  777. }
  778. axios.post('/i/bookmark', {
  779. item: this.status.id
  780. }).then(res => {
  781. if(this.reactions.bookmarked == true) {
  782. this.reactions.bookmarked = false;
  783. } else {
  784. this.reactions.bookmarked = true;
  785. }
  786. }).catch(err => {
  787. swal('Error', 'Something went wrong, please try again later.', 'error');
  788. });
  789. },
  790. muteProfile() {
  791. if($('body').hasClass('loggedIn') == false) {
  792. return;
  793. }
  794. axios.post('/i/mute', {
  795. type: 'user',
  796. item: this.status.account.id
  797. }).then(res => {
  798. swal('Success', 'You have successfully muted ' + this.status.account.acct, 'success');
  799. }).catch(err => {
  800. swal('Error', 'Something went wrong. Please try again later.', 'error');
  801. });
  802. },
  803. blockProfile() {
  804. if($('body').hasClass('loggedIn') == false) {
  805. return;
  806. }
  807. axios.post('/i/block', {
  808. type: 'user',
  809. item: this.status.account.id
  810. }).then(res => {
  811. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  812. }).catch(err => {
  813. swal('Error', 'Something went wrong. Please try again later.', 'error');
  814. });
  815. },
  816. deletePost(status) {
  817. if(!this.ownerOrAdmin()) {
  818. return;
  819. }
  820. var result = confirm('Are you sure you want to delete this post?');
  821. if (result) {
  822. if($('body').hasClass('loggedIn') == false) {
  823. return;
  824. }
  825. axios.post('/i/delete', {
  826. type: 'status',
  827. item: this.status.id
  828. }).then(res => {
  829. swal('Success', 'You have successfully deleted this post', 'success');
  830. setTimeout(function() {
  831. window.location.href = '/';
  832. }, 3000);
  833. }).catch(err => {
  834. swal('Error', 'Something went wrong. Please try again later.', 'error');
  835. });
  836. }
  837. },
  838. owner() {
  839. return this.user.id === this.status.account.id;
  840. },
  841. admin() {
  842. return this.user.is_admin == true;
  843. },
  844. ownerOrAdmin() {
  845. return this.owner() || this.admin();
  846. },
  847. lightbox(src) {
  848. this.lightboxMedia = src;
  849. this.$refs.lightboxModal.show();
  850. },
  851. postReply() {
  852. let self = this;
  853. if(this.replyText.length == 0 ||
  854. this.replyText.trim() == '@'+this.status.account.acct) {
  855. self.replyText = null;
  856. $('textarea[name="comment"]').blur();
  857. return;
  858. }
  859. let data = {
  860. item: this.replyingToId,
  861. comment: this.replyText
  862. }
  863. this.replyText = '';
  864. axios.post('/i/comment', data)
  865. .then(function(res) {
  866. let entity = res.data.entity;
  867. if(entity.in_reply_to_id == self.status.id) {
  868. if(self.profileLayout == 'metro') {
  869. self.results.push(entity);
  870. } else {
  871. self.results.unshift(entity);
  872. }
  873. let elem = $('.status-comments')[0];
  874. elem.scrollTop = elem.clientHeight;
  875. } else {
  876. if(self.replyToIndex >= 0) {
  877. let el = self.results[self.replyToIndex];
  878. el.replies.push(entity);
  879. el.reply_count = el.reply_count + 1;
  880. }
  881. }
  882. });
  883. },
  884. deleteComment(id, i) {
  885. axios.post('/i/delete', {
  886. type: 'comment',
  887. item: id
  888. }).then(res => {
  889. this.results.splice(i, 1);
  890. }).catch(err => {
  891. swal('Something went wrong!', 'Please try again later', 'error');
  892. });
  893. },
  894. deleteCommentReply(id, i, pi) {
  895. axios.post('/i/delete', {
  896. type: 'comment',
  897. item: id
  898. }).then(res => {
  899. this.results[pi].replies.splice(i, 1);
  900. --this.results[pi].reply_count;
  901. }).catch(err => {
  902. swal('Something went wrong!', 'Please try again later', 'error');
  903. });
  904. },
  905. l(e) {
  906. let len = e.length;
  907. if(len < 10) { return e; }
  908. return e.substr(0, 10)+'...';
  909. },
  910. replyFocus(e, index) {
  911. this.replyToIndex = index;
  912. this.replyingToId = e.id;
  913. this.reply_to_profile_id = e.account.id;
  914. this.replyText = '@' + e.account.username + ' ';
  915. $('textarea[name="comment"]').focus();
  916. },
  917. fetchComments() {
  918. let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
  919. axios.get(url)
  920. .then(response => {
  921. let self = this;
  922. this.results = this.profileLayout == 'metro' ?
  923. _.reverse(response.data.data) :
  924. response.data.data;
  925. this.pagination = response.data.meta.pagination;
  926. if(this.results.length > 0) {
  927. $('.load-more-link').removeClass('d-none');
  928. }
  929. $('.postCommentsLoader').addClass('d-none');
  930. $('.postCommentsContainer').removeClass('d-none');
  931. }).catch(error => {
  932. if(!error.response) {
  933. $('.postCommentsLoader .lds-ring')
  934. .attr('style','width:100%')
  935. .addClass('pt-4 font-weight-bold text-muted')
  936. .text('An error occurred, cannot fetch comments. Please try again later.');
  937. } else {
  938. switch(error.response.status) {
  939. case 401:
  940. $('.postCommentsLoader .lds-ring')
  941. .attr('style','width:100%')
  942. .addClass('pt-4 font-weight-bold text-muted')
  943. .text('Please login to view.');
  944. break;
  945. default:
  946. $('.postCommentsLoader .lds-ring')
  947. .attr('style','width:100%')
  948. .addClass('pt-4 font-weight-bold text-muted')
  949. .text('An error occurred, cannot fetch comments. Please try again later.');
  950. break;
  951. }
  952. }
  953. });
  954. },
  955. loadMore(e) {
  956. e.preventDefault();
  957. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  958. $('.load-more-link').addClass('d-none');
  959. return;
  960. }
  961. $('.postCommentsLoader').removeClass('d-none');
  962. let next = this.pagination.links.next;
  963. axios.get(next)
  964. .then(response => {
  965. let self = this;
  966. let res = response.data.data;
  967. $('.postCommentsLoader').addClass('d-none');
  968. for(let i=0; i < res.length; i++) {
  969. this.results.unshift(res[i]);
  970. }
  971. this.pagination = response.data.meta.pagination;
  972. });
  973. },
  974. likeReply(status, $event) {
  975. if($('body').hasClass('loggedIn') == false) {
  976. return;
  977. }
  978. axios.post('/i/like', {
  979. item: status.id
  980. }).then(res => {
  981. status.favourites_count = res.data.count;
  982. if(status.favourited == true) {
  983. status.favourited = false;
  984. } else {
  985. status.favourited = true;
  986. }
  987. }).catch(err => {
  988. swal('Error', 'Something went wrong, please try again later.', 'error');
  989. });
  990. },
  991. truncate(str,lim) {
  992. return _.truncate(str,{
  993. length: lim
  994. });
  995. },
  996. timeAgo(ts) {
  997. let date = Date.parse(ts);
  998. let seconds = Math.floor((new Date() - date) / 1000);
  999. let interval = Math.floor(seconds / 31536000);
  1000. if (interval >= 1) {
  1001. return interval + "y";
  1002. }
  1003. interval = Math.floor(seconds / 604800);
  1004. if (interval >= 1) {
  1005. return interval + "w";
  1006. }
  1007. interval = Math.floor(seconds / 86400);
  1008. if (interval >= 1) {
  1009. return interval + "d";
  1010. }
  1011. interval = Math.floor(seconds / 3600);
  1012. if (interval >= 1) {
  1013. return interval + "h";
  1014. }
  1015. interval = Math.floor(seconds / 60);
  1016. if (interval >= 1) {
  1017. return interval + "m";
  1018. }
  1019. return Math.floor(seconds) + "s";
  1020. },
  1021. emojiReaction() {
  1022. let em = event.target.innerText;
  1023. if(this.replyText.length == 0) {
  1024. this.reply_to_profile_id = this.status.account.id;
  1025. this.replyText = em + ' ';
  1026. $('textarea[name="comment"]').focus();
  1027. } else {
  1028. this.reply_to_profile_id = this.status.account.id;
  1029. this.replyText += em + ' ';
  1030. $('textarea[name="comment"]').focus();
  1031. }
  1032. },
  1033. toggleCommentVisibility() {
  1034. if(this.ownerOrAdmin() == false) {
  1035. return;
  1036. }
  1037. let state = this.status.comments_disabled;
  1038. let self = this;
  1039. if(state == true) {
  1040. // re-enable comments
  1041. axios.post('/i/visibility', {
  1042. item: self.status.id,
  1043. disableComments: false
  1044. }).then(function(res) {
  1045. window.location.href = self.status.url;
  1046. }).catch(function(err) {
  1047. return;
  1048. });
  1049. } else {
  1050. // disable comments
  1051. axios.post('/i/visibility', {
  1052. item: self.status.id,
  1053. disableComments: true
  1054. }).then(function(res) {
  1055. self.status.comments_disabled = false;
  1056. self.showComments = false;
  1057. }).catch(function(err) {
  1058. return;
  1059. });
  1060. }
  1061. },
  1062. fetchRelationships() {
  1063. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1064. this.fetchData();
  1065. return;
  1066. } else {
  1067. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1068. params: {
  1069. 'id[]': this.statusProfileId
  1070. }
  1071. }).then(res => {
  1072. if(res.data[0] == null) {
  1073. this.fetchData();
  1074. return;
  1075. }
  1076. this.relationship = res.data[0];
  1077. if(res.data[0].blocking == true) {
  1078. this.loaded = true;
  1079. this.warning = true;
  1080. return;
  1081. } else {
  1082. this.fetchData();
  1083. return;
  1084. }
  1085. });
  1086. }
  1087. },
  1088. visibilityModal() {
  1089. switch(this.status.visibility) {
  1090. case 'public':
  1091. swal('Public Post', 'This post is visible to everyone.', 'info');
  1092. break;
  1093. case 'unlisted':
  1094. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1095. break;
  1096. case 'private':
  1097. swal('Private Post', 'This post is only visible to followers.', 'info');
  1098. break;
  1099. }
  1100. },
  1101. toggleReplies(reply) {
  1102. if(reply.thread) {
  1103. reply.thread = false;
  1104. } else {
  1105. if(reply.replies.length > 0) {
  1106. reply.thread = true;
  1107. return;
  1108. }
  1109. let url = '/api/v2/comments/'+reply.account.username+'/status/'+reply.id;
  1110. axios.get(url)
  1111. .then(response => {
  1112. reply.replies = _.reverse(response.data.data);
  1113. reply.thread = true;
  1114. });
  1115. }
  1116. },
  1117. redirect(url) {
  1118. window.location.href = url;
  1119. },
  1120. showEmbedPostModal() {
  1121. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url)
  1122. this.$refs.embedModal.show();
  1123. },
  1124. ctxCopyEmbed() {
  1125. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1126. this.$refs.embedModal.hide();
  1127. },
  1128. },
  1129. }
  1130. </script>