PostComponent.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  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="profileLayout == '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. <div v-if="!owner()">
  38. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  39. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile()">Mute Profile</a>
  40. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile()">Block Profile</a>
  41. </div>
  42. <div v-if="ownerOrAdmin()">
  43. <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
  44. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  45. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="col-12 col-md-8 px-0 mx-0">
  53. <div class="postPresenterContainer d-none d-flex justify-content-center align-items-center" v-on:dblclick="likeStatus">
  54. <div v-if="status.pf_type === 'photo'" class="w-100">
  55. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  56. </div>
  57. <div v-else-if="status.pf_type === 'video'" class="w-100">
  58. <video-presenter :status="status"></video-presenter>
  59. </div>
  60. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  61. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  62. </div>
  63. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  64. <video-album-presenter :status="status"></video-album-presenter>
  65. </div>
  66. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  67. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  68. </div>
  69. <div v-else class="w-100">
  70. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="col-12 col-md-4 px-0 d-flex flex-column border-left border-md-left-0">
  75. <div class="d-md-flex d-none align-items-center justify-content-between card-header py-3 bg-white">
  76. <div class="d-flex align-items-center status-username text-truncate" data-toggle="tooltip" data-placement="bottom" :title="statusUsername">
  77. <div class="status-avatar mr-2" @click="redirect(statusProfileUrl)">
  78. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;" class="cursor-pointer">
  79. </div>
  80. <div class="username">
  81. <span class="username-link font-weight-bold text-dark cursor-pointer" @click="redirect(statusProfileUrl)">{{ statusUsername }}</span>
  82. <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;">
  83. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  84. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  85. </span>
  86. <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>
  87. </div>
  88. </div>
  89. <div class="float-right">
  90. <div class="post-actions">
  91. <div v-if="user != false" class="dropdown">
  92. <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">
  93. <span class="fas fa-ellipsis-v text-muted"></span>
  94. </button>
  95. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  96. <span v-if="!owner()">
  97. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  98. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile">Mute Profile</a>
  99. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile">Block Profile</a>
  100. </span>
  101. <span v-if="ownerOrAdmin()">
  102. <a class="dropdown-item font-weight-bold" href="#" v-on:click.prevent="toggleCommentVisibility">{{ showComments ? 'Disable' : 'Enable'}} Comments</a>
  103. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  104. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
  105. </span>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <div class="d-flex flex-md-column flex-column-reverse h-100" style="overflow-y: auto;">
  112. <div class="card-body status-comments pb-5">
  113. <div class="status-comment">
  114. <p :class="[status.content.length > 620 ? 'mb-1 read-more' : 'mb-1']" style="overflow: hidden;">
  115. <a class="font-weight-bold pr-1 text-dark text-decoration-none" :href="statusProfileUrl">{{statusUsername}}</a>
  116. <span class="comment-text" :id="status.id + '-status-readmore'" v-html="status.content"></span>
  117. </p>
  118. <div v-if="showComments">
  119. <hr>
  120. <div class="postCommentsLoader text-center">
  121. <div class="spinner-border" role="status">
  122. <span class="sr-only">Loading...</span>
  123. </div>
  124. </div>
  125. <div class="postCommentsContainer d-none">
  126. <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>
  127. <div class="comments">
  128. <div v-for="(reply, index) in results" class="pb-3" :key="'tl' + reply.id + '_' + index">
  129. <div v-if="reply.sensitive == true">
  130. <span class="py-3">
  131. <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>
  132. <span class="text-break">
  133. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  134. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  135. </span>
  136. </span>
  137. </div>
  138. <div v-else>
  139. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  140. <span>
  141. <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>
  142. <span class="text-break" v-html="reply.content"></span>
  143. </span>
  144. <span class="pl-2" style="min-width:38px">
  145. <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>
  146. <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>
  147. </span>
  148. </p>
  149. <p class="">
  150. <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>
  151. <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>
  152. <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index)">Reply</span>
  153. </p>
  154. <div v-if="reply.reply_count > 0" class="cursor-pointer" style="margin-left:30px;" v-on:click="toggleReplies(reply)">
  155. <span class="show-reply-bar"></span>
  156. <span class="comment-reaction font-weight-bold text-muted">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
  157. </div>
  158. <div v-if="reply.thread == true" class="comment-thread">
  159. <div v-for="(s, sindex) in reply.replies" class="pb-3" :key="'cr' + s.id + '_' + index">
  160. <p class="d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;">
  161. <span>
  162. <a class="text-dark font-weight-bold mr-1" :href="s.account.url" :title="s.account.username">{{s.account.username}}</a>
  163. <span class="text-break" v-html="s.content"></span>
  164. </span>
  165. <span class="pl-2" style="min-width:38px">
  166. <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>
  167. <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>
  168. </span>
  169. </p>
  170. <p class="">
  171. <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>
  172. <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>
  173. </p>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. <div class="card-body flex-grow-0 py-1">
  184. <div class="reactions my-1">
  185. <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>
  186. <h3 v-if="!status.comments_disabled" class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="replyFocus(status)"></h3>
  187. <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>
  188. <h3 @click="lightbox(status.media_attachments[0])" class="fas fa-expand m-0 cursor-pointer"></h3>
  189. <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>
  190. </div>
  191. <div class="reaction-counts font-weight-bold mb-0">
  192. <span style="cursor:pointer;" v-on:click="likesModal">
  193. <span class="like-count">{{status.favourites_count || 0}}</span> likes
  194. </span>
  195. <span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
  196. <span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
  197. </span>
  198. </div>
  199. <div class="timestamp pt-2 d-flex align-items-bottom justify-content-between">
  200. <a v-bind:href="statusUrl" class="small text-muted">
  201. {{timestampFormat()}}
  202. </a>
  203. <span class="small text-muted text-capitalize cursor-pointer" v-on:click="visibilityModal">{{status.visibility}}</span>
  204. </div>
  205. </div>
  206. </div>
  207. <div v-if="showComments && user.length !== 0" class="card-footer bg-white px-2 py-0">
  208. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  209. <li class="nav-item" v-on:click="emojiReaction">😂</li>
  210. <li class="nav-item" v-on:click="emojiReaction">💯</li>
  211. <li class="nav-item" v-on:click="emojiReaction">❤️</li>
  212. <li class="nav-item" v-on:click="emojiReaction">🙌</li>
  213. <li class="nav-item" v-on:click="emojiReaction">👏</li>
  214. <li class="nav-item" v-on:click="emojiReaction">👌</li>
  215. <li class="nav-item" v-on:click="emojiReaction">😍</li>
  216. <li class="nav-item" v-on:click="emojiReaction">😯</li>
  217. <li class="nav-item" v-on:click="emojiReaction">😢</li>
  218. <li class="nav-item" v-on:click="emojiReaction">😅</li>
  219. <li class="nav-item" v-on:click="emojiReaction">😁</li>
  220. <li class="nav-item" v-on:click="emojiReaction">🙂</li>
  221. <li class="nav-item" v-on:click="emojiReaction">😎</li>
  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"/>
  232. </form>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <div v-if="profileLayout == '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" 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 < 2"
  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. </div>
  467. </template>
  468. <style type="text/css" scoped>
  469. .status-comments,
  470. .reactions {
  471. background: #fff;
  472. }
  473. .postPresenterContainer {
  474. background: #fff;
  475. }
  476. @media(min-width: 720px) {
  477. .postPresenterContainer {
  478. min-height: 600px;
  479. }
  480. }
  481. ::-webkit-scrollbar {
  482. width: 0px;
  483. background: transparent;
  484. }
  485. .reply-btn {
  486. position: absolute;
  487. bottom: 12px;
  488. right: 20px;
  489. width: 60px;
  490. text-align: center;
  491. border-radius: 0 3px 3px 0;
  492. }
  493. .text-lighter {
  494. color:#B8C2CC !important;
  495. }
  496. .text-break {
  497. overflow-wrap: break-word;
  498. }
  499. .comments p {
  500. margin-bottom: 0;
  501. }
  502. .comment-reaction {
  503. font-size: 80%;
  504. }
  505. .show-reply-bar {
  506. display: inline-block;
  507. border-bottom: 1px solid #999;
  508. height: 0;
  509. margin-right: 16px;
  510. vertical-align: middle;
  511. width: 24px;
  512. }
  513. .comment-thread {
  514. margin: 4px 0 0 40px;
  515. width: calc(100% - 40px);
  516. }
  517. .emoji-reactions .nav-item {
  518. font-size: 1.2rem;
  519. padding: 9px;
  520. cursor: pointer;
  521. }
  522. .emoji-reactions::-webkit-scrollbar {
  523. width: 0px;
  524. height: 0px;
  525. background: transparent;
  526. }
  527. </style>
  528. <style type="text/css" scoped>
  529. .momentui .bg-dark {
  530. background: #000 !important;
  531. }
  532. .momentui .carousel.slide,
  533. .momentui .carousel-item {
  534. background: #000 !important;
  535. }
  536. </style>
  537. <script>
  538. pixelfed.postComponent = {};
  539. export default {
  540. props: [
  541. 'status-id',
  542. 'status-username',
  543. 'status-template',
  544. 'status-url',
  545. 'status-profile-url',
  546. 'status-avatar',
  547. 'status-profile-id',
  548. 'profile-layout'
  549. ],
  550. data() {
  551. return {
  552. config: window.App.config,
  553. status: false,
  554. media: {},
  555. user: false,
  556. reactions: {
  557. liked: false,
  558. shared: false
  559. },
  560. likes: [],
  561. likesPage: 1,
  562. shares: [],
  563. sharesPage: 1,
  564. lightboxMedia: false,
  565. replyText: '',
  566. relationship: {},
  567. results: [],
  568. pagination: {},
  569. min_id: 0,
  570. max_id: 0,
  571. reply_to_profile_id: 0,
  572. thread: false,
  573. showComments: false,
  574. warning: false,
  575. loaded: false,
  576. loading: null,
  577. replyingToId: this.statusId,
  578. replyToIndex: 0,
  579. emoji: ['😀','🤣','😃','😄','😆','😉','😊','😋','😘','😗','😙','😚','🤗','🤩','🤔','🤨','😐','😑','😶','🙄','😏','😣','😥','😮','🤐','😪','😫','😴','😌','😛','😜','😝','🤤','😒','😓','😔','😕','🙃','🤑','😲','🙁','😖','😞','😟','😤','😭','😦','😧','😨','😩','🤯','😬','😰','😱','😳','🤪','😵','😡','😠','🤬','😷','🤒','🤕','🤢','🤮','🤧','😇','🤠','🤡','🤥','🤫','🤭','🧐','🤓','😈','👿','👹','👺','💀','👻','👽','🤖','💩','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🤲','👐','🤝','👍','👎','👊','✊','🤛','🤜','🤞','✌️','🤟','🤘','👈','👉','👆','👇','☝️','✋','🤚','🖐','🖖','👋','🤙','💪','🖕','✍️','🙏','💍','💄','💋','👄','👅','👂','👃','👣','👁','👀','🧠','🗣','👤','👥'],
  580. showReadMore: true,
  581. }
  582. },
  583. beforeMount() {
  584. let u = new URLSearchParams(window.location.search);
  585. if(u.has('ui') && u.get('ui') == 'moment' && this.profileLayout != 'moment') {
  586. this.profileLayout = 'moment';
  587. }
  588. if(u.has('ui') && u.get('ui') == 'metro' && this.profileLayout != 'metro') {
  589. this.profileLayout = 'metro';
  590. }
  591. },
  592. mounted() {
  593. this.fetchRelationships();
  594. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  595. this.showReadMore = false;
  596. } else {
  597. this.showReadMore = true;
  598. }
  599. },
  600. updated() {
  601. $('.carousel').carousel();
  602. if(this.showReadMore == true) {
  603. window.pixelfed.readmore();
  604. }
  605. },
  606. methods: {
  607. showMuteBlock() {
  608. let sid = this.status.account.id;
  609. let uid = this.user.id;
  610. if(sid == uid) {
  611. $('.post-actions .menu-author').removeClass('d-none');
  612. } else {
  613. $('.post-actions .menu-user').removeClass('d-none');
  614. }
  615. },
  616. reportUrl() {
  617. return '/i/report?type=post&id=' + this.status.id;
  618. },
  619. editUrl() {
  620. return this.status.url + '/edit';
  621. },
  622. timestampFormat() {
  623. let ts = new Date(this.status.created_at);
  624. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  625. },
  626. fetchData() {
  627. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  628. .then(response => {
  629. let self = this;
  630. self.status = response.data.status;
  631. self.user = response.data.user;
  632. self.media = self.status.media_attachments;
  633. self.reactions = response.data.reactions;
  634. self.likes = response.data.likes;
  635. self.shares = response.data.shares;
  636. self.likesPage = 2;
  637. self.sharesPage = 2;
  638. this.showMuteBlock();
  639. if(self.status.comments_disabled == false) {
  640. self.showComments = true;
  641. this.fetchComments();
  642. }
  643. this.loaded = true;
  644. $('head title').text(this.status.account.username + ' posted a photo: ' + this.status.favourites_count + ' likes');
  645. }).catch(error => {
  646. if(!error.response) {
  647. } else {
  648. switch(error.response.status) {
  649. case 401:
  650. break;
  651. default:
  652. break;
  653. }
  654. }
  655. });
  656. },
  657. likesModal() {
  658. if(this.status.favourites_count == 0 || $('body').hasClass('loggedIn') == false) {
  659. return;
  660. }
  661. this.$refs.likesModal.show();
  662. },
  663. sharesModal() {
  664. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  665. return;
  666. }
  667. this.$refs.sharesModal.show();
  668. },
  669. infiniteLikesHandler($state) {
  670. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  671. axios.get(api, {
  672. params: {
  673. page: this.likesPage,
  674. },
  675. }).then(({ data }) => {
  676. if (data.data.length > 0) {
  677. this.likes.push(...data.data);
  678. this.likesPage++;
  679. $state.loaded();
  680. } else {
  681. $state.complete();
  682. }
  683. });
  684. },
  685. infiniteSharesHandler($state) {
  686. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  687. params: {
  688. page: this.sharesPage,
  689. },
  690. }).then(({ data }) => {
  691. if (data.data.length > 0) {
  692. this.shares.push(...data.data);
  693. this.sharesPage++;
  694. $state.loaded();
  695. } else {
  696. $state.complete();
  697. }
  698. });
  699. },
  700. likeStatus(event) {
  701. if($('body').hasClass('loggedIn') == false) {
  702. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  703. return;
  704. }
  705. axios.post('/i/like', {
  706. item: this.status.id
  707. }).then(res => {
  708. this.status.favourites_count = res.data.count;
  709. if(this.reactions.liked == true) {
  710. this.reactions.liked = false;
  711. let user = this.user.id;
  712. this.likes = this.likes.filter(function(like) {
  713. return like.id !== user;
  714. });
  715. } else {
  716. this.reactions.liked = true;
  717. let user = this.user;
  718. this.likes.push(user);
  719. }
  720. }).catch(err => {
  721. console.error(err);
  722. swal('Error', 'Something went wrong, please try again later.', 'error');
  723. });
  724. },
  725. shareStatus() {
  726. if($('body').hasClass('loggedIn') == false) {
  727. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  728. return;
  729. }
  730. axios.post('/i/share', {
  731. item: this.status.id
  732. }).then(res => {
  733. this.status.reblogs_count = res.data.count;
  734. if(this.reactions.shared == true) {
  735. this.reactions.shared = false;
  736. let user = this.user.id;
  737. this.shares = this.shares.filter(function(reaction) {
  738. return reaction.id !== user;
  739. });
  740. } else {
  741. this.reactions.shared = true;
  742. let user = this.user;
  743. this.shares.push(user);
  744. }
  745. }).catch(err => {
  746. console.error(err);
  747. swal('Error', 'Something went wrong, please try again later.', 'error');
  748. });
  749. },
  750. bookmarkStatus() {
  751. if($('body').hasClass('loggedIn') == false) {
  752. window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname);
  753. return;
  754. }
  755. axios.post('/i/bookmark', {
  756. item: this.status.id
  757. }).then(res => {
  758. if(this.reactions.bookmarked == true) {
  759. this.reactions.bookmarked = false;
  760. } else {
  761. this.reactions.bookmarked = true;
  762. }
  763. }).catch(err => {
  764. swal('Error', 'Something went wrong, please try again later.', 'error');
  765. });
  766. },
  767. muteProfile() {
  768. if($('body').hasClass('loggedIn') == false) {
  769. return;
  770. }
  771. axios.post('/i/mute', {
  772. type: 'user',
  773. item: this.status.account.id
  774. }).then(res => {
  775. swal('Success', 'You have successfully muted ' + this.status.account.acct, 'success');
  776. }).catch(err => {
  777. swal('Error', 'Something went wrong. Please try again later.', 'error');
  778. });
  779. },
  780. blockProfile() {
  781. if($('body').hasClass('loggedIn') == false) {
  782. return;
  783. }
  784. axios.post('/i/block', {
  785. type: 'user',
  786. item: this.status.account.id
  787. }).then(res => {
  788. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  789. }).catch(err => {
  790. swal('Error', 'Something went wrong. Please try again later.', 'error');
  791. });
  792. },
  793. deletePost(status) {
  794. if(!this.ownerOrAdmin()) {
  795. return;
  796. }
  797. var result = confirm('Are you sure you want to delete this post?');
  798. if (result) {
  799. if($('body').hasClass('loggedIn') == false) {
  800. return;
  801. }
  802. axios.post('/i/delete', {
  803. type: 'status',
  804. item: this.status.id
  805. }).then(res => {
  806. swal('Success', 'You have successfully deleted this post', 'success');
  807. setTimeout(function() {
  808. window.location.href = '/';
  809. }, 3000);
  810. }).catch(err => {
  811. swal('Error', 'Something went wrong. Please try again later.', 'error');
  812. });
  813. }
  814. },
  815. owner() {
  816. return this.user.id === this.status.account.id;
  817. },
  818. admin() {
  819. return this.user.is_admin == true;
  820. },
  821. ownerOrAdmin() {
  822. return this.owner() || this.admin();
  823. },
  824. lightbox(src) {
  825. this.lightboxMedia = src;
  826. this.$refs.lightboxModal.show();
  827. },
  828. postReply() {
  829. let self = this;
  830. if(this.replyText.length == 0 ||
  831. this.replyText.trim() == '@'+this.status.account.acct) {
  832. self.replyText = null;
  833. $('textarea[name="comment"]').blur();
  834. return;
  835. }
  836. let data = {
  837. item: this.replyingToId,
  838. comment: this.replyText
  839. }
  840. this.replyText = '';
  841. axios.post('/i/comment', data)
  842. .then(function(res) {
  843. let entity = res.data.entity;
  844. if(entity.in_reply_to_id == self.status.id) {
  845. if(self.profileLayout == 'metro') {
  846. self.results.push(entity);
  847. } else {
  848. self.results.unshift(entity);
  849. }
  850. let elem = $('.status-comments')[0];
  851. elem.scrollTop = elem.clientHeight;
  852. } else {
  853. if(self.replyToIndex >= 0) {
  854. let el = self.results[self.replyToIndex];
  855. el.replies.push(entity);
  856. el.reply_count = el.reply_count + 1;
  857. }
  858. }
  859. });
  860. },
  861. deleteComment(id, i) {
  862. axios.post('/i/delete', {
  863. type: 'comment',
  864. item: id
  865. }).then(res => {
  866. this.results.splice(i, 1);
  867. }).catch(err => {
  868. swal('Something went wrong!', 'Please try again later', 'error');
  869. });
  870. },
  871. deleteCommentReply(id, i, pi) {
  872. axios.post('/i/delete', {
  873. type: 'comment',
  874. item: id
  875. }).then(res => {
  876. this.results[pi].replies.splice(i, 1);
  877. --this.results[pi].reply_count;
  878. }).catch(err => {
  879. swal('Something went wrong!', 'Please try again later', 'error');
  880. });
  881. },
  882. l(e) {
  883. let len = e.length;
  884. if(len < 10) { return e; }
  885. return e.substr(0, 10)+'...';
  886. },
  887. replyFocus(e, index) {
  888. this.replyToIndex = index;
  889. this.replyingToId = e.id;
  890. this.reply_to_profile_id = e.account.id;
  891. this.replyText = '@' + e.account.username + ' ';
  892. $('textarea[name="comment"]').focus();
  893. },
  894. fetchComments() {
  895. let url = '/api/v2/comments/'+this.statusUsername+'/status/'+this.statusId;
  896. axios.get(url)
  897. .then(response => {
  898. let self = this;
  899. this.results = this.profileLayout == 'metro' ?
  900. _.reverse(response.data.data) :
  901. response.data.data;
  902. this.pagination = response.data.meta.pagination;
  903. if(this.results.length > 0) {
  904. $('.load-more-link').removeClass('d-none');
  905. }
  906. $('.postCommentsLoader').addClass('d-none');
  907. $('.postCommentsContainer').removeClass('d-none');
  908. }).catch(error => {
  909. if(!error.response) {
  910. $('.postCommentsLoader .lds-ring')
  911. .attr('style','width:100%')
  912. .addClass('pt-4 font-weight-bold text-muted')
  913. .text('An error occurred, cannot fetch comments. Please try again later.');
  914. } else {
  915. switch(error.response.status) {
  916. case 401:
  917. $('.postCommentsLoader .lds-ring')
  918. .attr('style','width:100%')
  919. .addClass('pt-4 font-weight-bold text-muted')
  920. .text('Please login to view.');
  921. break;
  922. default:
  923. $('.postCommentsLoader .lds-ring')
  924. .attr('style','width:100%')
  925. .addClass('pt-4 font-weight-bold text-muted')
  926. .text('An error occurred, cannot fetch comments. Please try again later.');
  927. break;
  928. }
  929. }
  930. });
  931. },
  932. loadMore(e) {
  933. e.preventDefault();
  934. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  935. $('.load-more-link').addClass('d-none');
  936. return;
  937. }
  938. $('.postCommentsLoader').removeClass('d-none');
  939. let next = this.pagination.links.next;
  940. axios.get(next)
  941. .then(response => {
  942. let self = this;
  943. let res = response.data.data;
  944. $('.postCommentsLoader').addClass('d-none');
  945. for(let i=0; i < res.length; i++) {
  946. this.results.unshift(res[i]);
  947. }
  948. this.pagination = response.data.meta.pagination;
  949. });
  950. },
  951. likeReply(status, $event) {
  952. if($('body').hasClass('loggedIn') == false) {
  953. return;
  954. }
  955. axios.post('/i/like', {
  956. item: status.id
  957. }).then(res => {
  958. status.favourites_count = res.data.count;
  959. if(status.favourited == true) {
  960. status.favourited = false;
  961. } else {
  962. status.favourited = true;
  963. }
  964. }).catch(err => {
  965. swal('Error', 'Something went wrong, please try again later.', 'error');
  966. });
  967. },
  968. truncate(str,lim) {
  969. return _.truncate(str,{
  970. length: lim
  971. });
  972. },
  973. timeAgo(ts) {
  974. let date = Date.parse(ts);
  975. let seconds = Math.floor((new Date() - date) / 1000);
  976. let interval = Math.floor(seconds / 31536000);
  977. if (interval >= 1) {
  978. return interval + "y";
  979. }
  980. interval = Math.floor(seconds / 604800);
  981. if (interval >= 1) {
  982. return interval + "w";
  983. }
  984. interval = Math.floor(seconds / 86400);
  985. if (interval >= 1) {
  986. return interval + "d";
  987. }
  988. interval = Math.floor(seconds / 3600);
  989. if (interval >= 1) {
  990. return interval + "h";
  991. }
  992. interval = Math.floor(seconds / 60);
  993. if (interval >= 1) {
  994. return interval + "m";
  995. }
  996. return Math.floor(seconds) + "s";
  997. },
  998. emojiReaction() {
  999. let em = event.target.innerText;
  1000. if(this.replyText.length == 0) {
  1001. this.reply_to_profile_id = this.status.account.id;
  1002. this.replyText = em + ' ';
  1003. $('textarea[name="comment"]').focus();
  1004. } else {
  1005. this.reply_to_profile_id = this.status.account.id;
  1006. this.replyText += em + ' ';
  1007. $('textarea[name="comment"]').focus();
  1008. }
  1009. },
  1010. toggleCommentVisibility() {
  1011. if(this.ownerOrAdmin() == false) {
  1012. return;
  1013. }
  1014. let state = this.status.comments_disabled;
  1015. let self = this;
  1016. if(state == true) {
  1017. // re-enable comments
  1018. axios.post('/i/visibility', {
  1019. item: self.status.id,
  1020. disableComments: false
  1021. }).then(function(res) {
  1022. window.location.href = self.status.url;
  1023. }).catch(function(err) {
  1024. return;
  1025. });
  1026. } else {
  1027. // disable comments
  1028. axios.post('/i/visibility', {
  1029. item: self.status.id,
  1030. disableComments: true
  1031. }).then(function(res) {
  1032. self.status.comments_disabled = false;
  1033. self.showComments = false;
  1034. }).catch(function(err) {
  1035. return;
  1036. });
  1037. }
  1038. },
  1039. fetchRelationships() {
  1040. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  1041. this.fetchData();
  1042. return;
  1043. } else {
  1044. axios.get('/api/v1/accounts/relationships', {
  1045. params: {
  1046. 'id[]': this.statusProfileId
  1047. }
  1048. }).then(res => {
  1049. if(res.data[0] == null) {
  1050. this.fetchData();
  1051. return;
  1052. }
  1053. this.relationship = res.data[0];
  1054. if(res.data[0].blocking == true) {
  1055. this.loaded = true;
  1056. this.warning = true;
  1057. return;
  1058. } else {
  1059. this.fetchData();
  1060. return;
  1061. }
  1062. });
  1063. }
  1064. },
  1065. visibilityModal() {
  1066. switch(this.status.visibility) {
  1067. case 'public':
  1068. swal('Public Post', 'This post is visible to everyone.', 'info');
  1069. break;
  1070. case 'unlisted':
  1071. swal('Unlisted Post', 'This post is visible on profiles and with a direct links. It is not displayed on timelines.', 'info');
  1072. break;
  1073. case 'private':
  1074. swal('Private Post', 'This post is only visible to followers.', 'info');
  1075. break;
  1076. }
  1077. },
  1078. toggleReplies(reply) {
  1079. if(reply.thread) {
  1080. reply.thread = false;
  1081. } else {
  1082. if(reply.replies.length > 0) {
  1083. reply.thread = true;
  1084. return;
  1085. }
  1086. let url = '/api/v2/comments/'+reply.account.username+'/status/'+reply.id;
  1087. axios.get(url)
  1088. .then(response => {
  1089. reply.replies = _.reverse(response.data.data);
  1090. reply.thread = true;
  1091. });
  1092. }
  1093. },
  1094. redirect(url) {
  1095. window.location.href = url;
  1096. }
  1097. },
  1098. }
  1099. </script>