PostComponent.vue 51 KB

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