PostComponent.vue 72 KB

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