PostComponent.vue 62 KB

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