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 (1244B)


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