PostComponent.vue 73 KB

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