logo

pleroma-fe

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

edit_status_modal.js (1824B)


  1. import PostStatusForm from '../post_status_form/post_status_form.vue'
  2. import Modal from '../modal/modal.vue'
  3. import statusPosterService from '../../services/status_poster/status_poster.service.js'
  4. import get from 'lodash/get'
  5. const EditStatusModal = {
  6. components: {
  7. PostStatusForm,
  8. Modal
  9. },
  10. data () {
  11. return {
  12. resettingForm: false
  13. }
  14. },
  15. computed: {
  16. isLoggedIn () {
  17. return !!this.$store.state.users.currentUser
  18. },
  19. modalActivated () {
  20. return this.$store.state.editStatus.modalActivated
  21. },
  22. isFormVisible () {
  23. return this.isLoggedIn && !this.resettingForm && this.modalActivated
  24. },
  25. params () {
  26. return this.$store.state.editStatus.params || {}
  27. }
  28. },
  29. watch: {
  30. params (newVal, oldVal) {
  31. if (get(newVal, 'statusId') !== get(oldVal, 'statusId')) {
  32. this.resettingForm = true
  33. this.$nextTick(() => {
  34. this.resettingForm = false
  35. })
  36. }
  37. },
  38. isFormVisible (val) {
  39. if (val) {
  40. this.$nextTick(() => this.$el && this.$el.querySelector('textarea').focus())
  41. }
  42. }
  43. },
  44. methods: {
  45. doEditStatus ({ status, spoilerText, sensitive, media, contentType, poll }) {
  46. const params = {
  47. store: this.$store,
  48. statusId: this.$store.state.editStatus.params.statusId,
  49. status,
  50. spoilerText,
  51. sensitive,
  52. poll,
  53. media,
  54. contentType
  55. }
  56. return statusPosterService.editStatus(params)
  57. .then((data) => {
  58. return data
  59. })
  60. .catch((err) => {
  61. console.error('Error editing status', err)
  62. return {
  63. error: err.message
  64. }
  65. })
  66. },
  67. closeModal () {
  68. this.$store.dispatch('closeEditStatusModal')
  69. }
  70. }
  71. }
  72. export default EditStatusModal