StatusCard.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <template>
  2. <div>
  3. <div class="card rounded-0 border-top-0 status-card card-md-rounded-0 shadow-none border">
  4. <div v-if="status" class="card-header d-inline-flex align-items-center bg-white">
  5. <div>
  6. <img class="rounded-circle box-shadow" :src="status.account.avatar" width="32px" height="32px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=2'" alt="avatar">
  7. </div>
  8. <div class="pl-2">
  9. <a class="username font-weight-bold text-dark text-decoration-none text-break" v-bind:href="profileUrl(status)" v-html="statusCardUsernameFormat(status)">
  10. Loading...
  11. </a>
  12. <span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
  13. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  14. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  15. </span>
  16. <div class="d-flex align-items-center">
  17. <a v-if="status.place" class="small text-decoration-none text-muted" :href="'/discover/places/'+status.place.id+'/'+status.place.slug" title="Location" data-toggle="tooltip"><i class="fas fa-map-marked-alt"></i> {{status.place.name}}, {{status.place.country}}</a>
  18. </div>
  19. </div>
  20. <div class="text-right" style="flex-grow:1;">
  21. <button class="btn btn-link text-dark py-0" type="button" @click="ctxMenu()">
  22. <span class="fas fa-ellipsis-h text-lighter"></span>
  23. <span class="sr-only">Post Menu</span>
  24. </button>
  25. </div>
  26. </div>
  27. <div class="postPresenterContainer" style="background: #000;">
  28. <div v-if="config.ab.top && status.pf_type === 'text'" class="w-100">
  29. <div class="w-100 card-img-top border-bottom rounded-0" style="background-image: url(/storage/textimg/bg_1.jpg);background-size: cover;width: 100%;height: 540px;">
  30. <div class="w-100 h-100 d-flex justify-content-center align-items-center">
  31. <p class="text-center text-break h3 px-5 font-weight-bold" v-html="status.content"></p>
  32. </div>
  33. </div>
  34. </div>
  35. <div v-else-if="status.pf_type === 'photo'" class="w-100">
  36. <photo-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-presenter>
  37. </div>
  38. <div v-else-if="status.pf_type === 'video'" class="w-100">
  39. <video-presenter :status="status"></video-presenter>
  40. </div>
  41. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  42. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  43. </div>
  44. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  45. <video-album-presenter :status="status"></video-album-presenter>
  46. </div>
  47. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  48. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  49. </div>
  50. <div v-else class="w-100">
  51. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  52. </div>
  53. </div>
  54. <div v-if="config.features.label.covid.enabled && status.label && status.label.covid == true" class="card-body border-top border-bottom py-2 cursor-pointer pr-2" @click="labelRedirect()">
  55. <p class="font-weight-bold d-flex justify-content-between align-items-center mb-0">
  56. <span>
  57. <i class="fas fa-info-circle mr-2"></i>
  58. For information about COVID-19, {{config.features.label.covid.org}}
  59. </span>
  60. <span>
  61. <i class="fas fa-chevron-right text-lighter"></i>
  62. </span>
  63. </p>
  64. </div>
  65. <div class="card-body">
  66. <div class="reactions my-1 pb-2">
  67. <h3 v-if="status.favourited" class="fas fa-heart text-danger pr-3 m-0 cursor-pointer" title="Like" v-on:click="likeStatus(status, $event);"></h3>
  68. <h3 v-else class="far fa-heart pr-3 m-0 like-btn text-dark cursor-pointer" title="Like" v-on:click="likeStatus(status, $event);"></h3>
  69. <h3 v-if="!status.comments_disabled" class="far fa-comment text-dark pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
  70. <span v-if="status.taggedPeople.length" class="float-right">
  71. <span class="font-weight-light small" style="color:#718096">
  72. <i class="far fa-user" data-toggle="tooltip" title="Tagged People"></i>
  73. <span v-for="(tag, index) in status.taggedPeople" class="mr-n2">
  74. <a :href="'/'+tag.username">
  75. <img :src="tag.avatar" width="20px" height="20px" class="border rounded-circle" data-toggle="tooltip" :title="'@'+tag.username" alt="Avatar">
  76. </a>
  77. </span>
  78. </span>
  79. </span>
  80. </div>
  81. <div v-if="status.liked_by.username && status.liked_by.username !== profile.username" class="likes mb-1">
  82. <span class="like-count">Liked by
  83. <a class="font-weight-bold text-dark" :href="status.liked_by.url">{{status.liked_by.username}}</a>
  84. <span v-if="status.liked_by.others == true">
  85. and <span class="font-weight-bold" v-if="status.liked_by.total_count_pretty">{{status.liked_by.total_count_pretty}}</span> <span class="font-weight-bold">others</span>
  86. </span>
  87. </span>
  88. </div>
  89. <div v-if="status.pf_type != 'text'" class="caption">
  90. <p v-if="!status.sensitive" class="mb-2 read-more" style="overflow: hidden;">
  91. <span class="username font-weight-bold">
  92. <bdi><a class="text-dark" :href="profileUrl(status)">{{status.account.username}}</a></bdi>
  93. </span>
  94. <span class="status-content" v-html="status.content"></span>
  95. </p>
  96. </div>
  97. <div class="timestamp mt-2">
  98. <p class="small text-uppercase mb-0">
  99. <a :href="statusUrl(status)" class="text-muted">
  100. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  101. </a>
  102. <div v-if="recommended">
  103. <span class="px-1">&middot;</span>
  104. <span class="text-muted">Based on popular and trending content</span>
  105. </div>
  106. </p>
  107. </div>
  108. </div>
  109. </div>
  110. <context-menu
  111. ref="contextMenu"
  112. :status="status"
  113. :profile="profile"
  114. />
  115. </div>
  116. </template>
  117. <script type="text/javascript">
  118. import ContextMenu from './ContextMenu.vue';
  119. export default {
  120. props: {
  121. status: {
  122. type: Object
  123. },
  124. recommended: {
  125. type: Boolean,
  126. default: false
  127. }
  128. },
  129. components: {
  130. "context-menu": ContextMenu
  131. },
  132. data() {
  133. return {
  134. config: window.App.config,
  135. profile: {},
  136. loading: true,
  137. replies: [],
  138. replyId: null,
  139. lightboxMedia: false,
  140. showSuggestions: true,
  141. showReadMore: true,
  142. replyStatus: {},
  143. replyText: '',
  144. replyNsfw: false,
  145. emoji: window.App.util.emoji,
  146. ctxMenuStatus: false,
  147. ctxMenuRelationship: false,
  148. ctxEmbedPayload: false,
  149. copiedEmbed: false,
  150. replySending: false,
  151. ctxEmbedShowCaption: true,
  152. ctxEmbedShowLikes: false,
  153. ctxEmbedCompactMode: false,
  154. confirmModalTitle: 'Are you sure?',
  155. confirmModalIdentifer: null,
  156. confirmModalType: false,
  157. tributeSettings: {
  158. collection: [
  159. {
  160. trigger: '@',
  161. menuShowMinLength: 2,
  162. values: (function (text, cb) {
  163. let url = '/api/compose/v0/search/mention';
  164. axios.get(url, { params: { q: text }})
  165. .then(res => {
  166. cb(res.data);
  167. })
  168. .catch(err => {
  169. console.log(err);
  170. })
  171. })
  172. },
  173. {
  174. trigger: '#',
  175. menuShowMinLength: 2,
  176. values: (function (text, cb) {
  177. let url = '/api/compose/v0/search/hashtag';
  178. axios.get(url, { params: { q: text }})
  179. .then(res => {
  180. cb(res.data);
  181. })
  182. .catch(err => {
  183. console.log(err);
  184. })
  185. })
  186. }
  187. ]
  188. },
  189. }
  190. },
  191. mounted() {
  192. this.profile = window._sharedData.curUser;
  193. },
  194. methods: {
  195. formatCount(count) {
  196. return App.util.format.count(count);
  197. },
  198. statusUrl(status) {
  199. if(status.local == true) {
  200. return status.url;
  201. }
  202. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  203. },
  204. profileUrl(status) {
  205. if(status.local == true) {
  206. return status.account.url;
  207. }
  208. return '/i/web/profile/_/' + status.account.id;
  209. },
  210. timestampFormat(timestamp) {
  211. let ts = new Date(timestamp);
  212. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  213. },
  214. statusCardUsernameFormat(status) {
  215. if(status.account.local == true) {
  216. return status.account.username;
  217. }
  218. let fmt = window.App.config.username.remote.format;
  219. let txt = window.App.config.username.remote.custom;
  220. let usr = status.account.username;
  221. let dom = document.createElement('a');
  222. dom.href = status.account.url;
  223. dom = dom.hostname;
  224. switch(fmt) {
  225. case '@':
  226. return usr + '<span class="text-lighter font-weight-bold">@' + dom + '</span>';
  227. break;
  228. case 'from':
  229. return usr + '<span class="text-lighter font-weight-bold"> <span class="font-weight-normal">from</span> ' + dom + '</span>';
  230. break;
  231. case 'custom':
  232. return usr + '<span class="text-lighter font-weight-bold"> ' + txt + ' ' + dom + '</span>';
  233. break;
  234. default:
  235. return usr + '<span class="text-lighter font-weight-bold">@' + dom + '</span>';
  236. break;
  237. }
  238. },
  239. lightbox(status) {
  240. window.location.href = status.media_attachments[0].url;
  241. },
  242. labelRedirect(type) {
  243. let url = '/i/redirect?url=' + encodeURI(this.config.features.label.covid.url);
  244. window.location.href = url;
  245. },
  246. likeStatus(status, event) {
  247. if($('body').hasClass('loggedIn') == false) {
  248. return;
  249. }
  250. let count = status.favourites_count;
  251. status.favourited = !status.favourited;
  252. axios.post('/i/like', {
  253. item: status.id
  254. }).then(res => {
  255. status.favourites_count = res.data.count;
  256. }).catch(err => {
  257. status.favourited = !status.favourited;
  258. status.favourites_count = count;
  259. swal('Error', 'Something went wrong, please try again later.', 'error');
  260. });
  261. window.navigator.vibrate(200);
  262. if(status.favourited) {
  263. setTimeout(function() {
  264. event.target.classList.add('animate__animated', 'animate__bounce');
  265. },100);
  266. }
  267. },
  268. // ctxMenu() {
  269. // this.$emit('ctx-menu', this.status);
  270. // },
  271. commentFocus(status, $event) {
  272. this.$emit('comment-focus', status);
  273. },
  274. muteProfile(status) {
  275. if($('body').hasClass('loggedIn') == false) {
  276. return;
  277. }
  278. axios.post('/i/mute', {
  279. type: 'user',
  280. item: status.account.id
  281. }).then(res => {
  282. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  283. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  284. }).catch(err => {
  285. swal('Error', 'Something went wrong. Please try again later.', 'error');
  286. });
  287. },
  288. blockProfile(status) {
  289. if($('body').hasClass('loggedIn') == false) {
  290. return;
  291. }
  292. axios.post('/i/block', {
  293. type: 'user',
  294. item: status.account.id
  295. }).then(res => {
  296. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  297. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  298. }).catch(err => {
  299. swal('Error', 'Something went wrong. Please try again later.', 'error');
  300. });
  301. },
  302. deletePost(status) {
  303. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  304. return;
  305. }
  306. if(window.confirm('Are you sure you want to delete this post?') == false) {
  307. return;
  308. }
  309. axios.post('/i/delete', {
  310. type: 'status',
  311. item: status.id
  312. }).then(res => {
  313. this.$emit('status-delete', status.id);
  314. this.closeModals();
  315. }).catch(err => {
  316. swal('Error', 'Something went wrong. Please try again later.', 'error');
  317. });
  318. },
  319. commentSubmit(status, $event) {
  320. this.replySending = true;
  321. let id = status.id;
  322. let comment = this.replyText;
  323. let limit = this.config.uploader.max_caption_length;
  324. if(comment.length > limit) {
  325. this.replySending = false;
  326. swal('Comment Too Long', 'Please make sure your comment is '+limit+' characters or less.', 'error');
  327. return;
  328. }
  329. axios.post('/i/comment', {
  330. item: id,
  331. comment: comment,
  332. sensitive: this.replyNsfw
  333. }).then(res => {
  334. this.replyText = '';
  335. this.replies.push(res.data.entity);
  336. this.$refs.replyModal.hide();
  337. });
  338. this.replySending = false;
  339. },
  340. moderatePost(status, action, $event) {
  341. let username = status.account.username;
  342. let msg = '';
  343. let self = this;
  344. switch(action) {
  345. case 'addcw':
  346. msg = 'Are you sure you want to add a content warning to this post?';
  347. swal({
  348. title: 'Confirm',
  349. text: msg,
  350. icon: 'warning',
  351. buttons: true,
  352. dangerMode: true
  353. }).then(res => {
  354. if(res) {
  355. axios.post('/api/v2/moderator/action', {
  356. action: action,
  357. item_id: status.id,
  358. item_type: 'status'
  359. }).then(res => {
  360. swal('Success', 'Successfully added content warning', 'success');
  361. status.sensitive = true;
  362. self.ctxModMenuClose();
  363. }).catch(err => {
  364. swal(
  365. 'Error',
  366. 'Something went wrong, please try again later.',
  367. 'error'
  368. );
  369. self.ctxModMenuClose();
  370. });
  371. }
  372. });
  373. break;
  374. case 'remcw':
  375. msg = 'Are you sure you want to remove the content warning on this post?';
  376. swal({
  377. title: 'Confirm',
  378. text: msg,
  379. icon: 'warning',
  380. buttons: true,
  381. dangerMode: true
  382. }).then(res => {
  383. if(res) {
  384. axios.post('/api/v2/moderator/action', {
  385. action: action,
  386. item_id: status.id,
  387. item_type: 'status'
  388. }).then(res => {
  389. swal('Success', 'Successfully added content warning', 'success');
  390. status.sensitive = false;
  391. self.ctxModMenuClose();
  392. }).catch(err => {
  393. swal(
  394. 'Error',
  395. 'Something went wrong, please try again later.',
  396. 'error'
  397. );
  398. self.ctxModMenuClose();
  399. });
  400. }
  401. });
  402. break;
  403. case 'unlist':
  404. msg = 'Are you sure you want to unlist this post?';
  405. swal({
  406. title: 'Confirm',
  407. text: msg,
  408. icon: 'warning',
  409. buttons: true,
  410. dangerMode: true
  411. }).then(res => {
  412. if(res) {
  413. axios.post('/api/v2/moderator/action', {
  414. action: action,
  415. item_id: status.id,
  416. item_type: 'status'
  417. }).then(res => {
  418. this.feed = this.feed.filter(f => {
  419. return f.id != status.id;
  420. });
  421. swal('Success', 'Successfully unlisted post', 'success');
  422. self.ctxModMenuClose();
  423. }).catch(err => {
  424. self.ctxModMenuClose();
  425. swal(
  426. 'Error',
  427. 'Something went wrong, please try again later.',
  428. 'error'
  429. );
  430. });
  431. }
  432. });
  433. break;
  434. }
  435. },
  436. followAction(status) {
  437. let id = status.account.id;
  438. axios.post('/i/follow', {
  439. item: id
  440. }).then(res => {
  441. this.feed.forEach(s => {
  442. if(s.account.id == id) {
  443. s.account.relationship.following = !s.account.relationship.following;
  444. }
  445. });
  446. let username = status.account.acct;
  447. if(status.account.relationship.following) {
  448. swal('Follow successful!', 'You are now following ' + username, 'success');
  449. } else {
  450. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  451. }
  452. }).catch(err => {
  453. if(err.response.data.message) {
  454. swal('Error', err.response.data.message, 'error');
  455. }
  456. });
  457. },
  458. owner(status) {
  459. return this.profile.id === status.account.id;
  460. },
  461. admin() {
  462. return this.profile.is_admin == true;
  463. },
  464. ownerOrAdmin(status) {
  465. return this.owner(status) || this.admin();
  466. },
  467. ctxMenu() {
  468. this.$refs.contextMenu.open();
  469. // let status = this.status;
  470. // this.ctxMenuStatus = status;
  471. // this.ctxEmbedPayload = window.App.util.embed.post(status.url);
  472. // if(status.account.id == this.profile.id) {
  473. // this.ctxMenuRelationship = false;
  474. // this.$refs.ctxModal.show();
  475. // } else {
  476. // axios.get('/api/pixelfed/v1/accounts/relationships', {
  477. // params: {
  478. // 'id[]': status.account.id
  479. // }
  480. // }).then(res => {
  481. // this.ctxMenuRelationship = res.data[0];
  482. // this.$refs.ctxModal.show();
  483. // });
  484. // }
  485. },
  486. closeCtxMenu(truncate) {
  487. this.copiedEmbed = false;
  488. this.ctxMenuStatus = false;
  489. this.ctxMenuRelationship = false;
  490. this.$refs.ctxModal.hide();
  491. this.$refs.ctxReport.hide();
  492. this.$refs.ctxReportOther.hide();
  493. this.closeModals();
  494. },
  495. ctxMenuCopyLink() {
  496. let status = this.ctxMenuStatus;
  497. navigator.clipboard.writeText(status.url);
  498. this.closeModals();
  499. return;
  500. },
  501. ctxMenuGoToPost() {
  502. let status = this.ctxMenuStatus;
  503. window.location.href = this.statusUrl(status);
  504. this.closeCtxMenu();
  505. return;
  506. },
  507. ctxMenuFollow() {
  508. let id = this.ctxMenuStatus.account.id;
  509. axios.post('/i/follow', {
  510. item: id
  511. }).then(res => {
  512. let username = this.ctxMenuStatus.account.acct;
  513. this.closeCtxMenu();
  514. setTimeout(function() {
  515. swal('Follow successful!', 'You are now following ' + username, 'success');
  516. }, 500);
  517. });
  518. },
  519. ctxMenuUnfollow() {
  520. let id = this.ctxMenuStatus.account.id;
  521. axios.post('/i/follow', {
  522. item: id
  523. }).then(res => {
  524. let username = this.ctxMenuStatus.account.acct;
  525. if(this.scope == 'home') {
  526. this.feed = this.feed.filter(s => {
  527. return s.account.id != this.ctxMenuStatus.account.id;
  528. });
  529. }
  530. this.closeCtxMenu();
  531. setTimeout(function() {
  532. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  533. }, 500);
  534. });
  535. },
  536. ctxMenuReportPost() {
  537. this.$refs.ctxModal.hide();
  538. this.$refs.ctxReport.show();
  539. return;
  540. },
  541. ctxMenuEmbed() {
  542. this.closeModals();
  543. this.$refs.ctxEmbedModal.show();
  544. },
  545. ctxMenuShare() {
  546. this.$refs.ctxModal.hide();
  547. this.$refs.ctxShareModal.show();
  548. },
  549. closeCtxShareMenu() {
  550. this.$refs.ctxShareModal.hide();
  551. this.$refs.ctxModal.show();
  552. },
  553. ctxCopyEmbed() {
  554. navigator.clipboard.writeText(this.ctxEmbedPayload);
  555. this.ctxEmbedShowCaption = true;
  556. this.ctxEmbedShowLikes = false;
  557. this.ctxEmbedCompactMode = false;
  558. this.$refs.ctxEmbedModal.hide();
  559. },
  560. ctxModMenuShow() {
  561. this.$refs.ctxModal.hide();
  562. this.$refs.ctxModModal.show();
  563. },
  564. ctxModOtherMenuShow() {
  565. this.$refs.ctxModal.hide();
  566. this.$refs.ctxModModal.hide();
  567. this.$refs.ctxModOtherModal.show();
  568. },
  569. ctxModMenu() {
  570. this.$refs.ctxModal.hide();
  571. },
  572. ctxModMenuClose() {
  573. this.closeModals();
  574. this.$refs.ctxModal.show();
  575. },
  576. ctxModOtherMenuClose() {
  577. this.closeModals();
  578. this.$refs.ctxModModal.show();
  579. },
  580. formatCount(count) {
  581. return App.util.format.count(count);
  582. },
  583. openCtxReportOtherMenu() {
  584. let s = this.ctxMenuStatus;
  585. this.closeCtxMenu();
  586. this.ctxMenuStatus = s;
  587. this.$refs.ctxReportOther.show();
  588. },
  589. ctxReportMenuGoBack() {
  590. this.$refs.ctxReportOther.hide();
  591. this.$refs.ctxReport.hide();
  592. this.$refs.ctxModal.show();
  593. },
  594. ctxReportOtherMenuGoBack() {
  595. this.$refs.ctxReportOther.hide();
  596. this.$refs.ctxModal.hide();
  597. this.$refs.ctxReport.show();
  598. },
  599. sendReport(type) {
  600. let id = this.ctxMenuStatus.id;
  601. swal({
  602. 'title': 'Confirm Report',
  603. 'text': 'Are you sure you want to report this post?',
  604. 'icon': 'warning',
  605. 'buttons': true,
  606. 'dangerMode': true
  607. }).then((res) => {
  608. if(res) {
  609. axios.post('/i/report/', {
  610. 'report': type,
  611. 'type': 'post',
  612. 'id': id,
  613. }).then(res => {
  614. this.closeCtxMenu();
  615. swal('Report Sent!', 'We have successfully received your report.', 'success');
  616. }).catch(err => {
  617. swal('Oops!', 'There was an issue reporting this post.', 'error');
  618. })
  619. } else {
  620. this.closeCtxMenu();
  621. }
  622. });
  623. },
  624. closeModals() {
  625. this.$refs.ctxModal.hide();
  626. this.$refs.ctxModModal.hide();
  627. this.$refs.ctxModOtherModal.hide();
  628. this.$refs.ctxShareModal.hide();
  629. this.$refs.ctxEmbedModal.hide();
  630. this.$refs.ctxReport.hide();
  631. this.$refs.ctxReportOther.hide();
  632. this.$refs.ctxConfirm.hide();
  633. this.$refs.lightboxModal.hide();
  634. this.$refs.replyModal.hide();
  635. this.$refs.ctxStatusModal.hide();
  636. },
  637. openCtxStatusModal() {
  638. this.closeModals();
  639. this.$refs.ctxStatusModal.show();
  640. },
  641. openConfirmModal() {
  642. this.closeModals();
  643. this.$refs.ctxConfirm.show();
  644. },
  645. closeConfirmModal() {
  646. this.closeModals();
  647. this.confirmModalTitle = 'Are you sure?';
  648. this.confirmModalType = false;
  649. this.confirmModalIdentifer = null;
  650. },
  651. confirmModalConfirm() {
  652. switch(this.confirmModalType) {
  653. case 'post.delete':
  654. axios.post('/i/delete', {
  655. type: 'status',
  656. item: this.confirmModalIdentifer
  657. }).then(res => {
  658. this.feed = this.feed.filter(s => {
  659. return s.id != this.confirmModalIdentifer;
  660. });
  661. this.closeConfirmModal();
  662. }).catch(err => {
  663. this.closeConfirmModal();
  664. swal('Error', 'Something went wrong. Please try again later.', 'error');
  665. });
  666. break;
  667. }
  668. this.closeConfirmModal();
  669. },
  670. confirmModalCancel() {
  671. this.closeConfirmModal();
  672. },
  673. timeAgo(ts) {
  674. return App.util.format.timeAgo(ts);
  675. },
  676. }
  677. }
  678. </script>