StatusCard.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  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 v-if="reactionBar" 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 mb-0">
  99. <a :href="statusUrl(status)" class="text-muted text-uppercase">
  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. <span v-if="recommended">
  103. <span class="px-1">&middot;</span>
  104. <span class="text-muted">Based on popular and trending content</span>
  105. </span>
  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. reactionBar: {
  129. type: Boolean,
  130. default: true
  131. }
  132. },
  133. components: {
  134. "context-menu": ContextMenu
  135. },
  136. data() {
  137. return {
  138. config: window.App.config,
  139. profile: {},
  140. loading: true,
  141. replies: [],
  142. replyId: null,
  143. lightboxMedia: false,
  144. showSuggestions: true,
  145. showReadMore: true,
  146. replyStatus: {},
  147. replyText: '',
  148. replyNsfw: false,
  149. emoji: window.App.util.emoji,
  150. ctxMenuStatus: false,
  151. ctxMenuRelationship: false,
  152. ctxEmbedPayload: false,
  153. copiedEmbed: false,
  154. replySending: false,
  155. ctxEmbedShowCaption: true,
  156. ctxEmbedShowLikes: false,
  157. ctxEmbedCompactMode: false,
  158. confirmModalTitle: 'Are you sure?',
  159. confirmModalIdentifer: null,
  160. confirmModalType: false,
  161. tributeSettings: {
  162. collection: [
  163. {
  164. trigger: '@',
  165. menuShowMinLength: 2,
  166. values: (function (text, cb) {
  167. let url = '/api/compose/v0/search/mention';
  168. axios.get(url, { params: { q: text }})
  169. .then(res => {
  170. cb(res.data);
  171. })
  172. .catch(err => {
  173. console.log(err);
  174. })
  175. })
  176. },
  177. {
  178. trigger: '#',
  179. menuShowMinLength: 2,
  180. values: (function (text, cb) {
  181. let url = '/api/compose/v0/search/hashtag';
  182. axios.get(url, { params: { q: text }})
  183. .then(res => {
  184. cb(res.data);
  185. })
  186. .catch(err => {
  187. console.log(err);
  188. })
  189. })
  190. }
  191. ]
  192. },
  193. }
  194. },
  195. mounted() {
  196. this.profile = window._sharedData.curUser;
  197. },
  198. methods: {
  199. formatCount(count) {
  200. return App.util.format.count(count);
  201. },
  202. statusUrl(status) {
  203. if(status.local == true) {
  204. return status.url;
  205. }
  206. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  207. },
  208. profileUrl(status) {
  209. if(status.local == true) {
  210. return status.account.url;
  211. }
  212. return '/i/web/profile/_/' + status.account.id;
  213. },
  214. timestampFormat(timestamp) {
  215. let ts = new Date(timestamp);
  216. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  217. },
  218. statusCardUsernameFormat(status) {
  219. if(status.account.local == true) {
  220. return status.account.username;
  221. }
  222. let fmt = window.App.config.username.remote.format;
  223. let txt = window.App.config.username.remote.custom;
  224. let usr = status.account.username;
  225. let dom = document.createElement('a');
  226. dom.href = status.account.url;
  227. dom = dom.hostname;
  228. switch(fmt) {
  229. case '@':
  230. return usr + '<span class="text-lighter font-weight-bold">@' + dom + '</span>';
  231. break;
  232. case 'from':
  233. return usr + '<span class="text-lighter font-weight-bold"> <span class="font-weight-normal">from</span> ' + dom + '</span>';
  234. break;
  235. case 'custom':
  236. return usr + '<span class="text-lighter font-weight-bold"> ' + txt + ' ' + dom + '</span>';
  237. break;
  238. default:
  239. return usr + '<span class="text-lighter font-weight-bold">@' + dom + '</span>';
  240. break;
  241. }
  242. },
  243. lightbox(status) {
  244. window.location.href = status.media_attachments[0].url;
  245. },
  246. labelRedirect(type) {
  247. let url = '/i/redirect?url=' + encodeURI(this.config.features.label.covid.url);
  248. window.location.href = url;
  249. },
  250. likeStatus(status, event) {
  251. if($('body').hasClass('loggedIn') == false) {
  252. return;
  253. }
  254. let count = status.favourites_count;
  255. status.favourited = !status.favourited;
  256. axios.post('/i/like', {
  257. item: status.id
  258. }).then(res => {
  259. status.favourites_count = res.data.count;
  260. }).catch(err => {
  261. status.favourited = !status.favourited;
  262. status.favourites_count = count;
  263. swal('Error', 'Something went wrong, please try again later.', 'error');
  264. });
  265. window.navigator.vibrate(200);
  266. if(status.favourited) {
  267. setTimeout(function() {
  268. event.target.classList.add('animate__animated', 'animate__bounce');
  269. },100);
  270. }
  271. },
  272. // ctxMenu() {
  273. // this.$emit('ctx-menu', this.status);
  274. // },
  275. commentFocus(status, $event) {
  276. this.$emit('comment-focus', status);
  277. },
  278. muteProfile(status) {
  279. if($('body').hasClass('loggedIn') == false) {
  280. return;
  281. }
  282. axios.post('/i/mute', {
  283. type: 'user',
  284. item: status.account.id
  285. }).then(res => {
  286. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  287. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  288. }).catch(err => {
  289. swal('Error', 'Something went wrong. Please try again later.', 'error');
  290. });
  291. },
  292. blockProfile(status) {
  293. if($('body').hasClass('loggedIn') == false) {
  294. return;
  295. }
  296. axios.post('/i/block', {
  297. type: 'user',
  298. item: status.account.id
  299. }).then(res => {
  300. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  301. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  302. }).catch(err => {
  303. swal('Error', 'Something went wrong. Please try again later.', 'error');
  304. });
  305. },
  306. deletePost(status) {
  307. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  308. return;
  309. }
  310. if(window.confirm('Are you sure you want to delete this post?') == false) {
  311. return;
  312. }
  313. axios.post('/i/delete', {
  314. type: 'status',
  315. item: status.id
  316. }).then(res => {
  317. this.$emit('status-delete', status.id);
  318. this.closeModals();
  319. }).catch(err => {
  320. swal('Error', 'Something went wrong. Please try again later.', 'error');
  321. });
  322. },
  323. commentSubmit(status, $event) {
  324. this.replySending = true;
  325. let id = status.id;
  326. let comment = this.replyText;
  327. let limit = this.config.uploader.max_caption_length;
  328. if(comment.length > limit) {
  329. this.replySending = false;
  330. swal('Comment Too Long', 'Please make sure your comment is '+limit+' characters or less.', 'error');
  331. return;
  332. }
  333. axios.post('/i/comment', {
  334. item: id,
  335. comment: comment,
  336. sensitive: this.replyNsfw
  337. }).then(res => {
  338. this.replyText = '';
  339. this.replies.push(res.data.entity);
  340. this.$refs.replyModal.hide();
  341. });
  342. this.replySending = false;
  343. },
  344. moderatePost(status, action, $event) {
  345. let username = status.account.username;
  346. let msg = '';
  347. let self = this;
  348. switch(action) {
  349. case 'addcw':
  350. msg = 'Are you sure you want to add a content warning to this post?';
  351. swal({
  352. title: 'Confirm',
  353. text: msg,
  354. icon: 'warning',
  355. buttons: true,
  356. dangerMode: true
  357. }).then(res => {
  358. if(res) {
  359. axios.post('/api/v2/moderator/action', {
  360. action: action,
  361. item_id: status.id,
  362. item_type: 'status'
  363. }).then(res => {
  364. swal('Success', 'Successfully added content warning', 'success');
  365. status.sensitive = true;
  366. self.ctxModMenuClose();
  367. }).catch(err => {
  368. swal(
  369. 'Error',
  370. 'Something went wrong, please try again later.',
  371. 'error'
  372. );
  373. self.ctxModMenuClose();
  374. });
  375. }
  376. });
  377. break;
  378. case 'remcw':
  379. msg = 'Are you sure you want to remove the content warning on this post?';
  380. swal({
  381. title: 'Confirm',
  382. text: msg,
  383. icon: 'warning',
  384. buttons: true,
  385. dangerMode: true
  386. }).then(res => {
  387. if(res) {
  388. axios.post('/api/v2/moderator/action', {
  389. action: action,
  390. item_id: status.id,
  391. item_type: 'status'
  392. }).then(res => {
  393. swal('Success', 'Successfully added content warning', 'success');
  394. status.sensitive = false;
  395. self.ctxModMenuClose();
  396. }).catch(err => {
  397. swal(
  398. 'Error',
  399. 'Something went wrong, please try again later.',
  400. 'error'
  401. );
  402. self.ctxModMenuClose();
  403. });
  404. }
  405. });
  406. break;
  407. case 'unlist':
  408. msg = 'Are you sure you want to unlist this post?';
  409. swal({
  410. title: 'Confirm',
  411. text: msg,
  412. icon: 'warning',
  413. buttons: true,
  414. dangerMode: true
  415. }).then(res => {
  416. if(res) {
  417. axios.post('/api/v2/moderator/action', {
  418. action: action,
  419. item_id: status.id,
  420. item_type: 'status'
  421. }).then(res => {
  422. this.feed = this.feed.filter(f => {
  423. return f.id != status.id;
  424. });
  425. swal('Success', 'Successfully unlisted post', 'success');
  426. self.ctxModMenuClose();
  427. }).catch(err => {
  428. self.ctxModMenuClose();
  429. swal(
  430. 'Error',
  431. 'Something went wrong, please try again later.',
  432. 'error'
  433. );
  434. });
  435. }
  436. });
  437. break;
  438. }
  439. },
  440. followAction(status) {
  441. let id = status.account.id;
  442. axios.post('/i/follow', {
  443. item: id
  444. }).then(res => {
  445. this.feed.forEach(s => {
  446. if(s.account.id == id) {
  447. s.account.relationship.following = !s.account.relationship.following;
  448. }
  449. });
  450. let username = status.account.acct;
  451. if(status.account.relationship.following) {
  452. swal('Follow successful!', 'You are now following ' + username, 'success');
  453. } else {
  454. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  455. }
  456. }).catch(err => {
  457. if(err.response.data.message) {
  458. swal('Error', err.response.data.message, 'error');
  459. }
  460. });
  461. },
  462. owner(status) {
  463. return this.profile.id === status.account.id;
  464. },
  465. admin() {
  466. return this.profile.is_admin == true;
  467. },
  468. ownerOrAdmin(status) {
  469. return this.owner(status) || this.admin();
  470. },
  471. ctxMenu() {
  472. this.$refs.contextMenu.open();
  473. // let status = this.status;
  474. // this.ctxMenuStatus = status;
  475. // this.ctxEmbedPayload = window.App.util.embed.post(status.url);
  476. // if(status.account.id == this.profile.id) {
  477. // this.ctxMenuRelationship = false;
  478. // this.$refs.ctxModal.show();
  479. // } else {
  480. // axios.get('/api/pixelfed/v1/accounts/relationships', {
  481. // params: {
  482. // 'id[]': status.account.id
  483. // }
  484. // }).then(res => {
  485. // this.ctxMenuRelationship = res.data[0];
  486. // this.$refs.ctxModal.show();
  487. // });
  488. // }
  489. },
  490. closeCtxMenu(truncate) {
  491. this.copiedEmbed = false;
  492. this.ctxMenuStatus = false;
  493. this.ctxMenuRelationship = false;
  494. this.$refs.ctxModal.hide();
  495. this.$refs.ctxReport.hide();
  496. this.$refs.ctxReportOther.hide();
  497. this.closeModals();
  498. },
  499. ctxMenuCopyLink() {
  500. let status = this.ctxMenuStatus;
  501. navigator.clipboard.writeText(status.url);
  502. this.closeModals();
  503. return;
  504. },
  505. ctxMenuGoToPost() {
  506. let status = this.ctxMenuStatus;
  507. window.location.href = this.statusUrl(status);
  508. this.closeCtxMenu();
  509. return;
  510. },
  511. ctxMenuFollow() {
  512. let id = this.ctxMenuStatus.account.id;
  513. axios.post('/i/follow', {
  514. item: id
  515. }).then(res => {
  516. let username = this.ctxMenuStatus.account.acct;
  517. this.closeCtxMenu();
  518. setTimeout(function() {
  519. swal('Follow successful!', 'You are now following ' + username, 'success');
  520. }, 500);
  521. });
  522. },
  523. ctxMenuUnfollow() {
  524. let id = this.ctxMenuStatus.account.id;
  525. axios.post('/i/follow', {
  526. item: id
  527. }).then(res => {
  528. let username = this.ctxMenuStatus.account.acct;
  529. if(this.scope == 'home') {
  530. this.feed = this.feed.filter(s => {
  531. return s.account.id != this.ctxMenuStatus.account.id;
  532. });
  533. }
  534. this.closeCtxMenu();
  535. setTimeout(function() {
  536. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  537. }, 500);
  538. });
  539. },
  540. ctxMenuReportPost() {
  541. this.$refs.ctxModal.hide();
  542. this.$refs.ctxReport.show();
  543. return;
  544. },
  545. ctxMenuEmbed() {
  546. this.closeModals();
  547. this.$refs.ctxEmbedModal.show();
  548. },
  549. ctxMenuShare() {
  550. this.$refs.ctxModal.hide();
  551. this.$refs.ctxShareModal.show();
  552. },
  553. closeCtxShareMenu() {
  554. this.$refs.ctxShareModal.hide();
  555. this.$refs.ctxModal.show();
  556. },
  557. ctxCopyEmbed() {
  558. navigator.clipboard.writeText(this.ctxEmbedPayload);
  559. this.ctxEmbedShowCaption = true;
  560. this.ctxEmbedShowLikes = false;
  561. this.ctxEmbedCompactMode = false;
  562. this.$refs.ctxEmbedModal.hide();
  563. },
  564. ctxModMenuShow() {
  565. this.$refs.ctxModal.hide();
  566. this.$refs.ctxModModal.show();
  567. },
  568. ctxModOtherMenuShow() {
  569. this.$refs.ctxModal.hide();
  570. this.$refs.ctxModModal.hide();
  571. this.$refs.ctxModOtherModal.show();
  572. },
  573. ctxModMenu() {
  574. this.$refs.ctxModal.hide();
  575. },
  576. ctxModMenuClose() {
  577. this.closeModals();
  578. this.$refs.ctxModal.show();
  579. },
  580. ctxModOtherMenuClose() {
  581. this.closeModals();
  582. this.$refs.ctxModModal.show();
  583. },
  584. formatCount(count) {
  585. return App.util.format.count(count);
  586. },
  587. openCtxReportOtherMenu() {
  588. let s = this.ctxMenuStatus;
  589. this.closeCtxMenu();
  590. this.ctxMenuStatus = s;
  591. this.$refs.ctxReportOther.show();
  592. },
  593. ctxReportMenuGoBack() {
  594. this.$refs.ctxReportOther.hide();
  595. this.$refs.ctxReport.hide();
  596. this.$refs.ctxModal.show();
  597. },
  598. ctxReportOtherMenuGoBack() {
  599. this.$refs.ctxReportOther.hide();
  600. this.$refs.ctxModal.hide();
  601. this.$refs.ctxReport.show();
  602. },
  603. sendReport(type) {
  604. let id = this.ctxMenuStatus.id;
  605. swal({
  606. 'title': 'Confirm Report',
  607. 'text': 'Are you sure you want to report this post?',
  608. 'icon': 'warning',
  609. 'buttons': true,
  610. 'dangerMode': true
  611. }).then((res) => {
  612. if(res) {
  613. axios.post('/i/report/', {
  614. 'report': type,
  615. 'type': 'post',
  616. 'id': id,
  617. }).then(res => {
  618. this.closeCtxMenu();
  619. swal('Report Sent!', 'We have successfully received your report.', 'success');
  620. }).catch(err => {
  621. swal('Oops!', 'There was an issue reporting this post.', 'error');
  622. })
  623. } else {
  624. this.closeCtxMenu();
  625. }
  626. });
  627. },
  628. closeModals() {
  629. this.$refs.ctxModal.hide();
  630. this.$refs.ctxModModal.hide();
  631. this.$refs.ctxModOtherModal.hide();
  632. this.$refs.ctxShareModal.hide();
  633. this.$refs.ctxEmbedModal.hide();
  634. this.$refs.ctxReport.hide();
  635. this.$refs.ctxReportOther.hide();
  636. this.$refs.ctxConfirm.hide();
  637. this.$refs.lightboxModal.hide();
  638. this.$refs.replyModal.hide();
  639. this.$refs.ctxStatusModal.hide();
  640. },
  641. openCtxStatusModal() {
  642. this.closeModals();
  643. this.$refs.ctxStatusModal.show();
  644. },
  645. openConfirmModal() {
  646. this.closeModals();
  647. this.$refs.ctxConfirm.show();
  648. },
  649. closeConfirmModal() {
  650. this.closeModals();
  651. this.confirmModalTitle = 'Are you sure?';
  652. this.confirmModalType = false;
  653. this.confirmModalIdentifer = null;
  654. },
  655. confirmModalConfirm() {
  656. switch(this.confirmModalType) {
  657. case 'post.delete':
  658. axios.post('/i/delete', {
  659. type: 'status',
  660. item: this.confirmModalIdentifer
  661. }).then(res => {
  662. this.feed = this.feed.filter(s => {
  663. return s.id != this.confirmModalIdentifer;
  664. });
  665. this.closeConfirmModal();
  666. }).catch(err => {
  667. this.closeConfirmModal();
  668. swal('Error', 'Something went wrong. Please try again later.', 'error');
  669. });
  670. break;
  671. }
  672. this.closeConfirmModal();
  673. },
  674. confirmModalCancel() {
  675. this.closeConfirmModal();
  676. },
  677. timeAgo(ts) {
  678. return App.util.format.timeAgo(ts);
  679. },
  680. }
  681. }
  682. </script>