PostComponent.vue 73 KB

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