logo

pleroma-fe

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

draft.js (2529B)


  1. import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
  2. import EditStatusForm from 'src/components/edit_status_form/edit_status_form.vue'
  3. import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue'
  4. import StatusContent from 'src/components/status_content/status_content.vue'
  5. import Gallery from 'src/components/gallery/gallery.vue'
  6. import { cloneDeep } from 'lodash'
  7. import { library } from '@fortawesome/fontawesome-svg-core'
  8. import {
  9. faPollH
  10. } from '@fortawesome/free-solid-svg-icons'
  11. library.add(
  12. faPollH
  13. )
  14. const Draft = {
  15. components: {
  16. PostStatusForm,
  17. EditStatusForm,
  18. ConfirmModal,
  19. StatusContent,
  20. Gallery
  21. },
  22. props: {
  23. draft: {
  24. type: Object,
  25. required: true
  26. }
  27. },
  28. data () {
  29. return {
  30. referenceDraft: cloneDeep(this.draft),
  31. editing: false,
  32. showingConfirmDialog: false
  33. }
  34. },
  35. computed: {
  36. relAttrs () {
  37. if (this.draft.type === 'edit') {
  38. return { statusId: this.draft.refId }
  39. } else if (this.draft.type === 'reply') {
  40. return { replyTo: this.draft.refId }
  41. } else {
  42. return {}
  43. }
  44. },
  45. safeToSave () {
  46. return this.draft.status ||
  47. this.draft.files?.length ||
  48. this.draft.hasPoll
  49. },
  50. postStatusFormProps () {
  51. return {
  52. draftId: this.draft.id,
  53. ...this.relAttrs
  54. }
  55. },
  56. refStatus () {
  57. return this.draft.refId ? this.$store.state.statuses.allStatusesObject[this.draft.refId] : undefined
  58. },
  59. localCollapseSubjectDefault () {
  60. return this.$store.getters.mergedConfig.collapseMessageWithSubject
  61. },
  62. nsfwClickthrough () {
  63. if (!this.draft.nsfw) {
  64. return false
  65. }
  66. if (this.draft.summary && this.localCollapseSubjectDefault) {
  67. return false
  68. }
  69. return true
  70. }
  71. },
  72. watch: {
  73. editing (newVal) {
  74. if (newVal) return
  75. if (this.safeToSave) {
  76. this.$store.dispatch('addOrSaveDraft', { draft: this.draft })
  77. } else {
  78. this.$store.dispatch('addOrSaveDraft', { draft: this.referenceDraft })
  79. }
  80. }
  81. },
  82. methods: {
  83. toggleEditing () {
  84. this.editing = !this.editing
  85. },
  86. abandon () {
  87. this.showingConfirmDialog = true
  88. },
  89. doAbandon () {
  90. this.$store.dispatch('abandonDraft', { id: this.draft.id })
  91. .then(() => {
  92. this.hideConfirmDialog()
  93. })
  94. },
  95. hideConfirmDialog () {
  96. this.showingConfirmDialog = false
  97. }
  98. }
  99. }
  100. export default Draft