PostComponent.vue 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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 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">Click <a href="#" class="cursor-pointer" @click.prevent="warning = false; fetchData()">here</a> to view this status</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 v-if="loaded && status.place != null" class="small mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)">{{status.place.name}}, {{status.place.country}}</p>
  28. </div>
  29. </div>
  30. <div v-if="user != false" class="float-right">
  31. <div class="post-actions">
  32. <div class="dropdown">
  33. <button class="btn btn-link text-dark no-caret dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  34. <span class="fas fa-ellipsis-v text-muted"></span>
  35. </button>
  36. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  37. <a class="dropdown-item font-weight-bold" @click="showEmbedPostModal()">Embed</a>
  38. <div v-if="!owner()">
  39. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  40. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile()">Mute Profile</a>
  41. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile()">Block Profile</a>
  42. </div>
  43. <div v-if="ownerOrAdmin()">
  44. <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
  45. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  46. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="col-12 col-md-8 px-0 mx-0">
  54. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center" style="background: #000;">
  55. <div v-if="status.pf_type === 'photo'" class="w-100">
  56. <photo-presenter :status="status" v-on:lightbox="lightbox"></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" data-toggle="tooltip" data-placement="bottom" :title="statusUsername">
  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 v-if="loaded && status.place != null" class="small mb-0 cursor-pointer text-truncate" style="color:#718096" @click="redirect('/discover/places/' + status.place.id + '/' + status.place.slug)">{{status.place.name}}, {{status.place.country}}</p>
  88. </div>
  89. </div>
  90. <div class="float-right">
  91. <div class="post-actions">
  92. <div v-if="user != false" class="dropdown">
  93. <button class="btn btn-link text-dark no-caret dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  94. <span class="fas fa-ellipsis-v text-muted"></span>
  95. </button>
  96. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  97. <a class="dropdown-item font-weight-bold" @click="showEmbedPostModal()">Embed</a>
  98. <span v-if="!owner()">
  99. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  100. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile">Mute Profile</a>
  101. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile">Block Profile</a>
  102. </span>
  103. <span v-if="ownerOrAdmin()">
  104. <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
  105. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  106. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
  107. </span>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="d-flex flex-md-column flex-column-reverse h-100" style="overflow-y: auto;">
  114. <div class="card-body status-comments pb-5">
  115. <div class="status-comment">
  116. <div v-if="showCaption != true">
  117. <span class="py-3">
  118. <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>
  119. <span class="text-break">
  120. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  121. <span class="text-primary cursor-pointer pl-1" @click="showCaption = true">Show</span>
  122. </span>
  123. </span>
  124. </div>
  125. <div v-else>
  126. <p :class="[status.content.length > 620 ? 'mb-1 read-more' : 'mb-1']" style="overflow: hidden;">
  127. <a class="font-weight-bold pr-1 text-dark text-decoration-none" :href="statusProfileUrl">{{statusUsername}}</a>
  128. <span class="comment-text" :id="status.id + '-status-readmore'" v-html="status.content"></span>
  129. </p>
  130. </div>
  131. <div v-if="showComments">
  132. <hr>
  133. <div class="postCommentsLoader text-center">
  134. <div class="spinner-border" role="status">
  135. <span class="sr-only">Loading...</span>
  136. </div>
  137. </div>
  138. <div class="postCommentsContainer d-none">
  139. <p v-if="status.reply_count > 10"class="mb-1 text-center load-more-link d-none"><a href="#" class="text-muted" v-on:click="loadMore">Load more comments</a></p>
  140. <div class="comments">
  141. <div v-for="(reply, index) in results" class="pb-3" :key="'tl' + reply.id + '_' + index">
  142. <div v-if="reply.sensitive == true">
  143. <span class="py-3">
  144. <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>
  145. <span class="text-break">
  146. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  147. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  148. </span>
  149. </span>
  150. </div>
  151. <div v-else>
  152. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  153. <span>
  154. <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>
  155. <span class="text-break" v-html="reply.content"></span>
  156. </span>
  157. <span class="pl-2" style="min-width:38px">
  158. <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>
  159. <post-menu :status="reply" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block pl-2" v-on:deletePost="deleteComment(reply.id, index)"></post-menu>
  160. </span>
  161. </p>
  162. <p class="">
  163. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(reply.created_at)" :href="reply.url"></a>
  164. <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>
  165. <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index)">Reply</span>
  166. </p>
  167. <div v-if="reply.reply_count > 0" class="cursor-pointer" style="margin-left:30px;" v-on:click="toggleReplies(reply)">
  168. <span class="show-reply-bar"></span>
  169. <span class="comment-reaction font-weight-bold text-muted">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
  170. </div>
  171. <div v-if="reply.thread == true" class="comment-thread">
  172. <div v-for="(s, sindex) in reply.replies" class="pb-3" :key="'cr' + s.id + '_' + index">
  173. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  174. <span>
  175. <a class="text-dark font-weight-bold mr-1" :href="s.account.url" :title="s.account.username">{{s.account.username}}</a>
  176. <span class="text-break" v-html="s.content"></span>
  177. </span>
  178. <span class="pl-2" style="min-width:38px">
  179. <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>
  180. <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>
  181. </span>
  182. </p>
  183. <p class="">
  184. <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>
  185. <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>
  186. </p>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="card-body flex-grow-0 py-1">
  197. <div class="reactions my-1">
  198. <h3 v-bind:class="[reactions.liked ? 'fas fa-heart text-danger pr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus"></h3>
  199. <h3 v-if="!status.comments_disabled" class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="replyFocus(status)"></h3>
  200. <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'far fa-share-square pr-3 m-0 text-primary cursor-pointer' : 'far fa-share-square pr-3 m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
  201. <h3 @click="lightbox(status.media_attachments[0])" class="fas fa-expand m-0 cursor-pointer"></h3>
  202. <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>
  203. </div>
  204. <div class="reaction-counts font-weight-bold mb-0">
  205. <span style="cursor:pointer;" v-on:click="likesModal">
  206. <span class="like-count">{{status.favourites_count || 0}}</span> likes
  207. </span>
  208. <span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
  209. <span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
  210. </span>
  211. </div>
  212. <div class="timestamp pt-2 d-flex align-items-bottom justify-content-between">
  213. <a v-bind:href="statusUrl" class="small text-muted">
  214. {{timestampFormat()}}
  215. </a>
  216. <span class="small text-muted text-capitalize cursor-pointer" v-on:click="visibilityModal">{{status.visibility}}</span>
  217. </div>
  218. </div>
  219. </div>
  220. <div v-if="showComments && user.length !== 0" class="card-footer bg-white px-2 py-0">
  221. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  222. <li class="nav-item" v-on:click="emojiReaction" v-for="e in emoji">{{e}}</li>
  223. </ul>
  224. </div>
  225. <div v-if="showComments" class="card-footer bg-white sticky-md-bottom p-0">
  226. <div v-if="user.length == 0" class="comment-form-guest p-3">
  227. <a href="/login">Login</a> to like or comment.
  228. </div>
  229. <form v-else class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="statusId" data-truncate="false">
  230. <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;" v-model="replyText"></textarea>
  231. <input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" v-on:click.prevent="postReply" :disabled="replyText.length == 0" />
  232. </form>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <div v-if="layout == 'moment'" class="momentui">
  239. <div class="bg-dark mt-md-n4">
  240. <div class="container" v-on:dblclick="likeStatus">
  241. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center bg-dark">
  242. <div v-if="status.pf_type === 'photo'" class="w-100">
  243. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  244. </div>
  245. <div v-else-if="status.pf_type === 'video'" class="w-100">
  246. <video-presenter :status="status"></video-presenter>
  247. </div>
  248. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  249. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  250. </div>
  251. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  252. <video-album-presenter :status="status"></video-album-presenter>
  253. </div>
  254. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  255. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  256. </div>
  257. <div v-else class="w-100">
  258. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. <div class="bg-white">
  264. <div class="container">
  265. <div class="row pb-5">
  266. <div class="col-12 col-md-8 py-4">
  267. <div class="reactions d-flex align-items-center">
  268. <div class="text-center mr-5">
  269. <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">
  270. </div>
  271. <div class="like-count font-weight-bold mt-2 rounded border" style="cursor:pointer;" v-on:click="likesModal">{{status.favourites_count || 0}}</div>
  272. </div>
  273. <div class="text-center">
  274. <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">
  275. </div>
  276. <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>
  277. </div>
  278. </div>
  279. <!-- <div class="reaction-counts font-weight-bold mb-0">
  280. <span class="like-count">{{status.favourites_count || 0}}</span> likes
  281. <span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
  282. <span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
  283. </span>
  284. </div> -->
  285. <div class="media align-items-center mt-3">
  286. <div class="media-body">
  287. <h2 class="font-weight-bold">
  288. {{status.content.length < 100 ? status.content.slice(0,100) : 'Untitled Post'}}
  289. </h2>
  290. <p class="lead mb-0">
  291. by <a :href="statusProfileUrl">{{statusUsername}}</a>
  292. <!-- <span class="px-1 text-lighter">•</span>
  293. <a class="font-weight-bold small" href="#">Follow</a> -->
  294. </p>
  295. </div>
  296. <img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="72px" height="72px">
  297. </div>
  298. <hr>
  299. <div>
  300. <p class="lead">
  301. <span v-if="status.place" class="text-truncate">
  302. <i class="fas fa-map-marker-alt text-lighter mr-3"></i> {{status.place.name}}, {{status.place.country}}
  303. </span>
  304. <span v-once class="float-right">
  305. <i class="far fa-clock text-lighter mr-3"></i> {{timeAgo(status.created_at)}} ago
  306. </span>
  307. </p>
  308. <!-- <div v-if="status.content.length > 100" class="lead" v-html="status.content"></div> -->
  309. <!-- <div class="pt-4">
  310. <p class="lead">
  311. <span class="mr-3"><i class="fas fa-camera text-lighter"></i></span>
  312. <span>Nikon D850</span>
  313. </p>
  314. <p class="lead">
  315. <span class="mr-3"><i class="fas fa-ruler-horizontal text-lighter"></i></span>
  316. <span>200-500mm</span>
  317. </p>
  318. <p class="lead">
  319. <span class="mr-3"><i class="fas fa-stream text-lighter"></i></span>
  320. <span>500mm <span class="px-1"></span> ƒ/7.1 <span class="px-1"></span> 1/1600s <span class="px-1"></span> ISO 800</span>
  321. </p>
  322. </div> -->
  323. <div v-if="status.tags" class="pt-4">
  324. <p class="lead">
  325. <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>
  326. </p>
  327. </div>
  328. </div>
  329. </div>
  330. <div class="col-12 col-md-4 pt-4 pl-md-3">
  331. <p class="lead font-weight-bold">Comments</p>
  332. <div v-if="user && user.length" class="moment-comments">
  333. <div class="form-group">
  334. <textarea class="form-control" rows="3" placeholder="Add a comment ..." v-model="replyText"></textarea>
  335. <p style="padding-top:4px;">
  336. <span class="small text-lighter font-weight-bold">
  337. {{replyText.length}}/{{config.uploader.max_caption_length}}
  338. </span>
  339. <button
  340. :class="[replyText.length > 1 ? 'btn btn-sm font-weight-bold float-right btn-outline-dark ':'btn btn-sm font-weight-bold float-right btn-outline-lighter']"
  341. :disabled="replyText.length == 0 ? 'disabled':''"
  342. @click="postReply"
  343. >Post</button>
  344. </p>
  345. </div>
  346. <hr>
  347. </div>
  348. <div class="comment mt-3" style="max-height: 500px; overflow-y: auto;">
  349. <div v-for="(reply, index) in results" :key="'tl' + reply.id + '_' + index" class="media mb-3">
  350. <img :src="reply.account.avatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px">
  351. <div class="media-body">
  352. <div class="d-flex justify-content-between">
  353. <span class="font-weight-bold">{{reply.account.username}}</span>
  354. <span class="small">
  355. <a class="text-lighter text-decoration-none" :href="reply.url">{{timeAgo(reply.created_at)}}</a>
  356. </span>
  357. </div>
  358. <p v-html="reply.content"></p>
  359. </div>
  360. </div>
  361. <!-- <div class="media mb-3">
  362. <img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px">
  363. <div class="media-body">
  364. <div class="d-flex justify-content-between">
  365. <span class="font-weight-bold">mona</span>
  366. <span class="text-lighter small">2h ago</span>
  367. </div>
  368. <p>Stunning my friend!</p>
  369. </div>
  370. </div>
  371. <div class="media mb-3">
  372. <img :src="statusAvatar" class="rounded-circle border mr-3" alt="avatar" width="32px" height="32px">
  373. <div class="media-body">
  374. <div class="d-flex justify-content-between">
  375. <span class="font-weight-bold">Andre</span>
  376. <span class="text-lighter small">3h ago</span>
  377. </div>
  378. <p>Wow</p>
  379. </div>
  380. </div> -->
  381. </div>
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. </div>
  387. </div>
  388. <b-modal ref="likesModal"
  389. id="l-modal"
  390. hide-footer
  391. centered
  392. title="Likes"
  393. body-class="list-group-flush p-0">
  394. <div class="list-group">
  395. <div class="list-group-item border-0" v-for="(user, index) in likes" :key="'modal_likes_'+index">
  396. <div class="media">
  397. <a :href="user.url">
  398. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  399. </a>
  400. <div class="media-body">
  401. <p class="mb-0" style="font-size: 14px">
  402. <a :href="user.url" class="font-weight-bold text-dark">
  403. {{user.username}}
  404. </a>
  405. </p>
  406. <p class="text-muted mb-0" style="font-size: 14px">
  407. {{user.display_name}}
  408. </a>
  409. </p>
  410. </div>
  411. </div>
  412. </div>
  413. <infinite-loading @infinite="infiniteLikesHandler" spinner="spiral">
  414. <div slot="no-more"></div>
  415. <div slot="no-results"></div>
  416. </infinite-loading>
  417. </div>
  418. </b-modal>
  419. <b-modal ref="sharesModal"
  420. id="s-modal"
  421. hide-footer
  422. centered
  423. title="Shares"
  424. body-class="list-group-flush p-0">
  425. <div class="list-group">
  426. <div class="list-group-item border-0" v-for="(user, index) in shares" :key="'modal_shares_'+index">
  427. <div class="media">
  428. <a :href="user.url">
  429. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  430. </a>
  431. <div class="media-body">
  432. <div class="d-inline-block">
  433. <p class="mb-0" style="font-size: 14px">
  434. <a :href="user.url" class="font-weight-bold text-dark">
  435. {{user.username}}
  436. </a>
  437. </p>
  438. <p class="text-muted mb-0" style="font-size: 14px">
  439. {{user.display_name}}
  440. </a>
  441. </p>
  442. </div>
  443. <p class="float-right"><!-- <a class="btn btn-primary font-weight-bold py-1" href="#">Follow</a> --></p>
  444. </div>
  445. </div>
  446. </div>
  447. <infinite-loading @infinite="infiniteSharesHandler" spinner="spiral">
  448. <div slot="no-more"></div>
  449. <div slot="no-results"></div>
  450. </infinite-loading>
  451. </div>
  452. </b-modal>
  453. <b-modal
  454. id="lightbox"
  455. ref="lightboxModal"
  456. :hide-header="true"
  457. :hide-footer="true"
  458. centered
  459. size="lg"
  460. body-class="p-0"
  461. >
  462. <div v-if="lightboxMedia" >
  463. <img :src="lightboxMedia.url" :class="lightboxMedia.filter_class + ' img-fluid'" style="min-height: 100%; min-width: 100%">
  464. </div>
  465. </b-modal>
  466. <b-modal ref="embedModal"
  467. id="ctx-embed-modal"
  468. hide-header
  469. hide-footer
  470. centered
  471. rounded
  472. size="md"
  473. body-class="p-2 rounded">
  474. <div>
  475. <textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 12px; height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
  476. <hr>
  477. <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>
  478. <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>
  479. </div>
  480. </b-modal>
  481. </div>
  482. </template>
  483. <style type="text/css" scoped>
  484. .status-comments,
  485. .reactions {
  486. background: #fff;
  487. }
  488. .postPresenterContainer {
  489. background: #fff;
  490. }
  491. @media(min-width: 720px) {
  492. .postPresenterContainer {
  493. min-height: 600px;
  494. }
  495. }
  496. ::-webkit-scrollbar {
  497. width: 0px;
  498. background: transparent;
  499. }
  500. .reply-btn {
  501. position: absolute;
  502. bottom: 12px;
  503. right: 20px;
  504. width: 60px;
  505. text-align: center;
  506. border-radius: 0 3px 3px 0;
  507. }
  508. .text-lighter {
  509. color:#B8C2CC !important;
  510. }
  511. .text-break {
  512. overflow-wrap: break-word;
  513. }
  514. .comments p {
  515. margin-bottom: 0;
  516. }
  517. .comment-reaction {
  518. font-size: 80%;
  519. }
  520. .show-reply-bar {
  521. display: inline-block;
  522. border-bottom: 1px solid #999;
  523. height: 0;
  524. margin-right: 16px;
  525. vertical-align: middle;
  526. width: 24px;
  527. }
  528. .comment-thread {
  529. margin: 4px 0 0 40px;
  530. width: calc(100% - 40px);
  531. }
  532. .emoji-reactions .nav-item {
  533. font-size: 1.2rem;
  534. padding: 9px;
  535. cursor: pointer;
  536. }
  537. .emoji-reactions::-webkit-scrollbar {
  538. width: 0px;
  539. height: 0px;
  540. background: transparent;
  541. }
  542. </style>
  543. <style type="text/css" scoped>
  544. .momentui .bg-dark {
  545. background: #000 !important;
  546. }
  547. .momentui .carousel.slide,
  548. .momentui .carousel-item {
  549. background: #000 !important;
  550. }
  551. .reply-btn[disabled] {
  552. opacity: .3;
  553. color: #3897f0;
  554. }
  555. </style>
  556. <script>
  557. pixelfed.postComponent = {};
  558. export default {
  559. props: [
  560. 'status-id',
  561. 'status-username',
  562. 'status-template',
  563. 'status-url',
  564. 'status-profile-url',
  565. 'status-avatar',
  566. 'status-profile-id',
  567. 'profile-layout'
  568. ],
  569. data() {
  570. return {
  571. config: window.App.config,
  572. status: false,
  573. media: {},
  574. user: false,
  575. reactions: {
  576. liked: false,
  577. shared: false
  578. },
  579. likes: [],
  580. likesPage: 1,
  581. shares: [],
  582. sharesPage: 1,
  583. lightboxMedia: false,
  584. replyText: '',
  585. relationship: {},
  586. results: [],
  587. pagination: {},
  588. min_id: 0,
  589. max_id: 0,
  590. reply_to_profile_id: 0,
  591. thread: false,
  592. showComments: false,
  593. warning: false,
  594. loaded: false,
  595. loading: null,
  596. replyingToId: this.statusId,
  597. replyToIndex: 0,
  598. emoji: window.App.util.emoji,
  599. showReadMore: true,
  600. showCaption: true,
  601. ctxEmbedPayload: false,
  602. copiedEmbed: false,
  603. layout: this.profileLayout
  604. }
  605. },
  606. beforeMount() {
  607. let u = new URLSearchParams(window.location.search);
  608. let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
  609. if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
  610. this.layout = 'metro';
  611. }
  612. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  613. this.layout = 'moment';
  614. }
  615. },
  616. mounted() {
  617. this.fetchRelationships();
  618. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  619. this.showReadMore = false;
  620. } else {
  621. this.showReadMore = true;
  622. }
  623. },
  624. updated() {
  625. $('.carousel').carousel();
  626. if(this.showReadMore == true) {
  627. window.pixelfed.readmore();
  628. }
  629. },
  630. methods: {
  631. showMuteBlock() {
  632. let sid = this.status.account.id;
  633. let uid = this.user.id;
  634. if(sid == uid) {
  635. $('.post-actions .menu-author').removeClass('d-none');
  636. } else {
  637. $('.post-actions .menu-user').removeClass('d-none');
  638. }
  639. },
  640. reportUrl() {
  641. return '/i/report?type=post&id=' + this.status.id;
  642. },
  643. editUrl() {
  644. return this.status.url + '/edit';
  645. },
  646. timestampFormat() {
  647. let ts = new Date(this.status.created_at);
  648. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  649. },
  650. fetchData() {
  651. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  652. .then(response => {
  653. let self = this;
  654. self.status = response.data.status;
  655. self.user = response.data.user;
  656. window._sharedData.curUser = self.user;
  657. self.media = self.status.media_attachments;
  658. self.reactions = response.data.reactions;
  659. self.likes = response.data.likes;
  660. self.shares = response.data.shares;
  661. self.likesPage = 2;
  662. self.sharesPage = 2;
  663. this.showMuteBlock();
  664. self.showCaption = !response.data.status.sensitive;
  665. if(self.status.comments_disabled == false) {
  666. self.showComments = true;
  667. this.fetchComments();
  668. }
  669. this.loaded = true;
  670. $('head title').text(this.status.account.username + ' posted a photo: ' + this.status.favourites_count + ' likes');
  671. }).catch(error => {
  672. if(!error.response) {
  673. } else {
  674. switch(error.response.status) {
  675. case 401:
  676. break;
  677. default:
  678. break;
  679. }
  680. }
  681. });
  682. },
  683. likesModal() {
  684. if(this.status.favourites_count == 0 || $('body').hasClass('loggedIn') == false) {
  685. return;
  686. }
  687. this.$refs.likesModal.show();
  688. },
  689. sharesModal() {
  690. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  691. return;
  692. }
  693. this.$refs.sharesModal.show();
  694. },
  695. infiniteLikesHandler($state) {
  696. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  697. axios.get(api, {
  698. params: {
  699. page: this.likesPage,
  700. },
  701. }).then(({ data }) => {
  702. if (data.data.length > 0) {
  703. this.likes.push(...data.data);
  704. this.likesPage++;
  705. $state.loaded();
  706. } else {
  707. $state.complete();
  708. }
  709. });
  710. },
  711. infiniteSharesHandler($state) {
  712. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  713. params: {
  714. page: this.sharesPage,
  715. },
  716. }).then(({ data }) => {
  717. if (data.data.length > 0) {
  718. this.shares.push(...data.data);
  719. this.sharesPage++;
  720. $state.loaded();
  721. } else {
  722. $state.complete();
  723. }
  724. });
  725. },
  726. likeStatus(event) {
  727. if($('body').hasClass('loggedIn') == false) {
  728. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  729. return;
  730. }
  731. axios.post('/i/like', {
  732. item: this.status.id
  733. }).then(res => {
  734. this.status.favourites_count = res.data.count;
  735. if(this.reactions.liked == true) {
  736. this.reactions.liked = false;
  737. let user = this.user.id;
  738. this.likes = this.likes.filter(function(like) {
  739. return like.id !== user;
  740. });
  741. } else {
  742. this.reactions.liked = true;
  743. let user = this.user;
  744. this.likes.push(user);
  745. }
  746. }).catch(err => {
  747. console.error(err);
  748. swal('Error', 'Something went wrong, please try again later.', 'error');
  749. });
  750. },
  751. shareStatus() {
  752. if($('body').hasClass('loggedIn') == false) {
  753. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  754. return;
  755. }
  756. axios.post('/i/share', {
  757. item: this.status.id
  758. }).then(res => {
  759. this.status.reblogs_count = res.data.count;
  760. if(this.reactions.shared == true) {
  761. this.reactions.shared = false;
  762. let user = this.user.id;
  763. this.shares = this.shares.filter(function(reaction) {
  764. return reaction.id !== user;
  765. });
  766. } else {
  767. this.reactions.shared = true;
  768. let user = this.user;
  769. this.shares.push(user);
  770. }
  771. }).catch(err => {
  772. console.error(err);
  773. swal('Error', 'Something went wrong, please try again later.', 'error');
  774. });
  775. },
  776. bookmarkStatus() {
  777. if($('body').hasClass('loggedIn') == false) {
  778. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  779. return;
  780. }
  781. axios.post('/i/bookmark', {
  782. item: this.status.id
  783. }).then(res => {
  784. if(this.reactions.bookmarked == true) {
  785. this.reactions.bookmarked = false;
  786. } else {
  787. this.reactions.bookmarked = true;
  788. }
  789. }).catch(err => {
  790. swal('Error', 'Something went wrong, please try again later.', 'error');
  791. });
  792. },
  793. muteProfile() {
  794. if($('body').hasClass('loggedIn') == false) {
  795. return;
  796. }
  797. axios.post('/i/mute', {
  798. type: 'user',
  799. item: this.status.account.id
  800. }).then(res => {
  801. swal('Success', 'You have successfully muted ' + this.status.account.acct, 'success');
  802. }).catch(err => {
  803. swal('Error', 'Something went wrong. Please try again later.', 'error');
  804. });
  805. },
  806. blockProfile() {
  807. if($('body').hasClass('loggedIn') == false) {
  808. return;
  809. }
  810. axios.post('/i/block', {
  811. type: 'user',
  812. item: this.status.account.id
  813. }).then(res => {
  814. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  815. }).catch(err => {
  816. swal('Error', 'Something went wrong. Please try again later.', 'error');
  817. });
  818. },
  819. deletePost(status) {
  820. if(!this.ownerOrAdmin()) {
  821. return;
  822. }
  823. var result = confirm('Are you sure you want to delete this post?');
  824. if (result) {
  825. if($('body').hasClass('loggedIn') == false) {
  826. return;
  827. }
  828. axios.post('/i/delete', {
  829. type: 'status',
  830. item: this.status.id
  831. }).then(res => {
  832. swal('Success', 'You have successfully deleted this post', 'success');
  833. setTimeout(function() {
  834. window.location.href = '/';
  835. }, 3000);
  836. }).catch(err => {
  837. swal('Error', 'Something went wrong. Please try again later.', 'error');
  838. });
  839. }
  840. },
  841. owner() {
  842. return this.user.id === this.status.account.id;
  843. },
  844. admin() {
  845. return this.user.is_admin == true;
  846. },
  847. ownerOrAdmin() {
  848. return this.owner() || this.admin();
  849. },
  850. lightbox(src) {
  851. this.lightboxMedia = src;
  852. this.$refs.lightboxModal.show();
  853. },
  854. postReply() {
  855. let self = this;
  856. if(this.replyText.length == 0 ||
  857. this.replyText.trim() == '@'+this.status.account.acct) {
  858. self.replyText = null;
  859. $('textarea[name="comment"]').blur();
  860. return;
  861. }
  862. let data = {
  863. item: this.replyingToId,
  864. comment: this.replyText
  865. }
  866. this.replyText = '';
  867. axios.post('/i/comment', data)
  868. .then(function(res) {
  869. let entity = res.data.entity;
  870. if(entity.in_reply_to_id == self.status.id) {
  871. if(self.layout == 'metro') {
  872. self.results.push(entity);
  873. } else {
  874. self.results.unshift(entity);
  875. }
  876. let elem = $('.status-comments')[0];
  877. elem.scrollTop = elem.clientHeight;
  878. } else {
  879. if(self.replyToIndex >= 0) {
  880. let el = self.results[self.replyToIndex];
  881. el.replies.push(entity);
  882. el.reply_count = el.reply_count + 1;
  883. }
  884. }
  885. });
  886. },
  887. deleteComment(id, i) {
  888. axios.post('/i/delete', {
  889. type: 'comment',
  890. item: id
  891. }).then(res => {
  892. this.results.splice(i, 1);
  893. }).catch(err => {
  894. swal('Something went wrong!', 'Please try again later', 'error');
  895. });
  896. },
  897. deleteCommentReply(id, i, pi) {
  898. axios.post('/i/delete', {
  899. type: 'comment',
  900. item: id
  901. }).then(res => {
  902. this.results[pi].replies.splice(i, 1);
  903. --this.results[pi].reply_count;
  904. }).catch(err => {
  905. swal('Something went wrong!', 'Please try again later', 'error');
  906. });
  907. },
  908. l(e) {
  909. let len = e.length;
  910. if(len < 10) { return e; }
  911. return e.substr(0, 10)+'...';
  912. },
  913. replyFocus(e, index) {
  914. this.replyToIndex = index;
  915. this.replyingToId = e.id;
  916. this.reply_to_profile_id = e.account.id;
  917. this.replyText = '@' + e.account.username + ' ';
  918. $('textarea[name="comment"]').focus();
  919. },
  920. fetchComments() {
  921. let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
  922. axios.get(url)
  923. .then(response => {
  924. let self = this;
  925. this.results = this.layout == 'metro' ?
  926. _.reverse(response.data.data) :
  927. response.data.data;
  928. this.pagination = response.data.meta.pagination;
  929. if(this.results.length > 0) {
  930. $('.load-more-link').removeClass('d-none');
  931. }
  932. $('.postCommentsLoader').addClass('d-none');
  933. $('.postCommentsContainer').removeClass('d-none');
  934. }).catch(error => {
  935. if(!error.response) {
  936. $('.postCommentsLoader .lds-ring')
  937. .attr('style','width:100%')
  938. .addClass('pt-4 font-weight-bold text-muted')
  939. .text('An error occurred, cannot fetch comments. Please try again later.');
  940. } else {
  941. switch(error.response.status) {
  942. case 401:
  943. $('.postCommentsLoader .lds-ring')
  944. .attr('style','width:100%')
  945. .addClass('pt-4 font-weight-bold text-muted')
  946. .text('Please login to view.');
  947. break;
  948. default:
  949. $('.postCommentsLoader .lds-ring')
  950. .attr('style','width:100%')
  951. .addClass('pt-4 font-weight-bold text-muted')
  952. .text('An error occurred, cannot fetch comments. Please try again later.');
  953. break;
  954. }
  955. }
  956. });
  957. },
  958. loadMore(e) {
  959. e.preventDefault();
  960. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  961. $('.load-more-link').addClass('d-none');
  962. return;
  963. }
  964. $('.postCommentsLoader').removeClass('d-none');
  965. let next = this.pagination.links.next;
  966. axios.get(next)
  967. .then(response => {
  968. let self = this;
  969. let res = response.data.data;
  970. $('.postCommentsLoader').addClass('d-none');
  971. for(let i=0; i < res.length; i++) {
  972. this.results.unshift(res[i]);
  973. }
  974. this.pagination = response.data.meta.pagination;
  975. });
  976. },
  977. likeReply(status, $event) {
  978. if($('body').hasClass('loggedIn') == false) {
  979. return;
  980. }
  981. axios.post('/i/like', {
  982. item: status.id
  983. }).then(res => {
  984. status.favourites_count = res.data.count;
  985. if(status.favourited == true) {
  986. status.favourited = false;
  987. } else {
  988. status.favourited = true;
  989. }
  990. }).catch(err => {
  991. swal('Error', 'Something went wrong, please try again later.', 'error');
  992. });
  993. },
  994. truncate(str,lim) {
  995. return _.truncate(str,{
  996. length: lim
  997. });
  998. },
  999. timeAgo(ts) {
  1000. let date = Date.parse(ts);
  1001. let seconds = Math.floor((new Date() - date) / 1000);
  1002. let interval = Math.floor(seconds / 31536000);
  1003. if (interval >= 1) {
  1004. return interval + "y";
  1005. }
  1006. interval = Math.floor(seconds / 604800);
  1007. if (interval >= 1) {
  1008. return interval + "w";
  1009. }
  1010. interval = Math.floor(seconds / 86400);
  1011. if (interval >= 1) {
  1012. return interval + "d";
  1013. }
  1014. interval = Math.floor(seconds / 3600);
  1015. if (interval >= 1) {
  1016. return interval + "h";
  1017. }
  1018. interval = Math.floor(seconds / 60);
  1019. if (interval >= 1) {
  1020. return interval + "m";
  1021. }
  1022. return Math.floor(seconds) + "s";
  1023. },
  1024. emojiReaction() {
  1025. let em = event.target.innerText;
  1026. if(this.replyText.length == 0) {
  1027. this.reply_to_profile_id = this.status.account.id;
  1028. this.replyText = em + ' ';
  1029. $('textarea[name="comment"]').focus();
  1030. } else {
  1031. this.reply_to_profile_id = this.status.account.id;
  1032. this.replyText += em + ' ';
  1033. $('textarea[name="comment"]').focus();
  1034. }
  1035. },
  1036. toggleCommentVisibility() {
  1037. if(this.ownerOrAdmin() == false) {
  1038. return;
  1039. }
  1040. let state = this.status.comments_disabled;
  1041. let self = this;
  1042. if(state == true) {
  1043. // re-enable comments
  1044. axios.post('/i/visibility', {
  1045. item: self.status.id,
  1046. disableComments: false
  1047. }).then(function(res) {
  1048. window.location.href = self.status.url;
  1049. }).catch(function(err) {
  1050. return;
  1051. });
  1052. } else {
  1053. // disable comments
  1054. axios.post('/i/visibility', {
  1055. item: self.status.id,
  1056. disableComments: true
  1057. }).then(function(res) {
  1058. self.status.comments_disabled = false;
  1059. self.showComments = false;
  1060. }).catch(function(err) {
  1061. return;
  1062. });
  1063. }
  1064. },
  1065. fetchRelationships() {
  1066. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1067. this.fetchData();
  1068. return;
  1069. } else {
  1070. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1071. params: {
  1072. 'id[]': this.statusProfileId
  1073. }
  1074. }).then(res => {
  1075. if(res.data[0] == null) {
  1076. this.fetchData();
  1077. return;
  1078. }
  1079. this.relationship = res.data[0];
  1080. if(res.data[0].blocking == true) {
  1081. this.loaded = true;
  1082. this.warning = true;
  1083. return;
  1084. } else {
  1085. this.fetchData();
  1086. return;
  1087. }
  1088. });
  1089. }
  1090. },
  1091. visibilityModal() {
  1092. switch(this.status.visibility) {
  1093. case 'public':
  1094. swal('Public Post', 'This post is visible to everyone.', 'info');
  1095. break;
  1096. case 'unlisted':
  1097. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1098. break;
  1099. case 'private':
  1100. swal('Private Post', 'This post is only visible to followers.', 'info');
  1101. break;
  1102. }
  1103. },
  1104. toggleReplies(reply) {
  1105. if(reply.thread) {
  1106. reply.thread = false;
  1107. } else {
  1108. if(reply.replies.length > 0) {
  1109. reply.thread = true;
  1110. return;
  1111. }
  1112. let url = '/api/v2/comments/'+reply.account.username+'/status/'+reply.id;
  1113. axios.get(url)
  1114. .then(response => {
  1115. reply.replies = _.reverse(response.data.data);
  1116. reply.thread = true;
  1117. });
  1118. }
  1119. },
  1120. redirect(url) {
  1121. window.location.href = url;
  1122. },
  1123. showEmbedPostModal() {
  1124. this.ctxEmbedPayload = window.App.util.embed.post(this.status.url)
  1125. this.$refs.embedModal.show();
  1126. },
  1127. ctxCopyEmbed() {
  1128. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1129. this.$refs.embedModal.hide();
  1130. },
  1131. },
  1132. }
  1133. </script>