PostComponent.vue 73 KB

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