logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

status_history_modal.js (1295B)


  1. import { get } from 'lodash'
  2. import Modal from '../modal/modal.vue'
  3. import Status from '../status/status.vue'
  4. import { useStatusHistoryStore } from 'src/stores/statusHistory'
  5. const StatusHistoryModal = {
  6. components: {
  7. Modal,
  8. Status
  9. },
  10. data () {
  11. return {
  12. statuses: []
  13. }
  14. },
  15. computed: {
  16. modalActivated () {
  17. return useStatusHistoryStore().modalActivated
  18. },
  19. params () {
  20. return useStatusHistoryStore().params
  21. },
  22. statusId () {
  23. return this.params.id
  24. },
  25. historyCount () {
  26. return this.statuses.length
  27. },
  28. history () {
  29. return this.statuses
  30. }
  31. },
  32. watch: {
  33. params (newVal, oldVal) {
  34. const newStatusId = get(newVal, 'id') !== get(oldVal, 'id')
  35. if (newStatusId) {
  36. this.resetHistory()
  37. }
  38. if (newStatusId || get(newVal, 'edited_at') !== get(oldVal, 'edited_at')) {
  39. this.fetchStatusHistory()
  40. }
  41. }
  42. },
  43. methods: {
  44. resetHistory () {
  45. this.statuses = []
  46. },
  47. fetchStatusHistory () {
  48. this.$store.dispatch('fetchStatusHistory', this.params)
  49. .then(data => {
  50. this.statuses = data
  51. })
  52. },
  53. closeModal () {
  54. useStatusHistoryStore().closeStatusHistoryModal()
  55. }
  56. }
  57. }
  58. export default StatusHistoryModal