PostComponent.vue 24 KB

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