PostComponent.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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 py-3 px-0">
  394. <div class="list-group">
  395. <div class="list-group-item border-0 py-1" 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 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">
  407. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  408. </p>
  409. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  410. {{user.display_name}}
  411. </p>
  412. </div>
  413. </div>
  414. </div>
  415. <infinite-loading @infinite="infiniteLikesHandler" spinner="spiral">
  416. <div slot="no-more"></div>
  417. <div slot="no-results"></div>
  418. </infinite-loading>
  419. </div>
  420. </b-modal>
  421. <b-modal ref="sharesModal"
  422. id="s-modal"
  423. hide-footer
  424. centered
  425. title="Shares"
  426. body-class="list-group-flush p-0">
  427. <div class="list-group">
  428. <div class="list-group-item border-0" v-for="(user, index) in shares" :key="'modal_shares_'+index">
  429. <div class="media">
  430. <a :href="user.url">
  431. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  432. </a>
  433. <div class="media-body">
  434. <div class="d-inline-block">
  435. <p class="mb-0" style="font-size: 14px">
  436. <a :href="user.url" class="font-weight-bold text-dark">
  437. {{user.username}}
  438. </a>
  439. </p>
  440. <p class="text-muted mb-0" style="font-size: 14px">
  441. {{user.display_name}}
  442. </a>
  443. </p>
  444. </div>
  445. <p class="float-right"><!-- <a class="btn btn-primary font-weight-bold py-1" href="#">Follow</a> --></p>
  446. </div>
  447. </div>
  448. </div>
  449. <infinite-loading @infinite="infiniteSharesHandler" spinner="spiral">
  450. <div slot="no-more"></div>
  451. <div slot="no-results"></div>
  452. </infinite-loading>
  453. </div>
  454. </b-modal>
  455. <b-modal
  456. id="lightbox"
  457. ref="lightboxModal"
  458. :hide-header="true"
  459. :hide-footer="true"
  460. centered
  461. size="lg"
  462. body-class="p-0"
  463. >
  464. <div v-if="lightboxMedia" >
  465. <img :src="lightboxMedia.url" :class="lightboxMedia.filter_class + ' img-fluid'" style="min-height: 100%; min-width: 100%">
  466. </div>
  467. </b-modal>
  468. <b-modal ref="embedModal"
  469. id="ctx-embed-modal"
  470. hide-header
  471. hide-footer
  472. centered
  473. rounded
  474. size="md"
  475. body-class="p-2 rounded">
  476. <div>
  477. <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>
  478. <hr>
  479. <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>
  480. <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>
  481. </div>
  482. </b-modal>
  483. </div>
  484. </template>
  485. <style type="text/css" scoped>
  486. .status-comments,
  487. .reactions {
  488. background: #fff;
  489. }
  490. .postPresenterContainer {
  491. background: #fff;
  492. }
  493. @media(min-width: 720px) {
  494. .postPresenterContainer {
  495. min-height: 600px;
  496. }
  497. }
  498. ::-webkit-scrollbar {
  499. width: 0px;
  500. background: transparent;
  501. }
  502. .reply-btn {
  503. position: absolute;
  504. bottom: 12px;
  505. right: 20px;
  506. width: 60px;
  507. text-align: center;
  508. border-radius: 0 3px 3px 0;
  509. }
  510. .text-lighter {
  511. color:#B8C2CC !important;
  512. }
  513. .text-break {
  514. overflow-wrap: break-word;
  515. }
  516. .comments p {
  517. margin-bottom: 0;
  518. }
  519. .comment-reaction {
  520. font-size: 80%;
  521. }
  522. .show-reply-bar {
  523. display: inline-block;
  524. border-bottom: 1px solid #999;
  525. height: 0;
  526. margin-right: 16px;
  527. vertical-align: middle;
  528. width: 24px;
  529. }
  530. .comment-thread {
  531. margin: 4px 0 0 40px;
  532. width: calc(100% - 40px);
  533. }
  534. .emoji-reactions .nav-item {
  535. font-size: 1.2rem;
  536. padding: 9px;
  537. cursor: pointer;
  538. }
  539. .emoji-reactions::-webkit-scrollbar {
  540. width: 0px;
  541. height: 0px;
  542. background: transparent;
  543. }
  544. </style>
  545. <style type="text/css" scoped>
  546. .momentui .bg-dark {
  547. background: #000 !important;
  548. }
  549. .momentui .carousel.slide,
  550. .momentui .carousel-item {
  551. background: #000 !important;
  552. }
  553. .reply-btn[disabled] {
  554. opacity: .3;
  555. color: #3897f0;
  556. }
  557. </style>
  558. <script>
  559. pixelfed.postComponent = {};
  560. export default {
  561. props: [
  562. 'status-id',
  563. 'status-username',
  564. 'status-template',
  565. 'status-url',
  566. 'status-profile-url',
  567. 'status-avatar',
  568. 'status-profile-id',
  569. 'profile-layout'
  570. ],
  571. data() {
  572. return {
  573. config: window.App.config,
  574. status: false,
  575. media: {},
  576. user: false,
  577. reactions: {
  578. liked: false,
  579. shared: false
  580. },
  581. likes: [],
  582. likesPage: 1,
  583. shares: [],
  584. sharesPage: 1,
  585. lightboxMedia: false,
  586. replyText: '',
  587. relationship: {},
  588. results: [],
  589. pagination: {},
  590. min_id: 0,
  591. max_id: 0,
  592. reply_to_profile_id: 0,
  593. thread: false,
  594. showComments: false,
  595. warning: false,
  596. loaded: false,
  597. loading: null,
  598. replyingToId: this.statusId,
  599. replyToIndex: 0,
  600. emoji: window.App.util.emoji,
  601. showReadMore: true,
  602. showCaption: true,
  603. ctxEmbedPayload: false,
  604. copiedEmbed: false,
  605. layout: this.profileLayout
  606. }
  607. },
  608. beforeMount() {
  609. let u = new URLSearchParams(window.location.search);
  610. let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
  611. if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
  612. this.layout = 'metro';
  613. }
  614. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  615. this.layout = 'moment';
  616. }
  617. },
  618. mounted() {
  619. this.fetchRelationships();
  620. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  621. this.showReadMore = false;
  622. } else {
  623. this.showReadMore = true;
  624. }
  625. },
  626. updated() {
  627. $('.carousel').carousel();
  628. if(this.showReadMore == true) {
  629. window.pixelfed.readmore();
  630. }
  631. },
  632. methods: {
  633. showMuteBlock() {
  634. let sid = this.status.account.id;
  635. let uid = this.user.id;
  636. if(sid == uid) {
  637. $('.post-actions .menu-author').removeClass('d-none');
  638. } else {
  639. $('.post-actions .menu-user').removeClass('d-none');
  640. }
  641. },
  642. reportUrl() {
  643. return '/i/report?type=post&id=' + this.status.id;
  644. },
  645. editUrl() {
  646. return this.status.url + '/edit';
  647. },
  648. timestampFormat() {
  649. let ts = new Date(this.status.created_at);
  650. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  651. },
  652. fetchData() {
  653. let self = this;
  654. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  655. .then(response => {
  656. self.status = response.data.status;
  657. self.user = response.data.user;
  658. window._sharedData.curUser = self.user;
  659. self.media = self.status.media_attachments;
  660. self.reactions = response.data.reactions;
  661. self.likes = response.data.likes;
  662. self.shares = response.data.shares;
  663. self.likesPage = 2;
  664. self.sharesPage = 2;
  665. this.showMuteBlock();
  666. self.showCaption = !response.data.status.sensitive;
  667. if(self.status.comments_disabled == false) {
  668. self.showComments = true;
  669. this.fetchComments();
  670. }
  671. this.loaded = true;
  672. $('head title').text(this.status.account.username + ' posted a photo: ' + this.status.favourites_count + ' likes');
  673. }).catch(error => {
  674. swal('Oops!', 'An error occured, please try refreshing the page.', 'error');
  675. });
  676. },
  677. likesModal() {
  678. if(this.status.favourites_count == 0 || $('body').hasClass('loggedIn') == false) {
  679. return;
  680. }
  681. this.$refs.likesModal.show();
  682. },
  683. sharesModal() {
  684. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  685. return;
  686. }
  687. this.$refs.sharesModal.show();
  688. },
  689. infiniteLikesHandler($state) {
  690. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  691. axios.get(api, {
  692. params: {
  693. page: this.likesPage,
  694. },
  695. }).then(({ data }) => {
  696. if (data.data.length > 0) {
  697. this.likes.push(...data.data);
  698. this.likesPage++;
  699. $state.loaded();
  700. } else {
  701. $state.complete();
  702. }
  703. });
  704. },
  705. infiniteSharesHandler($state) {
  706. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  707. params: {
  708. page: this.sharesPage,
  709. },
  710. }).then(({ data }) => {
  711. if (data.data.length > 0) {
  712. this.shares.push(...data.data);
  713. this.sharesPage++;
  714. $state.loaded();
  715. } else {
  716. $state.complete();
  717. }
  718. });
  719. },
  720. likeStatus(event) {
  721. if($('body').hasClass('loggedIn') == false) {
  722. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  723. return;
  724. }
  725. axios.post('/i/like', {
  726. item: this.status.id
  727. }).then(res => {
  728. this.status.favourites_count = res.data.count;
  729. if(this.reactions.liked == true) {
  730. this.reactions.liked = false;
  731. let user = this.user.id;
  732. this.likes = this.likes.filter(function(like) {
  733. return like.id !== user;
  734. });
  735. } else {
  736. this.reactions.liked = true;
  737. let user = this.user;
  738. this.likes.push(user);
  739. }
  740. }).catch(err => {
  741. console.error(err);
  742. swal('Error', 'Something went wrong, please try again later.', 'error');
  743. });
  744. },
  745. shareStatus() {
  746. if($('body').hasClass('loggedIn') == false) {
  747. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  748. return;
  749. }
  750. axios.post('/i/share', {
  751. item: this.status.id
  752. }).then(res => {
  753. this.status.reblogs_count = res.data.count;
  754. if(this.reactions.shared == true) {
  755. this.reactions.shared = false;
  756. let user = this.user.id;
  757. this.shares = this.shares.filter(function(reaction) {
  758. return reaction.id !== user;
  759. });
  760. } else {
  761. this.reactions.shared = true;
  762. let user = this.user;
  763. this.shares.push(user);
  764. }
  765. }).catch(err => {
  766. console.error(err);
  767. swal('Error', 'Something went wrong, please try again later.', 'error');
  768. });
  769. },
  770. bookmarkStatus() {
  771. if($('body').hasClass('loggedIn') == false) {
  772. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  773. return;
  774. }
  775. axios.post('/i/bookmark', {
  776. item: this.status.id
  777. }).then(res => {
  778. if(this.reactions.bookmarked == true) {
  779. this.reactions.bookmarked = false;
  780. } else {
  781. this.reactions.bookmarked = true;
  782. }
  783. }).catch(err => {
  784. swal('Error', 'Something went wrong, please try again later.', 'error');
  785. });
  786. },
  787. muteProfile() {
  788. if($('body').hasClass('loggedIn') == false) {
  789. return;
  790. }
  791. axios.post('/i/mute', {
  792. type: 'user',
  793. item: this.status.account.id
  794. }).then(res => {
  795. swal('Success', 'You have successfully muted ' + this.status.account.acct, 'success');
  796. }).catch(err => {
  797. swal('Error', 'Something went wrong. Please try again later.', 'error');
  798. });
  799. },
  800. blockProfile() {
  801. if($('body').hasClass('loggedIn') == false) {
  802. return;
  803. }
  804. axios.post('/i/block', {
  805. type: 'user',
  806. item: this.status.account.id
  807. }).then(res => {
  808. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  809. }).catch(err => {
  810. swal('Error', 'Something went wrong. Please try again later.', 'error');
  811. });
  812. },
  813. deletePost(status) {
  814. if(!this.ownerOrAdmin()) {
  815. return;
  816. }
  817. var result = confirm('Are you sure you want to delete this post?');
  818. if (result) {
  819. if($('body').hasClass('loggedIn') == false) {
  820. return;
  821. }
  822. axios.post('/i/delete', {
  823. type: 'status',
  824. item: this.status.id
  825. }).then(res => {
  826. swal('Success', 'You have successfully deleted this post', 'success');
  827. setTimeout(function() {
  828. window.location.href = '/';
  829. }, 3000);
  830. }).catch(err => {
  831. swal('Error', 'Something went wrong. Please try again later.', 'error');
  832. });
  833. }
  834. },
  835. owner() {
  836. return this.user.id === this.status.account.id;
  837. },
  838. admin() {
  839. return this.user.is_admin == true;
  840. },
  841. ownerOrAdmin() {
  842. return this.owner() || this.admin();
  843. },
  844. lightbox(src) {
  845. this.lightboxMedia = src;
  846. this.$refs.lightboxModal.show();
  847. },
  848. postReply() {
  849. let self = this;
  850. if(this.replyText.length == 0 ||
  851. this.replyText.trim() == '@'+this.status.account.acct) {
  852. self.replyText = null;
  853. $('textarea[name="comment"]').blur();
  854. return;
  855. }
  856. let data = {
  857. item: this.replyingToId,
  858. comment: this.replyText
  859. }
  860. this.replyText = '';
  861. axios.post('/i/comment', data)
  862. .then(function(res) {
  863. let entity = res.data.entity;
  864. if(entity.in_reply_to_id == self.status.id) {
  865. if(self.layout == 'metro') {
  866. self.results.push(entity);
  867. } else {
  868. self.results.unshift(entity);
  869. }
  870. let elem = $('.status-comments')[0];
  871. elem.scrollTop = elem.clientHeight;
  872. } else {
  873. if(self.replyToIndex >= 0) {
  874. let el = self.results[self.replyToIndex];
  875. el.replies.push(entity);
  876. el.reply_count = el.reply_count + 1;
  877. }
  878. }
  879. });
  880. },
  881. deleteComment(id, i) {
  882. axios.post('/i/delete', {
  883. type: 'comment',
  884. item: id
  885. }).then(res => {
  886. this.results.splice(i, 1);
  887. }).catch(err => {
  888. swal('Something went wrong!', 'Please try again later', 'error');
  889. });
  890. },
  891. deleteCommentReply(id, i, pi) {
  892. axios.post('/i/delete', {
  893. type: 'comment',
  894. item: id
  895. }).then(res => {
  896. this.results[pi].replies.splice(i, 1);
  897. --this.results[pi].reply_count;
  898. }).catch(err => {
  899. swal('Something went wrong!', 'Please try again later', 'error');
  900. });
  901. },
  902. l(e) {
  903. let len = e.length;
  904. if(len < 10) { return e; }
  905. return e.substr(0, 10)+'...';
  906. },
  907. replyFocus(e, index) {
  908. this.replyToIndex = index;
  909. this.replyingToId = e.id;
  910. this.reply_to_profile_id = e.account.id;
  911. $('textarea[name="comment"]').focus();
  912. },
  913. fetchComments() {
  914. let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
  915. axios.get(url)
  916. .then(response => {
  917. let self = this;
  918. this.results = this.layout == 'metro' ?
  919. _.reverse(response.data.data) :
  920. response.data.data;
  921. this.pagination = response.data.meta.pagination;
  922. if(this.results.length > 0) {
  923. $('.load-more-link').removeClass('d-none');
  924. }
  925. $('.postCommentsLoader').addClass('d-none');
  926. $('.postCommentsContainer').removeClass('d-none');
  927. }).catch(error => {
  928. if(!error.response) {
  929. $('.postCommentsLoader .lds-ring')
  930. .attr('style','width:100%')
  931. .addClass('pt-4 font-weight-bold text-muted')
  932. .text('An error occurred, cannot fetch comments. Please try again later.');
  933. } else {
  934. switch(error.response.status) {
  935. case 401:
  936. $('.postCommentsLoader .lds-ring')
  937. .attr('style','width:100%')
  938. .addClass('pt-4 font-weight-bold text-muted')
  939. .text('Please login to view.');
  940. break;
  941. default:
  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. break;
  947. }
  948. }
  949. });
  950. },
  951. loadMore(e) {
  952. e.preventDefault();
  953. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  954. $('.load-more-link').addClass('d-none');
  955. return;
  956. }
  957. $('.postCommentsLoader').removeClass('d-none');
  958. let next = this.pagination.links.next;
  959. axios.get(next)
  960. .then(response => {
  961. let self = this;
  962. let res = response.data.data;
  963. $('.postCommentsLoader').addClass('d-none');
  964. for(let i=0; i < res.length; i++) {
  965. this.results.unshift(res[i]);
  966. }
  967. this.pagination = response.data.meta.pagination;
  968. });
  969. },
  970. likeReply(status, $event) {
  971. if($('body').hasClass('loggedIn') == false) {
  972. return;
  973. }
  974. axios.post('/i/like', {
  975. item: status.id
  976. }).then(res => {
  977. status.favourites_count = res.data.count;
  978. if(status.favourited == true) {
  979. status.favourited = false;
  980. } else {
  981. status.favourited = true;
  982. }
  983. }).catch(err => {
  984. swal('Error', 'Something went wrong, please try again later.', 'error');
  985. });
  986. },
  987. truncate(str,lim) {
  988. return _.truncate(str,{
  989. length: lim
  990. });
  991. },
  992. timeAgo(ts) {
  993. let date = Date.parse(ts);
  994. let seconds = Math.floor((new Date() - date) / 1000);
  995. let interval = Math.floor(seconds / 31536000);
  996. if (interval >= 1) {
  997. return interval + "y";
  998. }
  999. interval = Math.floor(seconds / 604800);
  1000. if (interval >= 1) {
  1001. return interval + "w";
  1002. }
  1003. interval = Math.floor(seconds / 86400);
  1004. if (interval >= 1) {
  1005. return interval + "d";
  1006. }
  1007. interval = Math.floor(seconds / 3600);
  1008. if (interval >= 1) {
  1009. return interval + "h";
  1010. }
  1011. interval = Math.floor(seconds / 60);
  1012. if (interval >= 1) {
  1013. return interval + "m";
  1014. }
  1015. return Math.floor(seconds) + "s";
  1016. },
  1017. emojiReaction() {
  1018. let em = event.target.innerText;
  1019. if(this.replyText.length == 0) {
  1020. this.reply_to_profile_id = this.status.account.id;
  1021. this.replyText = em + ' ';
  1022. $('textarea[name="comment"]').focus();
  1023. } else {
  1024. this.reply_to_profile_id = this.status.account.id;
  1025. this.replyText += em + ' ';
  1026. $('textarea[name="comment"]').focus();
  1027. }
  1028. },
  1029. toggleCommentVisibility() {
  1030. if(this.ownerOrAdmin() == false) {
  1031. return;
  1032. }
  1033. let state = this.status.comments_disabled;
  1034. let self = this;
  1035. if(state == true) {
  1036. // re-enable comments
  1037. axios.post('/i/visibility', {
  1038. item: self.status.id,
  1039. disableComments: false
  1040. }).then(function(res) {
  1041. window.location.href = self.status.url;
  1042. }).catch(function(err) {
  1043. return;
  1044. });
  1045. } else {
  1046. // disable comments
  1047. axios.post('/i/visibility', {
  1048. item: self.status.id,
  1049. disableComments: true
  1050. }).then(function(res) {
  1051. self.status.comments_disabled = false;
  1052. self.showComments = false;
  1053. }).catch(function(err) {
  1054. return;
  1055. });
  1056. }
  1057. },
  1058. fetchRelationships() {
  1059. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1060. this.fetchData();
  1061. return;
  1062. } else {
  1063. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1064. params: {
  1065. 'id[]': this.statusProfileId
  1066. }
  1067. }).then(res => {
  1068. if(res.data[0] == null) {
  1069. this.fetchData();
  1070. return;
  1071. }
  1072. this.relationship = res.data[0];
  1073. if(res.data[0].blocking == true) {
  1074. this.loaded = true;
  1075. this.warning = true;
  1076. return;
  1077. } else {
  1078. this.fetchData();
  1079. return;
  1080. }
  1081. });
  1082. }
  1083. },
  1084. visibilityModal() {
  1085. switch(this.status.visibility) {
  1086. case 'public':
  1087. swal('Public Post', 'This post is visible to everyone.', 'info');
  1088. break;
  1089. case 'unlisted':
  1090. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1091. break;
  1092. case 'private':
  1093. swal('Private Post', 'This post is only visible to followers.', 'info');
  1094. break;
  1095. }
  1096. },
  1097. toggleReplies(reply) {
  1098. if(reply.thread) {
  1099. reply.thread = false;
  1100. } else {
  1101. if(reply.replies.length > 0) {
  1102. reply.thread = true;
  1103. return;
  1104. }
  1105. let url = '/api/v2/comments/'+reply.account.username+'/status/'+reply.id;
  1106. axios.get(url)
  1107. .then(response => {
  1108. reply.replies = _.reverse(response.data.data);
  1109. reply.thread = true;
  1110. });
  1111. }
  1112. },
  1113. redirect(url) {
  1114. window.location.href = url;
  1115. },
  1116. showEmbedPostModal() {
  1117. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url)
  1118. this.$refs.embedModal.show();
  1119. },
  1120. ctxCopyEmbed() {
  1121. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1122. this.$refs.embedModal.hide();
  1123. },
  1124. },
  1125. }
  1126. </script>