PostComponent.vue 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754
  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 mt-n4 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"><a href="#" class="btn btn-primary font-weight-bold px-5" @click.prevent="warning = false; fetchData()">View Status</a></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 class="mb-0" style="font-size: 10px;">
  28. <span v-if="loaded && status.taggedPeople.length" class="mb-0">
  29. <span class="font-weight-light cursor-pointer" style="color:#718096" title="Tagged People" data-toggle="tooltip" data-placement="bottom" @click="showTaggedPeopleModal()"><i class="fas fa-tag text-lighter"></i> <span class="font-weight-bold">{{status.taggedPeople.length}} Tagged People</span></span>
  30. </span>
  31. <span v-if="loaded && status.place != null && status.taggedPeople.length" class="px-2 font-weight-bold text-lighter">&#8226;</span>
  32. <span v-if="loaded && status.place != null" class="mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)"><i class="fas fa-map-marked-alt text-lighter"></i> <span class="font-weight-bold">{{status.place.name}}, {{status.place.country}}</span></span>
  33. </p>
  34. </div>
  35. </div>
  36. <div v-if="user != false" class="float-right">
  37. <div class="post-actions">
  38. <div>
  39. <button class="btn btn-link text-dark no-caret" title="Post options" @click="ctxMenu()">
  40. <span class="fas fa-ellipsis-v text-muted"></span>
  41. </button>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="col-12 col-md-8 px-0 mx-0">
  47. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center" style="background: #000;">
  48. <div v-if="status.pf_type === 'text'" class="w-100">
  49. <div class="w-100 card-img-top border-bottom rounded-0" style="background-image: url(/storage/textimg/bg_1.jpg);background-size: cover;width: 100%;height: 540px;">
  50. <div class="w-100 h-100 d-flex justify-content-center align-items-center">
  51. <p class="text-center text-break h3 px-5 font-weight-bold" v-html="status.content"></p>
  52. </div>
  53. </div>
  54. </div>
  55. <div v-else-if="status.pf_type === 'photo'" class="w-100">
  56. <photo-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-presenter>
  57. </div>
  58. <div v-else-if="status.pf_type === 'video'" class="w-100">
  59. <video-presenter :status="status" v-on:togglecw="status.sensitive = false"></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" v-on:togglecw="status.sensitive = false"></photo-album-presenter>
  63. </div>
  64. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  65. <video-album-presenter :status="status" v-on:togglecw="status.sensitive = false"></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" v-on:togglecw="status.sensitive = false"></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">
  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 class="mb-0" style="font-size: 10px;">
  88. <span v-if="loaded && status.taggedPeople.length" class="mb-0">
  89. <span class="font-weight-light cursor-pointer" style="color:#718096" title="Tagged People" data-toggle="tooltip" data-placement="bottom" @click="showTaggedPeopleModal()"><i class="fas fa-tag text-lighter"></i> <span class="font-weight-bold">{{status.taggedPeople.length}} Tagged People</span></span>
  90. </span>
  91. <span v-if="loaded && status.place != null && status.taggedPeople.length" class="px-2 font-weight-bold text-lighter">&#8226;</span>
  92. <span v-if="loaded && status.place != null" class="mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)"><i class="fas fa-map-marked-alt text-lighter"></i> <span class="font-weight-bold">{{status.place.name}}, {{status.place.country}}</span></span>
  93. </p>
  94. </div>
  95. </div>
  96. <div class="float-right">
  97. <div class="post-actions">
  98. <div v-if="user != false">
  99. <button class="btn btn-link text-dark no-caret" title="Post options" @click="ctxMenu()">
  100. <span class="fas fa-ellipsis-v text-muted"></span>
  101. </button>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div class="d-flex flex-md-column flex-column-reverse h-100" style="overflow-y: auto;">
  107. <div class="card-body status-comments pt-0">
  108. <div v-if="status.pf_type != 'text'" class="status-comment">
  109. <div v-if="status.content.length" class="pt-3">
  110. <div v-if="status.sensitive">
  111. <span class="py-3">
  112. <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>
  113. <span class="text-break">
  114. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  115. <span class="text-primary cursor-pointer pl-1" @click="status.sensitive = false">Show</span>
  116. </span>
  117. </span>
  118. </div>
  119. <div v-else>
  120. <p :class="[status.content.length > 620 ? 'mb-1 read-more' : 'mb-1']" style="overflow: hidden;">
  121. <a class="font-weight-bold pr-1 text-dark text-decoration-none" :href="statusProfileUrl">{{statusUsername}}</a>
  122. <span class="comment-text" :id="status.id + '-status-readmore'" v-html="status.content"></span>
  123. </p>
  124. </div>
  125. <hr>
  126. </div>
  127. <div v-if="showComments">
  128. <div class="postCommentsLoader text-center py-2">
  129. <div class="spinner-border" role="status">
  130. <span class="sr-only">Loading...</span>
  131. </div>
  132. </div>
  133. <div class="postCommentsContainer d-none">
  134. <p class="mb-1 text-center load-more-link d-none my-4">
  135. <a href="#" class="text-dark" v-on:click="loadMore" title="Load more comments" data-toggle="tooltip" data-placement="bottom">
  136. <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>
  137. </a>
  138. </p>
  139. <div class="comments mt-3">
  140. <div v-for="(reply, index) in results" class="pb-4 media" :key="'tl' + reply.id + '_' + index">
  141. <img :src="reply.account.avatar" class="rounded-circle border mr-3" width="42px" height="42px">
  142. <div class="media-body">
  143. <div v-if="reply.sensitive == true">
  144. <span class="py-3">
  145. <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>
  146. <span class="text-break">
  147. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  148. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  149. </span>
  150. </span>
  151. </div>
  152. <div v-else>
  153. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  154. <span>
  155. <a class="text-dark font-weight-bold mr-1 text-break" :href="reply.account.url" v-bind:title="reply.account.username">{{truncate(reply.account.username,15)}}</a>
  156. <span class="text-break comment-body" style="word-break: break-all;" v-html="reply.content"></span>
  157. </span>
  158. <span style="min-width:38px;">
  159. <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>
  160. <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>
  161. </span>
  162. </p>
  163. <p class="">
  164. <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>
  165. <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>
  166. <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index, true)">Reply</span>
  167. </p>
  168. <div v-if="reply.reply_count > 0" class="cursor-pointer" v-on:click="toggleReplies(reply)">
  169. <span class="show-reply-bar"></span>
  170. <span class="comment-reaction font-weight-bold text-muted">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
  171. </div>
  172. <div v-if="reply.thread == true" class="comment-thread">
  173. <div v-for="(s, sindex) in reply.replies" class="pb-3 media" :key="'cr' + s.id + '_' + index">
  174. <img :src="s.account.avatar" class="rounded-circle border mr-3" width="25px" height="25px">
  175. <div class="media-body">
  176. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  177. <span>
  178. <a class="text-dark font-weight-bold mr-1" :href="s.account.url" :title="s.account.username">{{s.account.username}}</a>
  179. <span class="text-break comment-body" style="word-break: break-all;" v-html="s.content"></span>
  180. </span>
  181. <span class="pl-2" style="min-width:38px">
  182. <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>
  183. <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>
  184. </span>
  185. </p>
  186. <p class="">
  187. <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>
  188. <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>
  189. </p>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. <div v-if="reactionBarLoading" class="card-body flex-grow-0 py-4 text-center">
  202. <div class="spinner-border" role="status">
  203. <span class="sr-only">Loading...</span>
  204. </div>
  205. </div>
  206. <div v-else class="card-body flex-grow-0 py-1">
  207. <div v-if="loaded && user.hasOwnProperty('id')" class="reactions my-2 pb-1 d-flex justify-content-between">
  208. <h3 v-bind:class="[reactions.liked ? 'fas fa-heart text-danger mr-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 mr-3 m-0 cursor-pointer" title="Comment" v-on:click="replyFocus(status)"></h3>
  210. <h3 @click="redirect(status.media_attachments[0].url)" class="fas fa-expand m-0 mr-3 cursor-pointer"></h3>
  211. <!-- <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> -->
  212. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 mr-3 cursor-pointer' : 'far fa-bookmark m-0 mr-3 cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
  213. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'fas fa-retweet m-0 text-primary cursor-pointer' : 'fas fa-retweet m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
  214. </div>
  215. <div class="reaction-counts mb-0">
  216. <div v-if="status.liked_by.username && status.liked_by.username !== user.username" class="likes mb-1">
  217. <span class="like-count">Liked by
  218. <a class="font-weight-bold text-dark" :href="status.liked_by.url">{{status.liked_by.username}}</a>
  219. <span v-if="status.liked_by.others == true">
  220. and <span class="font-weight-bold text-dark cursor-pointer" @click="likesModal"><span v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> others</span>
  221. </span>
  222. </span>
  223. </div>
  224. </div>
  225. <div class="timestamp d-flex align-items-bottom justify-content-between">
  226. <a v-bind:href="statusUrl" class="small text-muted" :title="status.created_at">
  227. {{timestampFormat()}}
  228. </a>
  229. <span class="small text-muted text-capitalize cursor-pointer" v-on:click="visibilityModal">{{status.visibility}}</span>
  230. </div>
  231. </div>
  232. </div>
  233. <div v-if="showComments" class="card-footer bg-white sticky-md-bottom p-0">
  234. <div v-if="user.length == 0" class="comment-form-guest p-3">
  235. <a href="/login">Login</a> to like or comment.
  236. </div>
  237. <form v-else class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="statusId" data-truncate="false">
  238. <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;" @click="replyFocus(status)"></textarea>
  239. <input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" disabled/>
  240. </form>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <div class="container" v-if="showProfileMorePosts">
  246. <p class="text-lighter px-3 mt-5" style="font-weight: 600;font-size: 15px;">More posts from <a :href="'/'+statusUsername" class="text-dark">{{this.statusUsername}}</a></p>
  247. <div class="profile-timeline mt-md-4">
  248. <div class="row">
  249. <div class="col-4 p-1 p-md-3" v-for="(s, index) in profileMorePosts" :key="'tlob:'+index">
  250. <a class="card info-overlay card-md-border-0" :href="getStatusUrl(s)" v-once>
  251. <div :class="[s.sensitive ? 'square' : 'square ' + s.media_attachments[0].filter_class]">
  252. <span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
  253. <span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
  254. <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
  255. <div class="square-content" v-bind:style="previewBackground(s)">
  256. </div>
  257. <div class="info-overlay-text">
  258. <h5 class="text-white m-auto font-weight-bold">
  259. <span>
  260. <span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
  261. <span class="d-flex-inline">{{s.favourites_count}}</span>
  262. </span>
  263. <span>
  264. <span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span>
  265. <span class="d-flex-inline">{{s.reblogs_count}}</span>
  266. </span>
  267. </h5>
  268. </div>
  269. </div>
  270. </a>
  271. </div>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. <div v-if="layout == 'moment'" class="momentui">
  277. <div class="bg-dark mt-md-n4">
  278. <div class="container" style="max-width: 700px;">
  279. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center bg-dark">
  280. <div v-if="status.pf_type === 'photo'" class="w-100">
  281. <photo-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-presenter>
  282. </div>
  283. <div v-else-if="status.pf_type === 'video'" class="w-100">
  284. <video-presenter :status="status" v-on:togglecw="status.sensitive = false"></video-presenter>
  285. </div>
  286. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  287. <photo-album-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-album-presenter>
  288. </div>
  289. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  290. <video-album-presenter :status="status" v-on:togglecw="status.sensitive = false"></video-album-presenter>
  291. </div>
  292. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  293. <mixed-album-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></mixed-album-presenter>
  294. </div>
  295. <div v-else class="w-100">
  296. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. <div class="bg-white">
  302. <div class="container">
  303. <div class="row pb-5">
  304. <div class="col-12 col-md-8 py-4">
  305. <div class="reactions d-flex align-items-center">
  306. <div class="text-center mr-5">
  307. <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">
  308. </div>
  309. <div class="like-count font-weight-bold mt-2 rounded border" style="cursor:pointer;" v-on:click="likesModal">
  310. {{ownerOrAdmin == true ? (status.liked_by.total_count + 1) : 0}}
  311. </div>
  312. </div>
  313. <div class="text-center">
  314. <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">
  315. </div>
  316. <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>
  317. </div>
  318. </div>
  319. <div v-if="status.length && status.content_text.includes('#') || status.content_text.includes('https://') || status.content_text.includes('@') || status.content_text.length > 45" class="media align-items-center mt-3">
  320. <div class="media-body">
  321. <p class="lead mr-2" v-html="status.content">
  322. </p>
  323. <p class="lead mb-0">
  324. by <a :href="statusProfileUrl">{{statusUsername}}</a>
  325. <span v-if="relationship && profile && user && !relationship.following && profile.id != user.id">
  326. <span class="px-1 text-lighter">•</span>
  327. <a class="font-weight-bold small" href="#">Follow</a>
  328. </span>
  329. </p>
  330. </div>
  331. <a :href="statusProfileUrl" :title="statusUsername"><img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="72px" height="72px"></a>
  332. </div>
  333. <div v-else class="media align-items-center mt-3">
  334. <div class="media-body">
  335. <h2 class="font-weight-bold mr-2">
  336. {{status.content_text.length ? status.content_text : 'Untitled Post'}}
  337. </h2>
  338. <p class="lead mb-0">
  339. by <a :href="statusProfileUrl">{{statusUsername}}</a>
  340. <!-- <span class="px-1 text-lighter">•</span>
  341. <a class="font-weight-bold small" href="#">Follow</a> -->
  342. </p>
  343. </div>
  344. <a :href="statusProfileUrl" :title="statusUsername"><img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="72px" height="72px"></a>
  345. </div>
  346. <hr>
  347. <div>
  348. <p class="lead">
  349. <span v-if="status.place" class="text-truncate">
  350. <i class="fas fa-map-marker-alt text-lighter mr-3"></i> {{status.place.name}}, {{status.place.country}}
  351. </span>
  352. <span v-once class="float-right">
  353. <i class="far fa-clock text-lighter mr-3"></i> {{timeAgo(status.created_at)}} ago
  354. </span>
  355. </p>
  356. <!-- <div class="">
  357. <p class="lead">
  358. <span class="mr-3"><i class="fas fa-camera text-lighter"></i></span>
  359. <span>Nikon D850</span>
  360. </p>
  361. <p class="lead">
  362. <span class="mr-3"><i class="fas fa-ruler-horizontal text-lighter"></i></span>
  363. <span>200-500mm</span>
  364. </p>
  365. <p class="lead">
  366. <span class="mr-3"><i class="fas fa-stream text-lighter"></i></span>
  367. <span>500mm <span class="px-1"></span> ƒ/7.1 <span class="px-1"></span> 1/1600s <span class="px-1"></span> ISO 800</span>
  368. </p>
  369. </div> -->
  370. <div v-if="status.tags" class="pt-4">
  371. <p class="lead">
  372. <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>
  373. </p>
  374. </div>
  375. </div>
  376. </div>
  377. <div class="col-12 col-md-4 pt-4 pl-md-3">
  378. <p class="lead font-weight-bold">Comments</p>
  379. <div v-if="user != false" class="moment-comments">
  380. <div class="form-group">
  381. <textarea class="form-control" rows="3" placeholder="Add a comment ..." v-model="replyText"></textarea>
  382. <p class="d-flex justify-content-between align-items-center mt-3">
  383. <span class="small text-lighter font-weight-bold">
  384. {{replyText.length}}/{{config.uploader.max_caption_length}}
  385. </span>
  386. <span v-if="replyText.length > 2">
  387. <div class="custom-control custom-switch">
  388. <input type="checkbox" class="custom-control-input" @click="!!replySensitive" v-model="replySensitive" id="sensitiveReply">
  389. <label class="custom-control-label small font-weight-bold text-muted" style="padding-top: 3px" for="sensitiveReply">Add Content Warning</label>
  390. </div>
  391. </span>
  392. <button class="btn btn-sm font-weight-bold btn-outline-primary py-1"
  393. v-if="replyText.length > 2" @click="postReply">Post</button>
  394. </p>
  395. </div>
  396. </div>
  397. <div class="comment mt-4" style="max-height: 500px; overflow-y: auto;">
  398. <div v-for="(reply, index) in results" :key="'tl' + reply.id + '_' + index" class="media mb-3 mt-2">
  399. <a :href="reply.account.url" :title="reply.account.username"><img :src="reply.account.avatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px"></a>
  400. <div class="media-body">
  401. <div class="d-flex justify-content-between">
  402. <span>
  403. <a class="font-weight-bold text-dark" :href="reply.account.url">{{reply.account.username}}</a>
  404. </span>
  405. <span class="text-lighter">
  406. <span v-if="reply.favourited" class="cursor-pointer mr-2" @click="likeReply(reply)">
  407. <i class="fas fa-heart text-danger"></i>
  408. </span>
  409. <span v-else class="cursor-pointer mr-2" @click="likeReply(reply)">
  410. <i class="far fa-heart"></i>
  411. </span>
  412. <span class="">
  413. <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>
  414. </span>
  415. </span>
  416. </div>
  417. <div v-if="reply.sensitive == true">
  418. <span class="py-3">
  419. <span class="text-break">
  420. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  421. <span class="badge badge-primary cursor-pointer ml-2 py-1" @click="reply.sensitive = false;">Show</span>
  422. </span>
  423. </span>
  424. </div>
  425. <div v-else class="read-more" style="overflow-y: hidden;">
  426. <p v-html="reply.content" class="mb-0">loading ...</p>
  427. </div>
  428. <p>
  429. <span class="small">
  430. <a class="text-lighter text-decoration-none" :href="reply.url">{{timeAgo(reply.created_at)}}</a>
  431. </span>
  432. </p>
  433. </div>
  434. </div>
  435. </div>
  436. </div>
  437. </div>
  438. </div>
  439. </div>
  440. </div>
  441. </div>
  442. <b-modal ref="likesModal"
  443. id="l-modal"
  444. hide-footer
  445. centered
  446. title="Likes"
  447. body-class="list-group-flush py-3 px-0">
  448. <div class="list-group">
  449. <div class="list-group-item border-0 py-1" v-for="(user, index) in likes" :key="'modal_likes_'+index">
  450. <div class="media">
  451. <a :href="user.url">
  452. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';">
  453. </a>
  454. <div class="media-body">
  455. <p class="mb-0" style="font-size: 14px">
  456. <a :href="user.url" class="font-weight-bold text-dark">
  457. {{user.username}}
  458. </a>
  459. </p>
  460. <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">
  461. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  462. </p>
  463. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  464. {{user.display_name}}
  465. </p>
  466. </div>
  467. </div>
  468. </div>
  469. <infinite-loading @infinite="infiniteLikesHandler" spinner="spiral">
  470. <div slot="no-more"></div>
  471. <div slot="no-results"></div>
  472. </infinite-loading>
  473. </div>
  474. </b-modal>
  475. <b-modal ref="sharesModal"
  476. id="s-modal"
  477. hide-footer
  478. centered
  479. title="Shares"
  480. body-class="list-group-flush py-3 px-0">
  481. <div class="list-group">
  482. <div class="list-group-item border-0 py-1" v-for="(user, index) in shares" :key="'modal_shares_'+index">
  483. <div class="media">
  484. <a :href="user.url">
  485. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  486. </a>
  487. <div class="media-body">
  488. <div class="d-inline-block">
  489. <p class="mb-0" style="font-size: 14px">
  490. <a :href="user.url" class="font-weight-bold text-dark">
  491. {{user.username}}
  492. </a>
  493. </p>
  494. <p class="text-muted mb-0" style="font-size: 14px">
  495. {{user.display_name}}
  496. </a>
  497. </p>
  498. </div>
  499. <p class="float-right"><!-- <a class="btn btn-primary font-weight-bold py-1" href="#">Follow</a> --></p>
  500. </div>
  501. </div>
  502. </div>
  503. <infinite-loading @infinite="infiniteSharesHandler" spinner="spiral">
  504. <div slot="no-more"></div>
  505. <div slot="no-results"></div>
  506. </infinite-loading>
  507. </div>
  508. </b-modal>
  509. <b-modal ref="lightboxModal"
  510. id="lightbox"
  511. :hide-header="true"
  512. :hide-footer="true"
  513. centered
  514. size="lg"
  515. body-class="p-0"
  516. >
  517. <div v-if="lightboxMedia" >
  518. <img :src="lightboxMedia.url" :class="lightboxMedia.filter_class + ' img-fluid'" style="min-height: 100%; min-width: 100%">
  519. </div>
  520. </b-modal>
  521. <b-modal ref="embedModal"
  522. id="ctx-embed-modal"
  523. hide-header
  524. hide-footer
  525. centered
  526. rounded
  527. size="md"
  528. body-class="p-2 rounded">
  529. <div>
  530. <div class="form-group">
  531. <textarea class="form-control disabled text-monospace" rows="8" style="overflow-y:hidden;border: 1px solid #efefef; font-size: 12px; line-height: 18px; margin: 0 0 7px;resize:none;" v-model="ctxEmbedPayload" disabled=""></textarea>
  532. </div>
  533. <div class="form-group pl-2 d-flex justify-content-center">
  534. <div class="form-check mr-3">
  535. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowCaption" :disabled="ctxEmbedCompactMode == true">
  536. <label class="form-check-label font-weight-light">
  537. Show Caption
  538. </label>
  539. </div>
  540. <div class="form-check mr-3">
  541. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowLikes" :disabled="ctxEmbedCompactMode == true">
  542. <label class="form-check-label font-weight-light">
  543. Show Likes
  544. </label>
  545. </div>
  546. <div class="form-check">
  547. <input class="form-check-input" type="checkbox" v-model="ctxEmbedCompactMode">
  548. <label class="form-check-label font-weight-light">
  549. Compact Mode
  550. </label>
  551. </div>
  552. </div>
  553. <hr>
  554. <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>
  555. <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>
  556. </div>
  557. </b-modal>
  558. <b-modal ref="taggedModal"
  559. id="tagged-modal"
  560. hide-footer
  561. centered
  562. title="Tagged People"
  563. body-class="list-group-flush py-3 px-0">
  564. <div class="list-group">
  565. <div class="list-group-item border-0 py-1" v-for="(taguser, index) in status.taggedPeople" :key="'modal_taggedpeople_'+index">
  566. <div class="media">
  567. <a :href="'/'+taguser.username">
  568. <img class="mr-3 rounded-circle box-shadow" :src="taguser.avatar" :alt="taguser.username + '’s avatar'" width="30px">
  569. </a>
  570. <div class="media-body">
  571. <p class="pt-1 d-flex justify-content-between" style="font-size: 14px">
  572. <a :href="'/'+taguser.username" class="font-weight-bold text-dark">
  573. {{taguser.username}}
  574. </a>
  575. <button v-if="taguser.id == user.id" class="btn btn-outline-primary btn-sm py-1 px-3" @click="untagMe()">Untag Me</button>
  576. </p>
  577. </div>
  578. </div>
  579. </div>
  580. </div>
  581. <p class="mb-0 text-center small text-muted font-weight-bold"><a href="/site/kb/tagging-people">Learn more</a> about Tagging People.</p>
  582. </b-modal>
  583. <b-modal ref="ctxModal"
  584. id="ctx-modal"
  585. hide-header
  586. hide-footer
  587. centered
  588. rounded
  589. size="sm"
  590. body-class="list-group-flush p-0 rounded">
  591. <div class="list-group text-center">
  592. <!-- <div v-if="user && user.id != status.account.id && relationship && relationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuUnfollow()">Unfollow</div>
  593. <div v-if="user && user.id != status.account.id && relationship && !relationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-primary" @click="ctxMenuFollow()">Follow</div> -->
  594. <div v-if="status && status.local == true" class="list-group-item rounded cursor-pointer" @click="showEmbedPostModal()">Embed</div>
  595. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
  596. <div v-if="status && user.id == status.account.id" class="list-group-item rounded cursor-pointer" @click="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</div>
  597. <a v-if="status && user.id == status.account.id" class="list-group-item rounded cursor-pointer text-dark text-decoration-none" :href="editUrl()">Edit</a>
  598. <div v-if="user && user.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenu()">Moderation Tools</div>
  599. <div v-if="status && user.id != status.account.id && !relationship.blocking && !user.is_admin" class="list-group-item rounded cursor-pointer text-danger" @click="blockProfile()">Block</div>
  600. <div v-if="status && user.id != status.account.id && relationship.blocking && !user.is_admin" class="list-group-item rounded cursor-pointer text-danger" @click="unblockProfile()">Unblock</div>
  601. <a v-if="user && user.id != status.account.id && !user.is_admin" class="list-group-item rounded cursor-pointer text-danger text-decoration-none" :href="reportUrl()">Report</a>
  602. <div v-if="status && (user.is_admin || user.id == status.account.id)" class="list-group-item rounded cursor-pointer text-danger" @click="deletePost(ctxMenuStatus)">Delete</div>
  603. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
  604. </div>
  605. </b-modal>
  606. <b-modal ref="ctxModModal"
  607. id="ctx-mod-modal"
  608. hide-header
  609. hide-footer
  610. centered
  611. rounded
  612. size="sm"
  613. body-class="list-group-flush p-0 rounded">
  614. <div class="list-group text-center">
  615. <div class="list-group-item rounded cursor-pointer" @click="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</div>
  616. <div class="list-group-item rounded cursor-pointer" @click="moderatePost('unlist')">Unlist from Timelines</div>
  617. <div v-if="status.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost('remcw')">Remove Content Warning</div>
  618. <div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost('addcw')">Add Content Warning</div>
  619. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
  620. </div>
  621. </b-modal>
  622. <b-modal ref="replyModal"
  623. id="ctx-reply-modal"
  624. hide-footer
  625. centered
  626. rounded
  627. :title-html="replyingToUsername ? 'Reply to <span class=text-dark>' + replyingToUsername + '</span>' : ''"
  628. title-tag="p"
  629. title-class="font-weight-bold text-muted"
  630. size="md"
  631. body-class="p-2 rounded">
  632. <div>
  633. <vue-tribute :options="tributeSettings">
  634. <textarea class="form-control" rows="4" style="border: none; font-size: 18px; resize: none; white-space: pre-wrap;outline: none;" placeholder="Reply here ..." v-model="replyText">
  635. </textarea>
  636. </vue-tribute>
  637. <div class="border-top border-bottom my-2">
  638. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  639. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  640. </ul>
  641. </div>
  642. <div class="d-flex justify-content-between align-items-center">
  643. <div>
  644. <span class="pl-2 small text-muted font-weight-bold text-monospace">
  645. <span :class="[replyText.length > config.uploader.max_caption_length ? 'text-danger':'text-dark']">{{replyText.length > config.uploader.max_caption_length ? config.uploader.max_caption_length - replyText.length : replyText.length}}</span>/{{config.uploader.max_caption_length}}
  646. </span>
  647. </div>
  648. <div class="d-flex align-items-center">
  649. <div class="custom-control custom-switch mr-3">
  650. <input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replySensitive">
  651. <label :class="[replySensitive ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label>
  652. </div>
  653. <!-- <select class="custom-select custom-select-sm my-0 mr-2">
  654. <option value="public" selected="">Public</option>
  655. <option value="unlisted">Unlisted</option>
  656. <option value="followers">Followers Only</option>
  657. </select> -->
  658. <button class="btn btn-primary btn-sm py-2 px-4 lead text-uppercase font-weight-bold" v-on:click.prevent="postReply()" :disabled="replyText.length == 0">
  659. {{replySending == true ? 'POSTING' : 'POST'}}
  660. </button>
  661. </div>
  662. </div>
  663. </div>
  664. </b-modal>
  665. </div>
  666. </template>
  667. <style type="text/css" scoped>
  668. .status-comments,
  669. .reactions {
  670. background: #fff;
  671. }
  672. .postPresenterContainer {
  673. background: #fff;
  674. }
  675. @media(min-width: 720px) {
  676. .postPresenterContainer {
  677. min-height: 600px;
  678. }
  679. }
  680. ::-webkit-scrollbar {
  681. width: 0px;
  682. background: transparent;
  683. }
  684. .reply-btn {
  685. position: absolute;
  686. bottom: 12px;
  687. right: 20px;
  688. width: 60px;
  689. text-align: center;
  690. border-radius: 0 3px 3px 0;
  691. }
  692. .text-lighter {
  693. color:#B8C2CC !important;
  694. }
  695. .text-break {
  696. overflow-wrap: break-word;
  697. }
  698. .comments p {
  699. margin-bottom: 0;
  700. }
  701. .comment-reaction {
  702. font-size: 80%;
  703. }
  704. .show-reply-bar {
  705. display: inline-block;
  706. border-bottom: 1px solid #999;
  707. height: 0;
  708. margin-right: 16px;
  709. vertical-align: middle;
  710. width: 24px;
  711. }
  712. .comment-thread {
  713. margin-top: 1rem;
  714. }
  715. .emoji-reactions .nav-item {
  716. font-size: 1.2rem;
  717. padding: 9px;
  718. cursor: pointer;
  719. }
  720. .emoji-reactions::-webkit-scrollbar {
  721. width: 0px;
  722. height: 0px;
  723. background: transparent;
  724. }
  725. @media (min-width: 1200px) {
  726. .container {
  727. max-width: 1100px;
  728. }
  729. }
  730. </style>
  731. <style type="text/css" scoped>
  732. .momentui .bg-dark {
  733. background: #000 !important;
  734. }
  735. .momentui .carousel.slide,
  736. .momentui .carousel-item {
  737. background: #000 !important;
  738. }
  739. .reply-btn[disabled] {
  740. opacity: .3;
  741. color: #3897f0;
  742. }
  743. </style>
  744. <script>
  745. import VueTribute from 'vue-tribute'
  746. pixelfed.postComponent = {};
  747. export default {
  748. props: [
  749. 'status-id',
  750. 'status-username',
  751. 'status-template',
  752. 'status-url',
  753. 'status-profile-url',
  754. 'status-avatar',
  755. 'status-profile-id',
  756. 'profile-layout',
  757. 'profile-recent'
  758. ],
  759. components: {
  760. VueTribute
  761. },
  762. data() {
  763. return {
  764. config: window.App.config,
  765. status: false,
  766. media: {},
  767. user: false,
  768. reactions: {
  769. liked: false,
  770. shared: false
  771. },
  772. likes: [],
  773. likesPage: 1,
  774. shares: [],
  775. sharesPage: 1,
  776. lightboxMedia: false,
  777. replyText: '',
  778. replyStatus: {},
  779. replySensitive: false,
  780. relationship: {},
  781. results: [],
  782. pagination: {},
  783. min_id: 0,
  784. max_id: 0,
  785. reply_to_profile_id: 0,
  786. thread: false,
  787. showComments: false,
  788. warning: false,
  789. loaded: false,
  790. loading: null,
  791. replyingToId: this.statusId,
  792. replyingToUsername: this.statusUsername,
  793. replyToIndex: 0,
  794. replySending: false,
  795. emoji: window.App.util.emoji,
  796. showReadMore: true,
  797. showCaption: true,
  798. ctxEmbedPayload: false,
  799. copiedEmbed: false,
  800. ctxEmbedShowCaption: true,
  801. ctxEmbedShowLikes: false,
  802. ctxEmbedCompactMode: false,
  803. layout: this.profileLayout,
  804. showProfileMorePosts: false,
  805. profileMorePosts: [],
  806. replySending: false,
  807. reactionBarLoading: true,
  808. tributeSettings: {
  809. collection: [
  810. {
  811. trigger: '@',
  812. menuShowMinLength: 2,
  813. values: (function (text, cb) {
  814. let url = '/api/compose/v0/search/mention';
  815. axios.get(url, { params: { q: text }})
  816. .then(res => {
  817. cb(res.data);
  818. })
  819. .catch(err => {
  820. console.log(err);
  821. })
  822. })
  823. },
  824. {
  825. trigger: '#',
  826. menuShowMinLength: 2,
  827. values: (function (text, cb) {
  828. let url = '/api/compose/v0/search/hashtag';
  829. axios.get(url, { params: { q: text }})
  830. .then(res => {
  831. cb(res.data);
  832. })
  833. .catch(err => {
  834. console.log(err);
  835. })
  836. })
  837. }
  838. ]
  839. }
  840. }
  841. },
  842. watch: {
  843. ctxEmbedShowCaption: function (n,o) {
  844. if(n == true) {
  845. this.ctxEmbedCompactMode = false;
  846. }
  847. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  848. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  849. },
  850. ctxEmbedShowLikes: function (n,o) {
  851. if(n == true) {
  852. this.ctxEmbedCompactMode = false;
  853. }
  854. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  855. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  856. },
  857. ctxEmbedCompactMode: function (n,o) {
  858. if(n == true) {
  859. this.ctxEmbedShowCaption = false;
  860. this.ctxEmbedShowLikes = false;
  861. }
  862. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  863. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  864. }
  865. },
  866. beforeMount() {
  867. let u = new URLSearchParams(window.location.search);
  868. let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
  869. if(this.statusTemplate == 'text') {
  870. this.layout = 'metro';
  871. return;
  872. }
  873. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  874. this.layout = 'moment';
  875. }
  876. if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
  877. this.layout = 'metro';
  878. }
  879. },
  880. mounted() {
  881. this.fetchRelationships();
  882. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  883. this.showReadMore = false;
  884. } else {
  885. this.showReadMore = true;
  886. }
  887. },
  888. updated() {
  889. $('.carousel').carousel();
  890. $('[data-toggle="tooltip"]').tooltip();
  891. if(this.showReadMore == true) {
  892. window.pixelfed.readmore();
  893. }
  894. },
  895. methods: {
  896. reportUrl() {
  897. return '/i/report?type=post&id=' + this.status.id;
  898. },
  899. editUrl() {
  900. return this.status.url + '/edit';
  901. },
  902. timestampFormat() {
  903. let ts = new Date(this.status.created_at);
  904. return ts.toDateString();
  905. },
  906. fetchData() {
  907. let self = this;
  908. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  909. .then(response => {
  910. self.status = response.data.status;
  911. self.media = self.status.media_attachments;
  912. self.likesPage = 2;
  913. self.sharesPage = 2;
  914. self.showCaption = !response.data.status.sensitive;
  915. if(self.status.comments_disabled == false) {
  916. self.showComments = true;
  917. this.fetchComments();
  918. }
  919. this.loaded = true;
  920. if(this.profileRecent !== false) {
  921. setTimeout(function() {
  922. self.fetchProfilePosts();
  923. }, 3000);
  924. }
  925. setTimeout(function() {
  926. self.fetchState();
  927. document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  928. i.href = App.util.format.rewriteLinks(i);
  929. });
  930. }, 500);
  931. }).catch(error => {
  932. swal('Oops!', 'An error occured, please try refreshing the page.', 'error');
  933. });
  934. },
  935. fetchState() {
  936. let self = this;
  937. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId+'/state')
  938. .then(res => {
  939. self.user = res.data.user;
  940. window._sharedData.curUser = self.user;
  941. window.App.util.navatar();
  942. self.likes = res.data.likes;
  943. self.shares = res.data.shares;
  944. self.reactions = res.data.reactions;
  945. self.reactionBarLoading = false;
  946. });
  947. },
  948. likesModal() {
  949. if($('body').hasClass('loggedIn') == false) {
  950. window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
  951. return;
  952. }
  953. if(this.likes.length) {
  954. this.$refs.likesModal.show();
  955. return;
  956. }
  957. axios.get('/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId)
  958. .then(res => {
  959. this.likes = res.data.data;
  960. this.$refs.likesModal.show();
  961. });
  962. },
  963. sharesModal() {
  964. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  965. window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
  966. return;
  967. }
  968. if(this.shares.length) {
  969. this.$refs.sharesModal.show();
  970. return;
  971. }
  972. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId)
  973. .then(res => {
  974. this.shares = res.data.data;
  975. this.$refs.sharesModal.show();
  976. });
  977. },
  978. infiniteLikesHandler($state) {
  979. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  980. axios.get(api, {
  981. params: {
  982. page: this.likesPage,
  983. },
  984. }).then(({ data }) => {
  985. if (data.data.length > 0) {
  986. this.likes.push(...data.data);
  987. this.likesPage++;
  988. $state.loaded();
  989. } else {
  990. $state.complete();
  991. }
  992. });
  993. },
  994. infiniteSharesHandler($state) {
  995. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  996. params: {
  997. page: this.sharesPage,
  998. },
  999. }).then(({ data }) => {
  1000. if (data.data.length > 0) {
  1001. this.shares.push(...data.data);
  1002. this.sharesPage++;
  1003. $state.loaded();
  1004. } else {
  1005. $state.complete();
  1006. }
  1007. });
  1008. },
  1009. likeStatus(event) {
  1010. if($('body').hasClass('loggedIn') == false) {
  1011. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  1012. return;
  1013. }
  1014. axios.post('/i/like', {
  1015. item: this.status.id
  1016. }).then(res => {
  1017. this.status.favourites_count = res.data.count;
  1018. if(this.reactions.liked == true) {
  1019. this.reactions.liked = false;
  1020. let user = this.user.id;
  1021. this.likes = this.likes.filter(function(like) {
  1022. return like.id !== user;
  1023. });
  1024. } else {
  1025. this.reactions.liked = true;
  1026. let user = this.user;
  1027. this.likes.unshift(user);
  1028. setTimeout(function() {
  1029. event.target.classList.add('animate__animated', 'animate__bounce');
  1030. },100);
  1031. }
  1032. }).catch(err => {
  1033. console.error(err);
  1034. swal('Error', 'Something went wrong, please try again later.', 'error');
  1035. });
  1036. window.navigator.vibrate(200);
  1037. },
  1038. shareStatus() {
  1039. if($('body').hasClass('loggedIn') == false) {
  1040. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  1041. return;
  1042. }
  1043. axios.post('/i/share', {
  1044. item: this.status.id
  1045. }).then(res => {
  1046. this.status.reblogs_count = res.data.count;
  1047. if(this.reactions.shared == true) {
  1048. this.reactions.shared = false;
  1049. let user = this.user.id;
  1050. this.shares = this.shares.filter(function(reaction) {
  1051. return reaction.id !== user;
  1052. });
  1053. } else {
  1054. this.reactions.shared = true;
  1055. let user = this.user;
  1056. this.shares.push(user);
  1057. }
  1058. }).catch(err => {
  1059. console.error(err);
  1060. swal('Error', 'Something went wrong, please try again later.', 'error');
  1061. });
  1062. },
  1063. bookmarkStatus() {
  1064. if($('body').hasClass('loggedIn') == false) {
  1065. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  1066. return;
  1067. }
  1068. axios.post('/i/bookmark', {
  1069. item: this.status.id
  1070. }).then(res => {
  1071. if(this.reactions.bookmarked == true) {
  1072. this.reactions.bookmarked = false;
  1073. } else {
  1074. this.reactions.bookmarked = true;
  1075. }
  1076. }).catch(err => {
  1077. swal('Error', 'Something went wrong, please try again later.', 'error');
  1078. });
  1079. },
  1080. blockProfile() {
  1081. if($('body').hasClass('loggedIn') == false) {
  1082. return;
  1083. }
  1084. axios.post('/i/block', {
  1085. type: 'user',
  1086. item: this.status.account.id
  1087. }).then(res => {
  1088. this.$refs.ctxModal.hide();
  1089. this.relationship.blocking = true;
  1090. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  1091. }).catch(err => {
  1092. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1093. });
  1094. },
  1095. unblockProfile() {
  1096. if($('body').hasClass('loggedIn') == false) {
  1097. return;
  1098. }
  1099. axios.post('/i/unblock', {
  1100. type: 'user',
  1101. item: this.status.account.id
  1102. }).then(res => {
  1103. this.relationship.blocking = false;
  1104. this.$refs.ctxModal.hide();
  1105. swal('Success', 'You have successfully unblocked ' + this.status.account.acct, 'success');
  1106. }).catch(err => {
  1107. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1108. });
  1109. },
  1110. deletePost(status) {
  1111. if(!this.ownerOrAdmin()) {
  1112. return;
  1113. }
  1114. var result = confirm('Are you sure you want to delete this post?');
  1115. if (result) {
  1116. if($('body').hasClass('loggedIn') == false) {
  1117. return;
  1118. }
  1119. axios.post('/i/delete', {
  1120. type: 'status',
  1121. item: this.status.id
  1122. }).then(res => {
  1123. swal('Success', 'You have successfully deleted this post', 'success');
  1124. setTimeout(function() {
  1125. window.location.href = '/';
  1126. }, 3000);
  1127. }).catch(err => {
  1128. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1129. });
  1130. }
  1131. },
  1132. owner() {
  1133. return this.user.id === this.status.account.id;
  1134. },
  1135. admin() {
  1136. return this.user.is_admin == true;
  1137. },
  1138. ownerOrAdmin() {
  1139. return this.owner() || this.admin();
  1140. },
  1141. lightbox(src) {
  1142. this.lightboxMedia = src;
  1143. this.$refs.lightboxModal.show();
  1144. },
  1145. postReply() {
  1146. let self = this;
  1147. this.replySending = true;
  1148. if(this.replyText.length == 0 ||
  1149. this.replyText.trim() == '@'+this.status.account.acct) {
  1150. self.replyText = null;
  1151. $('textarea[name="comment"]').blur();
  1152. return;
  1153. }
  1154. let data = {
  1155. item: this.replyingToId,
  1156. comment: this.replyText,
  1157. sensitive: this.replySensitive
  1158. }
  1159. this.replyText = '';
  1160. axios.post('/i/comment', data)
  1161. .then(function(res) {
  1162. let entity = res.data.entity;
  1163. if(entity.in_reply_to_id == self.status.id) {
  1164. if(self.layout == 'metro') {
  1165. self.results.push(entity);
  1166. } else {
  1167. self.results.unshift(entity);
  1168. }
  1169. let elem = $('.status-comments')[0];
  1170. elem.scrollTop = elem.clientHeight * 2;
  1171. } else {
  1172. if(self.replyToIndex >= 0) {
  1173. let el = self.results[self.replyToIndex];
  1174. el.replies.push(entity);
  1175. el.reply_count = el.reply_count + 1;
  1176. }
  1177. }
  1178. self.$refs.replyModal.hide();
  1179. self.replySending = false;
  1180. });
  1181. },
  1182. deleteComment(id, i) {
  1183. axios.post('/i/delete', {
  1184. type: 'comment',
  1185. item: id
  1186. }).then(res => {
  1187. this.results.splice(i, 1);
  1188. }).catch(err => {
  1189. swal('Something went wrong!', 'Please try again later', 'error');
  1190. });
  1191. },
  1192. deleteCommentReply(id, i, pi) {
  1193. axios.post('/i/delete', {
  1194. type: 'comment',
  1195. item: id
  1196. }).then(res => {
  1197. this.results[pi].replies.splice(i, 1);
  1198. --this.results[pi].reply_count;
  1199. }).catch(err => {
  1200. swal('Something went wrong!', 'Please try again later', 'error');
  1201. });
  1202. },
  1203. l(e) {
  1204. let len = e.length;
  1205. if(len < 10) { return e; }
  1206. return e.substr(0, 10)+'...';
  1207. },
  1208. replyFocus(e, index, prependUsername = false) {
  1209. if($('body').hasClass('loggedIn') == false) {
  1210. this.redirect('/login?next=' + encodeURIComponent(window.location.pathname));
  1211. return;
  1212. }
  1213. if(this.status.comments_disabled) {
  1214. return;
  1215. }
  1216. this.replyToIndex = index;
  1217. this.replyingToId = e.id;
  1218. this.replyingToUsername = e.account.username;
  1219. this.reply_to_profile_id = e.account.id;
  1220. let username = e.account.local ? '@' + e.account.username + ' '
  1221. : '@' + e.account.acct + ' ';
  1222. if(prependUsername == true) {
  1223. this.replyText = username;
  1224. }
  1225. this.$refs.replyModal.show();
  1226. },
  1227. fetchComments() {
  1228. let url = '/api/v2/comments/'+this.statusProfileId+'/status/'+this.statusId;
  1229. axios.get(url)
  1230. .then(response => {
  1231. let self = this;
  1232. this.results = this.layout == 'metro' ?
  1233. _.reverse(response.data.data) :
  1234. response.data.data;
  1235. this.pagination = response.data.meta.pagination;
  1236. if(this.results.length > 0) {
  1237. $('.load-more-link').removeClass('d-none');
  1238. }
  1239. $('.postCommentsLoader').addClass('d-none');
  1240. $('.postCommentsContainer').removeClass('d-none');
  1241. setTimeout(function() {
  1242. document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  1243. i.href = App.util.format.rewriteLinks(i);
  1244. });
  1245. }, 500);
  1246. }).catch(error => {
  1247. if(!error.response) {
  1248. $('.postCommentsLoader .lds-ring')
  1249. .attr('style','width:100%')
  1250. .addClass('pt-4 font-weight-bold text-muted')
  1251. .text('An error occurred, cannot fetch comments. Please try again later.');
  1252. } else {
  1253. switch(error.response.status) {
  1254. case 401:
  1255. $('.postCommentsLoader .lds-ring')
  1256. .attr('style','width:100%')
  1257. .addClass('pt-4 font-weight-bold text-muted')
  1258. .text('Please login to view.');
  1259. break;
  1260. default:
  1261. $('.postCommentsLoader .lds-ring')
  1262. .attr('style','width:100%')
  1263. .addClass('pt-4 font-weight-bold text-muted')
  1264. .text('An error occurred, cannot fetch comments. Please try again later.');
  1265. break;
  1266. }
  1267. }
  1268. });
  1269. },
  1270. loadMore(e) {
  1271. e.preventDefault();
  1272. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  1273. $('.load-more-link').addClass('d-none');
  1274. return;
  1275. }
  1276. $('.load-more-link').addClass('d-none');
  1277. $('.postCommentsLoader').removeClass('d-none');
  1278. let next = this.pagination.links.next;
  1279. axios.get(next)
  1280. .then(response => {
  1281. let self = this;
  1282. let res = response.data.data;
  1283. $('.postCommentsLoader').addClass('d-none');
  1284. for(let i=0; i < res.length; i++) {
  1285. this.results.unshift(res[i]);
  1286. }
  1287. this.pagination = response.data.meta.pagination;
  1288. $('.load-more-link').removeClass('d-none');
  1289. });
  1290. },
  1291. likeReply(status, $event) {
  1292. if($('body').hasClass('loggedIn') == false) {
  1293. swal('Login', 'Please login to perform this action.', 'info');
  1294. return;
  1295. }
  1296. axios.post('/i/like', {
  1297. item: status.id
  1298. }).then(res => {
  1299. status.favourites_count = res.data.count;
  1300. if(status.favourited == true) {
  1301. status.favourited = false;
  1302. } else {
  1303. status.favourited = true;
  1304. }
  1305. }).catch(err => {
  1306. swal('Error', 'Something went wrong, please try again later.', 'error');
  1307. });
  1308. },
  1309. truncate(str,lim) {
  1310. return _.truncate(str,{
  1311. length: lim
  1312. });
  1313. },
  1314. timeAgo(ts) {
  1315. return App.util.format.timeAgo(ts);
  1316. },
  1317. emojiReaction() {
  1318. let em = event.target.innerText;
  1319. if(this.replyText.length == 0) {
  1320. this.reply_to_profile_id = this.status.account.id;
  1321. this.replyText = em + ' ';
  1322. $('textarea[name="comment"]').focus();
  1323. } else {
  1324. this.reply_to_profile_id = this.status.account.id;
  1325. this.replyText += em + ' ';
  1326. $('textarea[name="comment"]').focus();
  1327. }
  1328. },
  1329. toggleCommentVisibility() {
  1330. if(this.ownerOrAdmin() == false) {
  1331. return;
  1332. }
  1333. let state = this.status.comments_disabled;
  1334. let self = this;
  1335. if(state == true) {
  1336. // re-enable comments
  1337. axios.post('/i/visibility', {
  1338. item: self.status.id,
  1339. disableComments: false
  1340. }).then(function(res) {
  1341. self.status.comments_disabled = false;
  1342. self.$refs.ctxModal.hide();
  1343. window.location.reload();
  1344. }).catch(function(err) {
  1345. return;
  1346. });
  1347. } else {
  1348. // disable comments
  1349. axios.post('/i/visibility', {
  1350. item: self.status.id,
  1351. disableComments: true
  1352. }).then(function(res) {
  1353. self.status.comments_disabled = true;
  1354. self.showComments = false;
  1355. self.$refs.ctxModal.hide();
  1356. }).catch(function(err) {
  1357. return;
  1358. });
  1359. }
  1360. },
  1361. fetchRelationships() {
  1362. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1363. this.fetchData();
  1364. return;
  1365. } else {
  1366. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1367. params: {
  1368. 'id[]': this.statusProfileId
  1369. }
  1370. }).then(res => {
  1371. if(res.data[0] == null) {
  1372. this.fetchData();
  1373. return;
  1374. }
  1375. this.relationship = res.data[0];
  1376. if(res.data[0].blocking == true) {
  1377. this.loaded = true;
  1378. this.warning = true;
  1379. return;
  1380. } else {
  1381. this.fetchData();
  1382. return;
  1383. }
  1384. });
  1385. }
  1386. },
  1387. visibilityModal() {
  1388. switch(this.status.visibility) {
  1389. case 'public':
  1390. swal('Public Post', 'This post is visible to everyone.', 'info');
  1391. break;
  1392. case 'unlisted':
  1393. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1394. break;
  1395. case 'private':
  1396. swal('Private Post', 'This post is only visible to followers.', 'info');
  1397. break;
  1398. }
  1399. },
  1400. toggleReplies(reply) {
  1401. if(reply.thread) {
  1402. reply.thread = false;
  1403. } else {
  1404. if(reply.replies.length > 0) {
  1405. reply.thread = true;
  1406. return;
  1407. }
  1408. let url = '/api/v2/comments/'+reply.account.id+'/status/'+reply.id;
  1409. axios.get(url)
  1410. .then(response => {
  1411. reply.replies = _.reverse(response.data.data);
  1412. reply.thread = true;
  1413. });
  1414. }
  1415. },
  1416. redirect(url) {
  1417. window.location.href = url;
  1418. },
  1419. showEmbedPostModal() {
  1420. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  1421. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  1422. this.$refs.ctxModal.hide();
  1423. this.$refs.embedModal.show();
  1424. },
  1425. ctxCopyEmbed() {
  1426. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1427. this.$refs.embedModal.hide();
  1428. },
  1429. permalinkUrl(reply, showOrigin = false) {
  1430. let profile = reply.account;
  1431. if(profile.local == true) {
  1432. return reply.url;
  1433. } else {
  1434. return showOrigin ?
  1435. reply.url :
  1436. '/i/web/post/_/' + profile.id + '/' + reply.id;
  1437. }
  1438. },
  1439. fetchProfilePosts() {
  1440. if(!$('body').hasClass('loggedIn') && this.loaded) {
  1441. return;
  1442. }
  1443. let self = this;
  1444. let apiUrl = '/api/pixelfed/v1/accounts/' + this.statusProfileId + '/statuses';
  1445. axios.get(apiUrl, {
  1446. params: {
  1447. only_media: true,
  1448. min_id: 1,
  1449. limit: 9
  1450. }
  1451. })
  1452. .then(res => {
  1453. let data = res.data.filter(function(status) {
  1454. return status.media_attachments.length > 0 &&
  1455. status.id != self.statusId &&
  1456. status.sensitive == false
  1457. });
  1458. let ids = data.map(status => status.id);
  1459. if(data.length >= 3) {
  1460. self.showProfileMorePosts = true;
  1461. }
  1462. self.profileMorePosts = data.slice(0,6);
  1463. })
  1464. },
  1465. previewUrl(status) {
  1466. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  1467. },
  1468. previewBackground(status) {
  1469. let preview = this.previewUrl(status);
  1470. return 'background-image: url(' + preview + ');';
  1471. },
  1472. getStatusUrl(status) {
  1473. if(status.local == true) {
  1474. return status.url;
  1475. }
  1476. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1477. },
  1478. showTaggedPeopleModal() {
  1479. if(!$('body').hasClass('loggedIn') && this.loaded) {
  1480. return;
  1481. }
  1482. this.$refs.taggedModal.show();
  1483. },
  1484. untagMe() {
  1485. this.$refs.taggedModal.hide();
  1486. let id = this.user.id;
  1487. axios.post('/api/local/compose/tag/untagme', {
  1488. status_id: this.statusId,
  1489. profile_id: id
  1490. }).then(res => {
  1491. this.status.taggedPeople = this.status.taggedPeople.filter(t => {
  1492. return t.id != id;
  1493. });
  1494. swal('Untagged', 'You have been untagged from this post.', 'success');
  1495. }).catch(err => {
  1496. swal('An Error Occurred', 'Please try again later.', 'error');
  1497. });
  1498. },
  1499. copyPostUrl() {
  1500. navigator.clipboard.writeText(this.statusUrl);
  1501. return;
  1502. },
  1503. moderatePost(action, $event) {
  1504. let status = this.status;
  1505. let username = status.account.username;
  1506. let msg = '';
  1507. let self = this;
  1508. switch(action) {
  1509. case 'addcw':
  1510. msg = 'Are you sure you want to add a content warning to this post?';
  1511. swal({
  1512. title: 'Confirm',
  1513. text: msg,
  1514. icon: 'warning',
  1515. buttons: true,
  1516. dangerMode: true
  1517. }).then(res => {
  1518. if(res) {
  1519. axios.post('/api/v2/moderator/action', {
  1520. action: action,
  1521. item_id: status.id,
  1522. item_type: 'status'
  1523. }).then(res => {
  1524. swal('Success', 'Successfully added content warning', 'success');
  1525. status.sensitive = true;
  1526. self.ctxModMenuClose();
  1527. }).catch(err => {
  1528. swal(
  1529. 'Error',
  1530. 'Something went wrong, please try again later.',
  1531. 'error'
  1532. );
  1533. self.ctxModMenuClose();
  1534. });
  1535. }
  1536. });
  1537. break;
  1538. case 'remcw':
  1539. msg = 'Are you sure you want to remove the content warning on this post?';
  1540. swal({
  1541. title: 'Confirm',
  1542. text: msg,
  1543. icon: 'warning',
  1544. buttons: true,
  1545. dangerMode: true
  1546. }).then(res => {
  1547. if(res) {
  1548. axios.post('/api/v2/moderator/action', {
  1549. action: action,
  1550. item_id: status.id,
  1551. item_type: 'status'
  1552. }).then(res => {
  1553. swal('Success', 'Successfully added content warning', 'success');
  1554. status.sensitive = false;
  1555. self.ctxModMenuClose();
  1556. }).catch(err => {
  1557. swal(
  1558. 'Error',
  1559. 'Something went wrong, please try again later.',
  1560. 'error'
  1561. );
  1562. self.ctxModMenuClose();
  1563. });
  1564. }
  1565. });
  1566. break;
  1567. case 'unlist':
  1568. msg = 'Are you sure you want to unlist this post?';
  1569. swal({
  1570. title: 'Confirm',
  1571. text: msg,
  1572. icon: 'warning',
  1573. buttons: true,
  1574. dangerMode: true
  1575. }).then(res => {
  1576. if(res) {
  1577. axios.post('/api/v2/moderator/action', {
  1578. action: action,
  1579. item_id: status.id,
  1580. item_type: 'status'
  1581. }).then(res => {
  1582. // this.feed = this.feed.filter(f => {
  1583. // return f.id != status.id;
  1584. // });
  1585. swal('Success', 'Successfully unlisted post', 'success');
  1586. self.ctxModMenuClose();
  1587. }).catch(err => {
  1588. self.ctxModMenuClose();
  1589. swal(
  1590. 'Error',
  1591. 'Something went wrong, please try again later.',
  1592. 'error'
  1593. );
  1594. });
  1595. }
  1596. });
  1597. break;
  1598. }
  1599. },
  1600. ctxMenu() {
  1601. this.$refs.ctxModal.show();
  1602. return;
  1603. },
  1604. closeCtxMenu(truncate) {
  1605. this.$refs.ctxModal.hide();
  1606. },
  1607. ctxModMenu() {
  1608. this.$refs.ctxModal.hide();
  1609. this.$refs.ctxModModal.show();
  1610. },
  1611. ctxModMenuClose() {
  1612. this.$refs.ctxModal.hide();
  1613. this.$refs.ctxModModal.hide();
  1614. },
  1615. ctxMenuCopyLink() {
  1616. let status = this.status;
  1617. navigator.clipboard.writeText(status.url);
  1618. this.closeCtxMenu();
  1619. return;
  1620. },
  1621. ctxMenuFollow() {
  1622. let id = this.status.account.id;
  1623. axios.post('/i/follow', {
  1624. item: id
  1625. }).then(res => {
  1626. let username = this.status.account.acct;
  1627. this.relationship.following = true;
  1628. this.$refs.ctxModal.hide();
  1629. setTimeout(function() {
  1630. swal('Follow successful!', 'You are now following ' + username, 'success');
  1631. }, 500);
  1632. });
  1633. },
  1634. ctxMenuUnfollow() {
  1635. let id = this.status.account.id;
  1636. axios.post('/i/follow', {
  1637. item: id
  1638. }).then(res => {
  1639. let username = this.status.account.acct;
  1640. this.relationship.following = false;
  1641. this.$refs.ctxModal.hide();
  1642. setTimeout(function() {
  1643. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1644. }, 500);
  1645. });
  1646. },
  1647. },
  1648. }
  1649. </script>