PostComponent.vue 25 KB

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