PostComponent.vue 63 KB

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