PostComponent.vue 62 KB

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