PostComponent.vue 51 KB

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