PostComponent.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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">
  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="layout == '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. layout: this.profileLayout
  604. }
  605. },
  606. beforeMount() {
  607. let u = new URLSearchParams(window.location.search);
  608. let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
  609. if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
  610. this.layout = 'metro';
  611. }
  612. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  613. this.layout = 'moment';
  614. }
  615. },
  616. mounted() {
  617. this.fetchRelationships();
  618. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  619. this.showReadMore = false;
  620. } else {
  621. this.showReadMore = true;
  622. }
  623. },
  624. updated() {
  625. $('.carousel').carousel();
  626. if(this.showReadMore == true) {
  627. window.pixelfed.readmore();
  628. }
  629. },
  630. methods: {
  631. showMuteBlock() {
  632. let sid = this.status.account.id;
  633. let uid = this.user.id;
  634. if(sid == uid) {
  635. $('.post-actions .menu-author').removeClass('d-none');
  636. } else {
  637. $('.post-actions .menu-user').removeClass('d-none');
  638. }
  639. },
  640. reportUrl() {
  641. return '/i/report?type=post&id=' + this.status.id;
  642. },
  643. editUrl() {
  644. return this.status.url + '/edit';
  645. },
  646. timestampFormat() {
  647. let ts = new Date(this.status.created_at);
  648. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  649. },
  650. fetchData() {
  651. let self = this;
  652. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  653. .then(response => {
  654. self.status = response.data.status;
  655. self.user = response.data.user;
  656. window._sharedData.curUser = self.user;
  657. self.media = self.status.media_attachments;
  658. self.reactions = response.data.reactions;
  659. self.likes = response.data.likes;
  660. self.shares = response.data.shares;
  661. self.likesPage = 2;
  662. self.sharesPage = 2;
  663. this.showMuteBlock();
  664. self.showCaption = !response.data.status.sensitive;
  665. if(self.status.comments_disabled == false) {
  666. self.showComments = true;
  667. this.fetchComments();
  668. }
  669. this.loaded = true;
  670. $('head title').text(this.status.account.username + ' posted a photo: ' + this.status.favourites_count + ' likes');
  671. }).catch(error => {
  672. swal('Oops!', 'An error occured, please try refreshing the page.', 'error');
  673. });
  674. },
  675. likesModal() {
  676. if(this.status.favourites_count == 0 || $('body').hasClass('loggedIn') == false) {
  677. return;
  678. }
  679. this.$refs.likesModal.show();
  680. },
  681. sharesModal() {
  682. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  683. return;
  684. }
  685. this.$refs.sharesModal.show();
  686. },
  687. infiniteLikesHandler($state) {
  688. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  689. axios.get(api, {
  690. params: {
  691. page: this.likesPage,
  692. },
  693. }).then(({ data }) => {
  694. if (data.data.length > 0) {
  695. this.likes.push(...data.data);
  696. this.likesPage++;
  697. $state.loaded();
  698. } else {
  699. $state.complete();
  700. }
  701. });
  702. },
  703. infiniteSharesHandler($state) {
  704. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  705. params: {
  706. page: this.sharesPage,
  707. },
  708. }).then(({ data }) => {
  709. if (data.data.length > 0) {
  710. this.shares.push(...data.data);
  711. this.sharesPage++;
  712. $state.loaded();
  713. } else {
  714. $state.complete();
  715. }
  716. });
  717. },
  718. likeStatus(event) {
  719. if($('body').hasClass('loggedIn') == false) {
  720. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  721. return;
  722. }
  723. axios.post('/i/like', {
  724. item: this.status.id
  725. }).then(res => {
  726. this.status.favourites_count = res.data.count;
  727. if(this.reactions.liked == true) {
  728. this.reactions.liked = false;
  729. let user = this.user.id;
  730. this.likes = this.likes.filter(function(like) {
  731. return like.id !== user;
  732. });
  733. } else {
  734. this.reactions.liked = true;
  735. let user = this.user;
  736. this.likes.push(user);
  737. }
  738. }).catch(err => {
  739. console.error(err);
  740. swal('Error', 'Something went wrong, please try again later.', 'error');
  741. });
  742. },
  743. shareStatus() {
  744. if($('body').hasClass('loggedIn') == false) {
  745. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  746. return;
  747. }
  748. axios.post('/i/share', {
  749. item: this.status.id
  750. }).then(res => {
  751. this.status.reblogs_count = res.data.count;
  752. if(this.reactions.shared == true) {
  753. this.reactions.shared = false;
  754. let user = this.user.id;
  755. this.shares = this.shares.filter(function(reaction) {
  756. return reaction.id !== user;
  757. });
  758. } else {
  759. this.reactions.shared = true;
  760. let user = this.user;
  761. this.shares.push(user);
  762. }
  763. }).catch(err => {
  764. console.error(err);
  765. swal('Error', 'Something went wrong, please try again later.', 'error');
  766. });
  767. },
  768. bookmarkStatus() {
  769. if($('body').hasClass('loggedIn') == false) {
  770. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  771. return;
  772. }
  773. axios.post('/i/bookmark', {
  774. item: this.status.id
  775. }).then(res => {
  776. if(this.reactions.bookmarked == true) {
  777. this.reactions.bookmarked = false;
  778. } else {
  779. this.reactions.bookmarked = true;
  780. }
  781. }).catch(err => {
  782. swal('Error', 'Something went wrong, please try again later.', 'error');
  783. });
  784. },
  785. muteProfile() {
  786. if($('body').hasClass('loggedIn') == false) {
  787. return;
  788. }
  789. axios.post('/i/mute', {
  790. type: 'user',
  791. item: this.status.account.id
  792. }).then(res => {
  793. swal('Success', 'You have successfully muted ' + this.status.account.acct, 'success');
  794. }).catch(err => {
  795. swal('Error', 'Something went wrong. Please try again later.', 'error');
  796. });
  797. },
  798. blockProfile() {
  799. if($('body').hasClass('loggedIn') == false) {
  800. return;
  801. }
  802. axios.post('/i/block', {
  803. type: 'user',
  804. item: this.status.account.id
  805. }).then(res => {
  806. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  807. }).catch(err => {
  808. swal('Error', 'Something went wrong. Please try again later.', 'error');
  809. });
  810. },
  811. deletePost(status) {
  812. if(!this.ownerOrAdmin()) {
  813. return;
  814. }
  815. var result = confirm('Are you sure you want to delete this post?');
  816. if (result) {
  817. if($('body').hasClass('loggedIn') == false) {
  818. return;
  819. }
  820. axios.post('/i/delete', {
  821. type: 'status',
  822. item: this.status.id
  823. }).then(res => {
  824. swal('Success', 'You have successfully deleted this post', 'success');
  825. setTimeout(function() {
  826. window.location.href = '/';
  827. }, 3000);
  828. }).catch(err => {
  829. swal('Error', 'Something went wrong. Please try again later.', 'error');
  830. });
  831. }
  832. },
  833. owner() {
  834. return this.user.id === this.status.account.id;
  835. },
  836. admin() {
  837. return this.user.is_admin == true;
  838. },
  839. ownerOrAdmin() {
  840. return this.owner() || this.admin();
  841. },
  842. lightbox(src) {
  843. this.lightboxMedia = src;
  844. this.$refs.lightboxModal.show();
  845. },
  846. postReply() {
  847. let self = this;
  848. if(this.replyText.length == 0 ||
  849. this.replyText.trim() == '@'+this.status.account.acct) {
  850. self.replyText = null;
  851. $('textarea[name="comment"]').blur();
  852. return;
  853. }
  854. let data = {
  855. item: this.replyingToId,
  856. comment: this.replyText
  857. }
  858. this.replyText = '';
  859. axios.post('/i/comment', data)
  860. .then(function(res) {
  861. let entity = res.data.entity;
  862. if(entity.in_reply_to_id == self.status.id) {
  863. if(self.layout == 'metro') {
  864. self.results.push(entity);
  865. } else {
  866. self.results.unshift(entity);
  867. }
  868. let elem = $('.status-comments')[0];
  869. elem.scrollTop = elem.clientHeight;
  870. } else {
  871. if(self.replyToIndex >= 0) {
  872. let el = self.results[self.replyToIndex];
  873. el.replies.push(entity);
  874. el.reply_count = el.reply_count + 1;
  875. }
  876. }
  877. });
  878. },
  879. deleteComment(id, i) {
  880. axios.post('/i/delete', {
  881. type: 'comment',
  882. item: id
  883. }).then(res => {
  884. this.results.splice(i, 1);
  885. }).catch(err => {
  886. swal('Something went wrong!', 'Please try again later', 'error');
  887. });
  888. },
  889. deleteCommentReply(id, i, pi) {
  890. axios.post('/i/delete', {
  891. type: 'comment',
  892. item: id
  893. }).then(res => {
  894. this.results[pi].replies.splice(i, 1);
  895. --this.results[pi].reply_count;
  896. }).catch(err => {
  897. swal('Something went wrong!', 'Please try again later', 'error');
  898. });
  899. },
  900. l(e) {
  901. let len = e.length;
  902. if(len < 10) { return e; }
  903. return e.substr(0, 10)+'...';
  904. },
  905. replyFocus(e, index) {
  906. this.replyToIndex = index;
  907. this.replyingToId = e.id;
  908. this.reply_to_profile_id = e.account.id;
  909. this.replyText = '@' + e.account.username + ' ';
  910. $('textarea[name="comment"]').focus();
  911. },
  912. fetchComments() {
  913. let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
  914. axios.get(url)
  915. .then(response => {
  916. let self = this;
  917. this.results = this.layout == 'metro' ?
  918. _.reverse(response.data.data) :
  919. response.data.data;
  920. this.pagination = response.data.meta.pagination;
  921. if(this.results.length > 0) {
  922. $('.load-more-link').removeClass('d-none');
  923. }
  924. $('.postCommentsLoader').addClass('d-none');
  925. $('.postCommentsContainer').removeClass('d-none');
  926. }).catch(error => {
  927. if(!error.response) {
  928. $('.postCommentsLoader .lds-ring')
  929. .attr('style','width:100%')
  930. .addClass('pt-4 font-weight-bold text-muted')
  931. .text('An error occurred, cannot fetch comments. Please try again later.');
  932. } else {
  933. switch(error.response.status) {
  934. case 401:
  935. $('.postCommentsLoader .lds-ring')
  936. .attr('style','width:100%')
  937. .addClass('pt-4 font-weight-bold text-muted')
  938. .text('Please login to view.');
  939. break;
  940. default:
  941. $('.postCommentsLoader .lds-ring')
  942. .attr('style','width:100%')
  943. .addClass('pt-4 font-weight-bold text-muted')
  944. .text('An error occurred, cannot fetch comments. Please try again later.');
  945. break;
  946. }
  947. }
  948. });
  949. },
  950. loadMore(e) {
  951. e.preventDefault();
  952. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  953. $('.load-more-link').addClass('d-none');
  954. return;
  955. }
  956. $('.postCommentsLoader').removeClass('d-none');
  957. let next = this.pagination.links.next;
  958. axios.get(next)
  959. .then(response => {
  960. let self = this;
  961. let res = response.data.data;
  962. $('.postCommentsLoader').addClass('d-none');
  963. for(let i=0; i < res.length; i++) {
  964. this.results.unshift(res[i]);
  965. }
  966. this.pagination = response.data.meta.pagination;
  967. });
  968. },
  969. likeReply(status, $event) {
  970. if($('body').hasClass('loggedIn') == false) {
  971. return;
  972. }
  973. axios.post('/i/like', {
  974. item: status.id
  975. }).then(res => {
  976. status.favourites_count = res.data.count;
  977. if(status.favourited == true) {
  978. status.favourited = false;
  979. } else {
  980. status.favourited = true;
  981. }
  982. }).catch(err => {
  983. swal('Error', 'Something went wrong, please try again later.', 'error');
  984. });
  985. },
  986. truncate(str,lim) {
  987. return _.truncate(str,{
  988. length: lim
  989. });
  990. },
  991. timeAgo(ts) {
  992. let date = Date.parse(ts);
  993. let seconds = Math.floor((new Date() - date) / 1000);
  994. let interval = Math.floor(seconds / 31536000);
  995. if (interval >= 1) {
  996. return interval + "y";
  997. }
  998. interval = Math.floor(seconds / 604800);
  999. if (interval >= 1) {
  1000. return interval + "w";
  1001. }
  1002. interval = Math.floor(seconds / 86400);
  1003. if (interval >= 1) {
  1004. return interval + "d";
  1005. }
  1006. interval = Math.floor(seconds / 3600);
  1007. if (interval >= 1) {
  1008. return interval + "h";
  1009. }
  1010. interval = Math.floor(seconds / 60);
  1011. if (interval >= 1) {
  1012. return interval + "m";
  1013. }
  1014. return Math.floor(seconds) + "s";
  1015. },
  1016. emojiReaction() {
  1017. let em = event.target.innerText;
  1018. if(this.replyText.length == 0) {
  1019. this.reply_to_profile_id = this.status.account.id;
  1020. this.replyText = em + ' ';
  1021. $('textarea[name="comment"]').focus();
  1022. } else {
  1023. this.reply_to_profile_id = this.status.account.id;
  1024. this.replyText += em + ' ';
  1025. $('textarea[name="comment"]').focus();
  1026. }
  1027. },
  1028. toggleCommentVisibility() {
  1029. if(this.ownerOrAdmin() == false) {
  1030. return;
  1031. }
  1032. let state = this.status.comments_disabled;
  1033. let self = this;
  1034. if(state == true) {
  1035. // re-enable comments
  1036. axios.post('/i/visibility', {
  1037. item: self.status.id,
  1038. disableComments: false
  1039. }).then(function(res) {
  1040. window.location.href = self.status.url;
  1041. }).catch(function(err) {
  1042. return;
  1043. });
  1044. } else {
  1045. // disable comments
  1046. axios.post('/i/visibility', {
  1047. item: self.status.id,
  1048. disableComments: true
  1049. }).then(function(res) {
  1050. self.status.comments_disabled = false;
  1051. self.showComments = false;
  1052. }).catch(function(err) {
  1053. return;
  1054. });
  1055. }
  1056. },
  1057. fetchRelationships() {
  1058. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1059. this.fetchData();
  1060. return;
  1061. } else {
  1062. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1063. params: {
  1064. 'id[]': this.statusProfileId
  1065. }
  1066. }).then(res => {
  1067. if(res.data[0] == null) {
  1068. this.fetchData();
  1069. return;
  1070. }
  1071. this.relationship = res.data[0];
  1072. if(res.data[0].blocking == true) {
  1073. this.loaded = true;
  1074. this.warning = true;
  1075. return;
  1076. } else {
  1077. this.fetchData();
  1078. return;
  1079. }
  1080. });
  1081. }
  1082. },
  1083. visibilityModal() {
  1084. switch(this.status.visibility) {
  1085. case 'public':
  1086. swal('Public Post', 'This post is visible to everyone.', 'info');
  1087. break;
  1088. case 'unlisted':
  1089. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1090. break;
  1091. case 'private':
  1092. swal('Private Post', 'This post is only visible to followers.', 'info');
  1093. break;
  1094. }
  1095. },
  1096. toggleReplies(reply) {
  1097. if(reply.thread) {
  1098. reply.thread = false;
  1099. } else {
  1100. if(reply.replies.length > 0) {
  1101. reply.thread = true;
  1102. return;
  1103. }
  1104. let url = '/api/v2/comments/'+reply.account.username+'/status/'+reply.id;
  1105. axios.get(url)
  1106. .then(response => {
  1107. reply.replies = _.reverse(response.data.data);
  1108. reply.thread = true;
  1109. });
  1110. }
  1111. },
  1112. redirect(url) {
  1113. window.location.href = url;
  1114. },
  1115. showEmbedPostModal() {
  1116. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url)
  1117. this.$refs.embedModal.show();
  1118. },
  1119. ctxCopyEmbed() {
  1120. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1121. this.$refs.embedModal.hide();
  1122. },
  1123. },
  1124. }
  1125. </script>