PostComponent.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <style>
  2. #l-modal .modal-body,
  3. #s-modal .modal-body {
  4. max-height: 70vh;
  5. overflow-y: scroll;
  6. }
  7. .status-comments,
  8. .reactions,
  9. .col-md-4 {
  10. background: #fff;
  11. }
  12. .postPresenterContainer {
  13. background: #000;
  14. min-height: 600px;
  15. }
  16. </style>
  17. <template>
  18. <div class="postComponent d-none">
  19. <div class="container px-0 mt-md-4">
  20. <div class="card card-md-rounded-0 status-container orientation-unknown">
  21. <div class="row px-0 mx-0">
  22. <div class="d-flex d-md-none align-items-center justify-content-between card-header bg-white w-100">
  23. <a :href="statusProfileUrl" class="d-flex align-items-center status-username text-truncate" data-toggle="tooltip" data-placement="bottom" :title="statusUsername">
  24. <div class="status-avatar mr-2">
  25. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;">
  26. </div>
  27. <div class="username">
  28. <span class="username-link font-weight-bold text-dark">{{ statusUsername }}</span>
  29. </div>
  30. </a>
  31. <div class="float-right">
  32. <div class="post-actions">
  33. <div class="dropdown">
  34. <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">
  35. <span class="fas fa-ellipsis-v text-muted"></span>
  36. </button>
  37. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  38. <span class="menu-user d-none">
  39. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  40. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile">Mute Profile</a>
  41. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile">Block Profile</a>
  42. </span>
  43. <span class="menu-author d-none">
  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">Delete</a>
  46. </span>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="col-12 col-md-8 status-photo px-0 mx-0">
  53. <div class="postPresenterLoader text-center">
  54. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  55. </div>
  56. <div class="postPresenterContainer d-none">
  57. </div>
  58. </div>
  59. <div class="col-12 col-md-4 px-0 d-flex flex-column border-left border-md-left-0">
  60. <div class="d-md-flex d-none align-items-center justify-content-between card-header py-3 bg-white">
  61. <a :href="statusProfileUrl" class="d-flex align-items-center status-username text-truncate" data-toggle="tooltip" data-placement="bottom" :title="statusUsername">
  62. <div class="status-avatar mr-2">
  63. <img :src="statusAvatar" width="24px" height="24px" style="border-radius:12px;">
  64. </div>
  65. <div class="username">
  66. <span class="username-link font-weight-bold text-dark">{{ statusUsername }}</span>
  67. </div>
  68. </a>
  69. <div class="float-right">
  70. <div class="post-actions">
  71. <div class="dropdown">
  72. <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">
  73. <span class="fas fa-ellipsis-v text-muted"></span>
  74. </button>
  75. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
  76. <span class="menu-user d-none">
  77. <a class="dropdown-item font-weight-bold" :href="reportUrl()">Report</a>
  78. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile">Mute Profile</a>
  79. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile">Block Profile</a>
  80. </span>
  81. <span class="menu-author d-none">
  82. <a class="dropdown-item font-weight-bold" :href="editUrl()">Edit</a>
  83. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost">Delete</a>
  84. </span>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="d-flex flex-md-column flex-column-reverse h-100">
  91. <div class="card-body status-comments">
  92. <div class="status-comment">
  93. <p class="mb-1 read-more" style="overflow: hidden;">
  94. <span class="font-weight-bold pr-1">{{statusUsername}}</span>
  95. <span class="comment-text" :id="status.id + '-status-readmore'" v-html="status.content"></span>
  96. </p>
  97. <post-comments :user="this.user" :post-id="statusId" :post-username="statusUsername"></post-comments>
  98. </div>
  99. </div>
  100. <div class="card-body flex-grow-0 py-1">
  101. <div class="reactions my-1">
  102. <h3 v-bind:class="[reactions.liked ? 'fas fa-heart text-danger pr-3 m-0' : 'far fa-heart pr-3 m-0 like-btn']" title="Like" v-on:click="likeStatus"></h3>
  103. <h3 class="far fa-comment pr-3 m-0" title="Comment" v-on:click="commentFocus"></h3>
  104. <h3 v-bind:class="[reactions.shared ? 'far fa-share-square pr-3 m-0 text-primary' : 'far fa-share-square pr-3 m-0 share-btn']" title="Share" v-on:click="shareStatus"></h3>
  105. <h3 v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 float-right' : 'far fa-bookmark m-0 float-right']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
  106. </div>
  107. <div class="reaction-counts font-weight-bold mb-0">
  108. <span style="cursor:pointer;" v-on:click="likesModal">
  109. <span class="like-count">{{status.favourites_count || 0}}</span> likes
  110. </span>
  111. <span class="float-right" style="cursor:pointer;" v-on:click="sharesModal">
  112. <span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares
  113. </span>
  114. </div>
  115. <div class="timestamp">
  116. <a v-bind:href="statusUrl" class="small text-muted">
  117. {{timestampFormat()}}
  118. </a>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="card-footer bg-white sticky-md-bottom">
  123. <div class="comment-form-guest">
  124. <a href="/login">Login</a> to like or comment.
  125. </div>
  126. <form class="comment-form d-none" method="post" action="/i/comment" :data-id="statusId" data-truncate="false">
  127. <input type="hidden" name="_token" value="">
  128. <input type="hidden" name="item" :value="statusId">
  129. <input class="form-control" name="comment" placeholder="Add a comment..." autocomplete="off">
  130. </form>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <b-modal ref="likesModal"
  137. id="l-modal"
  138. hide-footer
  139. centered
  140. title="Likes"
  141. body-class="list-group-flush p-0">
  142. <div class="list-group">
  143. <div class="list-group-item border-0" v-for="user in likes">
  144. <div class="media">
  145. <a :href="user.url">
  146. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '\'s avatar'" width="30px">
  147. </a>
  148. <div class="media-body">
  149. <p class="mb-0" style="font-size: 14px">
  150. <a :href="user.url" class="font-weight-bold text-dark">
  151. {{user.username}}
  152. </a>
  153. </p>
  154. <p class="text-muted mb-0" style="font-size: 14px">
  155. {{user.display_name}}
  156. </a>
  157. </p>
  158. </div>
  159. </div>
  160. </div>
  161. <infinite-loading @infinite="infiniteLikesHandler" spinner="spiral">
  162. <div slot="no-more"></div>
  163. <div slot="no-results"></div>
  164. </infinite-loading>
  165. </div>
  166. </b-modal>
  167. <b-modal ref="sharesModal"
  168. id="s-modal"
  169. hide-footer
  170. centered
  171. title="Shares"
  172. body-class="list-group-flush p-0">
  173. <div class="list-group">
  174. <div class="list-group-item border-0" v-for="user in shares">
  175. <div class="media">
  176. <a :href="user.url">
  177. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '\'s avatar'" width="30px">
  178. </a>
  179. <div class="media-body">
  180. <p class="mb-0" style="font-size: 14px">
  181. <a :href="user.url" class="font-weight-bold text-dark">
  182. {{user.username}}
  183. </a>
  184. </p>
  185. <p class="text-muted mb-0" style="font-size: 14px">
  186. {{user.display_name}}
  187. </a>
  188. </p>
  189. </div>
  190. </div>
  191. </div>
  192. <infinite-loading @infinite="infiniteSharesHandler" spinner="spiral">
  193. <div slot="no-more"></div>
  194. <div slot="no-results"></div>
  195. </infinite-loading>
  196. </div>
  197. </b-modal>
  198. </div>
  199. </template>
  200. <script>
  201. pixelfed.postComponent = {};
  202. pixelfed.presenter = {
  203. show: {
  204. image: function(container, media, status) {
  205. $('.status-container')
  206. .removeClass('orientation-unknown')
  207. .addClass('orientation-' + media[0]['orientation']);
  208. let wrapper = $('<div>');
  209. container.addClass('d-flex align-items-center');
  210. if(media[0]['filter_class']) {
  211. wrapper.addClass(media[0]['filter_class']);
  212. }
  213. let el = $('<img>');
  214. el.attr('src', media[0]['url']);
  215. el.attr('title', media[0]['description']);
  216. wrapper.append(el);
  217. if(status.sensitive == true) {
  218. let spoilerText = status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media';
  219. let cw = $('<details>').addClass('details-animated w-100');
  220. let summary = $('<summary>');
  221. let text = $('<p>').addClass('mb-0 lead font-weight-bold').text(spoilerText);
  222. let direction = $('<p>').addClass('font-weight-light').text('(click to show)');
  223. summary.append(text, direction);
  224. cw.append(summary, wrapper);
  225. container.append(cw);
  226. } else {
  227. container.append(wrapper);
  228. }
  229. },
  230. video: function(container, media, status) {
  231. let wrapper = $('<div>');
  232. container.addClass('d-flex align-items-center');
  233. let el = $('<video>');
  234. el.addClass('embed-responsive-item');
  235. el.attr('controls', '');
  236. el.attr('loop', '');
  237. el.attr('src', media[0]['url']);
  238. el.attr('title', media[0]['description']);
  239. wrapper.append(el);
  240. if(status.sensitive == true) {
  241. let spoilerText = status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media';
  242. let cw = $('<details>').addClass('details-animated w-100');
  243. let summary = $('<summary>');
  244. let text = $('<p>').addClass('mb-0 lead font-weight-bold').text(spoilerText);
  245. let direction = $('<p>').addClass('font-weight-light').text('(click to show)');
  246. summary.append(text, direction);
  247. cw.append(summary, wrapper);
  248. container.append(cw);
  249. } else {
  250. container.append(wrapper);
  251. }
  252. const player = new Plyr(el, {
  253. controls: [
  254. 'restart', // Restart playback
  255. 'play', // Play/pause playback
  256. 'progress', // The progress bar and scrubber for playback and buffering
  257. 'current-time', // The current time of playback
  258. 'duration', // The full duration of the media
  259. 'volume', // Volume control
  260. 'captions', // Toggle captions
  261. 'settings', // Settings menu
  262. 'fullscreen', // Toggle fullscreen
  263. ]
  264. });
  265. player.volume = 0.75;
  266. },
  267. imageAlbum: function(container, media, status) {
  268. $('.status-container')
  269. .removeClass('orientation-unknown')
  270. .addClass('orientation-' + media[0]['orientation']);
  271. let id = 'photo-carousel-wrapper-' + status.id;
  272. let wrapper = $('<div>');
  273. container.addClass('d-flex align-items-center');
  274. wrapper.addClass('carousel slide carousel-fade');
  275. wrapper.attr('data-ride', 'carousel');
  276. wrapper.attr('id', id);
  277. let indicators = $('<ol>');
  278. indicators.addClass('carousel-indicators');
  279. let prev = $('<a>');
  280. prev.addClass('carousel-control-prev');
  281. prev.attr('href', '#' + id);
  282. prev.attr('role', 'button');
  283. prev.attr('data-slide', 'prev');
  284. let prevIcon = $('<span>').addClass('carousel-control-prev-icon').attr('aria-hidden', 'true');
  285. let prevSr = $('<span>').addClass('sr-only');
  286. prev.append(prevIcon, prevSr);
  287. let next = $('<a>');
  288. next.addClass('carousel-control-next');
  289. next.attr('href', '#' + id);
  290. next.attr('role', 'button');
  291. next.attr('data-slide', 'next');
  292. let nextIcon = $('<span>').addClass('carousel-control-next-icon').attr('aria-hidden', 'true');
  293. let nextSr = $('<span>').addClass('sr-only');
  294. let inner = $('<div>').addClass('carousel-inner');
  295. next.append(nextIcon, nextSr);
  296. for(let i = 0; i < media.length; i++) {
  297. let li = $('<li>');
  298. li.attr('data-target', '#' + id);
  299. li.attr('data-slide-to', i);
  300. if(i == 0) {
  301. li.addClass('active');
  302. }
  303. indicators.append(li);
  304. let item = media[i];
  305. let carouselItem = $('<div>').addClass('carousel-item');
  306. if(i == 0) {
  307. carouselItem.addClass('active');
  308. }
  309. let figure = $('<figure>');
  310. if(item['filter_class']) {
  311. figure.addClass(item['filter_class']);
  312. }
  313. let badge = $('<span>');
  314. badge.addClass('float-right mr-3 badge badge-dark');
  315. badge.style = 'position:fixed;top:8px;right:0;margin-bottom:-20px;';
  316. badge.text(i+1 + '/' + media.length);
  317. let img = $('<img>');
  318. img.addClass('d-block w-100');
  319. img.attr('src', item['url']);
  320. figure.append(badge, img);
  321. carouselItem.append(figure);
  322. inner.append(carouselItem);
  323. }
  324. wrapper.append(indicators, inner, prev, next);
  325. if(status.sensitive == true) {
  326. let spoilerText = status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media';
  327. let cw = $('<details>').addClass('details-animated w-100');
  328. let summary = $('<summary>');
  329. let text = $('<p>').addClass('mb-0 lead font-weight-bold').text(spoilerText);
  330. let direction = $('<p>').addClass('font-weight-light').text('(click to show)');
  331. summary.append(text, direction);
  332. cw.append(summary, wrapper);
  333. container.append(cw);
  334. } else {
  335. container.append(wrapper);
  336. }
  337. }
  338. }
  339. };
  340. export default {
  341. props: ['status-id', 'status-username', 'status-template', 'status-url', 'status-profile-url', 'status-avatar'],
  342. data() {
  343. return {
  344. status: {},
  345. media: {},
  346. user: {},
  347. reactions: {
  348. liked: false,
  349. shared: false
  350. },
  351. likes: {},
  352. likesPage: 1,
  353. shares: {},
  354. sharesPage: 1,
  355. }
  356. },
  357. mounted() {
  358. this.fetchData();
  359. this.authCheck();
  360. let token = $('meta[name="csrf-token"]').attr('content');
  361. $('input[name="_token"]').each(function(k, v) {
  362. let el = $(v);
  363. el.val(token);
  364. });
  365. },
  366. updated() {
  367. $('.carousel').carousel();
  368. if(this.reactions) {
  369. if(this.reactions.bookmarked == true) {
  370. $('.far.fa-bookmark').removeClass('far').addClass('fas text-warning');
  371. }
  372. if(this.reactions.shared == true) {
  373. $('.far.fa-share-square').addClass('text-primary');
  374. }
  375. if(this.reactions.liked == true) {
  376. $('.far.fa-heart ').removeClass('far text-dark').addClass('fas text-danger');
  377. }
  378. }
  379. if(this.status) {
  380. let title = this.status.account.username + ' posted a photo: ' + this.status.favourites_count + ' likes';
  381. $('head title').text(title);
  382. }
  383. },
  384. methods: {
  385. authCheck() {
  386. let authed = $('body').hasClass('loggedIn');
  387. if(authed == true) {
  388. $('.comment-form-guest').addClass('d-none');
  389. $('.comment-form').removeClass('d-none');
  390. }
  391. },
  392. showMuteBlock() {
  393. let sid = this.status.account.id;
  394. let uid = this.user.id;
  395. if(sid == uid) {
  396. $('.post-actions .menu-author').removeClass('d-none');
  397. } else {
  398. $('.post-actions .menu-user').removeClass('d-none');
  399. }
  400. },
  401. reportUrl() {
  402. return '/i/report?type=post&id=' + this.status.id;
  403. },
  404. editUrl() {
  405. return this.status.url + '/edit';
  406. },
  407. timestampFormat() {
  408. let ts = new Date(this.status.created_at);
  409. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  410. },
  411. fetchData() {
  412. let loader = this.$loading.show({
  413. 'opacity': 0,
  414. 'background-color': '#f5f8fa'
  415. });
  416. axios.get('/api/v2/profile/'+this.statusUsername+'/status/'+this.statusId)
  417. .then(response => {
  418. let self = this;
  419. self.status = response.data.status;
  420. self.user = response.data.user;
  421. self.media = self.status.media_attachments;
  422. self.reactions = response.data.reactions;
  423. self.likes = response.data.likes;
  424. self.shares = response.data.shares;
  425. self.likesPage = 2;
  426. self.sharesPage = 2;
  427. this.buildPresenter();
  428. this.showMuteBlock();
  429. loader.hide();
  430. $('.postComponent').removeClass('d-none');
  431. }).catch(error => {
  432. if(!error.response) {
  433. $('.postPresenterLoader .lds-ring').attr('style','width:100%').addClass('pt-4 font-weight-bold text-muted').text('An error occured, cannot fetch media. Please try again later.');
  434. } else {
  435. switch(error.response.status) {
  436. case 401:
  437. $('.postPresenterLoader .lds-ring')
  438. .attr('style','width:100%')
  439. .addClass('pt-4 font-weight-bold text-muted')
  440. .text('Please login to view.');
  441. break;
  442. default:
  443. $('.postPresenterLoader .lds-ring').attr('style','width:100%').addClass('pt-4 font-weight-bold text-muted').text('An error occured, cannot fetch media. Please try again later.');
  444. break;
  445. }
  446. }
  447. });
  448. },
  449. commentFocus() {
  450. $('.comment-form input[name="comment"]').focus();
  451. },
  452. likesModal() {
  453. if(this.status.favourites_count == 0 || $('body').hasClass('loggedIn') == false) {
  454. return;
  455. }
  456. this.$refs.likesModal.show();
  457. },
  458. sharesModal() {
  459. if(this.status.reblogs_count == 0 || $('body').hasClass('loggedIn') == false) {
  460. return;
  461. }
  462. this.$refs.sharesModal.show();
  463. },
  464. infiniteLikesHandler($state) {
  465. let api = '/api/v2/likes/profile/'+this.statusUsername+'/status/'+this.statusId;
  466. axios.get(api, {
  467. params: {
  468. page: this.likesPage,
  469. },
  470. }).then(({ data }) => {
  471. if (data.data.length) {
  472. this.likesPage += 1;
  473. this.likes.push(...data.data);
  474. $state.loaded();
  475. } else {
  476. $state.complete();
  477. }
  478. });
  479. },
  480. infiniteSharesHandler($state) {
  481. axios.get('/api/v2/shares/profile/'+this.statusUsername+'/status/'+this.statusId, {
  482. params: {
  483. page: this.sharesPage,
  484. },
  485. }).then(({ data }) => {
  486. if (data.data.length) {
  487. this.sharesPage += 1;
  488. this.shares.push(...data.data);
  489. $state.loaded();
  490. } else {
  491. $state.complete();
  492. }
  493. });
  494. },
  495. buildPresenter() {
  496. let container = $('.postPresenterContainer');
  497. let status = this.status;
  498. let media = this.media;
  499. $('input[name="item"]').each(function(k, v) {
  500. let el = $(v);
  501. el.val(status.account.id);
  502. });
  503. if(container.children().length != 0) {
  504. return;
  505. }
  506. let template = this.status.pf_type ? this.status.pf_type : this.statusTemplate;
  507. switch(template) {
  508. case 'image':
  509. case 'photo':
  510. pixelfed.presenter.show.image(container, media, this.status);
  511. break;
  512. case 'album':
  513. case 'photo:album':
  514. pixelfed.presenter.show.imageAlbum(container, media, this.status);
  515. break;
  516. case 'video':
  517. pixelfed.presenter.show.video(container, media, this.status);
  518. break;
  519. case 'video:album':
  520. case 'photo:video:album':
  521. $('.postPresenterLoader .lds-ring').attr('style','width:100%').addClass('pt-4 font-weight-bold text-muted').text('We cannot load this post properly. We\'re working on a fix!');
  522. return;
  523. break;
  524. default:
  525. $('.postPresenterLoader .lds-ring').attr('style','width:100%').addClass('pt-4 font-weight-bold text-muted').text('An error occured, cannot fetch media. Please try again later.');
  526. break;
  527. }
  528. if(container.children().length == 0) {
  529. $('.postPresenterLoader .lds-ring').attr('style','width:100%').addClass('pt-4 font-weight-bold text-muted').text('An error occured, cannot fetch media. Please try again later.');
  530. return;
  531. }
  532. pixelfed.readmore();
  533. $('.postPresenterLoader').addClass('d-none');
  534. $('.postPresenterContainer').removeClass('d-none');
  535. },
  536. likeStatus(event) {
  537. if($('body').hasClass('loggedIn') == false) {
  538. return;
  539. }
  540. axios.post('/i/like', {
  541. item: this.status.id
  542. }).then(res => {
  543. this.status.favourites_count = res.data.count;
  544. if(this.reactions.liked == true) {
  545. this.reactions.liked = false;
  546. } else {
  547. this.reactions.liked = true;
  548. }
  549. }).catch(err => {
  550. swal('Error', 'Something went wrong, please try again later.', 'error');
  551. });
  552. },
  553. shareStatus() {
  554. if($('body').hasClass('loggedIn') == false) {
  555. return;
  556. }
  557. axios.post('/i/share', {
  558. item: this.status.id
  559. }).then(res => {
  560. this.status.reblogs_count = res.data.count;
  561. if(this.reactions.shared == true) {
  562. this.reactions.shared = false;
  563. } else {
  564. this.reactions.shared = true;
  565. }
  566. }).catch(err => {
  567. swal('Error', 'Something went wrong, please try again later.', 'error');
  568. });
  569. },
  570. bookmarkStatus() {
  571. if($('body').hasClass('loggedIn') == false) {
  572. return;
  573. }
  574. axios.post('/i/bookmark', {
  575. item: this.status.id
  576. }).then(res => {
  577. if(this.reactions.bookmarked == true) {
  578. this.reactions.bookmarked = false;
  579. } else {
  580. this.reactions.bookmarked = true;
  581. }
  582. }).catch(err => {
  583. swal('Error', 'Something went wrong, please try again later.', 'error');
  584. });
  585. },
  586. muteProfile() {
  587. if($('body').hasClass('loggedIn') == false) {
  588. return;
  589. }
  590. axios.post('/i/mute', {
  591. type: 'user',
  592. item: this.status.account.id
  593. }).then(res => {
  594. swal('Success', 'You have successfully muted ' + this.status.account.acct, 'success');
  595. }).catch(err => {
  596. swal('Error', 'Something went wrong. Please try again later.', 'error');
  597. });
  598. },
  599. blockProfile() {
  600. if($('body').hasClass('loggedIn') == false) {
  601. return;
  602. }
  603. axios.post('/i/block', {
  604. type: 'user',
  605. item: this.status.account.id
  606. }).then(res => {
  607. swal('Success', 'You have successfully blocked ' + this.status.account.acct, 'success');
  608. }).catch(err => {
  609. swal('Error', 'Something went wrong. Please try again later.', 'error');
  610. });
  611. },
  612. deletePost() {
  613. if($('body').hasClass('loggedIn') == false) {
  614. return;
  615. }
  616. axios.post('/i/delete', {
  617. type: 'status',
  618. item: this.status.id
  619. }).then(res => {
  620. swal('Success', 'You have successfully deleted this post', 'success');
  621. }).catch(err => {
  622. swal('Error', 'Something went wrong. Please try again later.', 'error');
  623. });
  624. }
  625. }
  626. }
  627. </script>