PostComponent.vue 48 KB

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