1
0

PostComponent.vue 72 KB

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