Move postStatus module to store
This commit is contained in:
parent
aa6c13f9e6
commit
27e36dbc2e
|
@ -3,6 +3,7 @@ import { library } from '@fortawesome/fontawesome-svg-core'
|
|||
import {
|
||||
faPen
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { usePostStatusStore } from '../../stores/postStatus'
|
||||
|
||||
library.add(
|
||||
faPen
|
||||
|
@ -71,7 +72,7 @@ const MobilePostStatusButton = {
|
|||
window.removeEventListener('scroll', this.handleScrollEnd)
|
||||
},
|
||||
openPostForm () {
|
||||
this.$store.dispatch('openPostStatusModal')
|
||||
usePostStatusStore().openPostStatusModal()
|
||||
},
|
||||
handleOSK () {
|
||||
// This is a big hack: we're guessing from changed window sizes if the
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import PostStatusForm from '../post_status_form/post_status_form.vue'
|
||||
import Modal from '../modal/modal.vue'
|
||||
import get from 'lodash/get'
|
||||
import { usePostStatusStore } from '../../stores/postStatus'
|
||||
|
||||
const PostStatusModal = {
|
||||
components: {
|
||||
|
@ -17,13 +18,13 @@ const PostStatusModal = {
|
|||
return !!this.$store.state.users.currentUser
|
||||
},
|
||||
modalActivated () {
|
||||
return this.$store.state.postStatus.modalActivated
|
||||
return usePostStatusStore().modalActivated
|
||||
},
|
||||
isFormVisible () {
|
||||
return this.isLoggedIn && !this.resettingForm && this.modalActivated
|
||||
},
|
||||
params () {
|
||||
return this.$store.state.postStatus.params || {}
|
||||
return usePostStatusStore().params || {}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -43,7 +44,7 @@ const PostStatusModal = {
|
|||
},
|
||||
methods: {
|
||||
closeModal () {
|
||||
this.$store.dispatch('closePostStatusModal')
|
||||
usePostStatusStore().closePostStatusModal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import RichContent from 'src/components/rich_content/rich_content.jsx'
|
|||
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
|
||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { usePostStatusStore } from '../../stores/postStatus'
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import {
|
||||
faBell,
|
||||
|
@ -225,7 +226,7 @@ export default {
|
|||
this.$store.dispatch('setCurrentMedia', attachment)
|
||||
},
|
||||
mentionUser () {
|
||||
this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user })
|
||||
usePostStatusStore().openPostStatusModal({ replyTo: true, repliedUser: this.user })
|
||||
},
|
||||
onAvatarClickHandler (e) {
|
||||
if (this.onAvatarClick) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import mediaViewerModule from './modules/media_viewer.js'
|
|||
import oauthTokensModule from './modules/oauth_tokens.js'
|
||||
import reportsModule from './modules/reports.js'
|
||||
import pollsModule from './modules/polls.js'
|
||||
import postStatusModule from './modules/postStatus.js'
|
||||
import editStatusModule from './modules/editStatus.js'
|
||||
import statusHistoryModule from './modules/statusHistory.js'
|
||||
|
||||
|
@ -84,7 +83,6 @@ const persistedStateOptions = {
|
|||
oauthTokens: oauthTokensModule,
|
||||
reports: reportsModule,
|
||||
polls: pollsModule,
|
||||
postStatus: postStatusModule,
|
||||
editStatus: editStatusModule,
|
||||
statusHistory: statusHistoryModule,
|
||||
chats: chatsModule,
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
const postStatus = {
|
||||
state: {
|
||||
params: null,
|
||||
modalActivated: false
|
||||
},
|
||||
mutations: {
|
||||
openPostStatusModal (state, params) {
|
||||
state.params = params
|
||||
state.modalActivated = true
|
||||
},
|
||||
closePostStatusModal (state) {
|
||||
state.modalActivated = false
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
openPostStatusModal ({ commit }, params) {
|
||||
commit('openPostStatusModal', params)
|
||||
},
|
||||
closePostStatusModal ({ commit }) {
|
||||
commit('closePostStatusModal')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default postStatus
|
|
@ -0,0 +1,17 @@
|
|||
import { defineStore } from 'pinia'
|
||||
|
||||
export const usePostStatusStore = defineStore('postStatus', {
|
||||
state: () => ({
|
||||
params: null,
|
||||
modalActivated: false
|
||||
}),
|
||||
actions: {
|
||||
openPostStatusModal (params) {
|
||||
this.params = params
|
||||
this.modalActivated = true
|
||||
},
|
||||
closePostStatusModal () {
|
||||
this.modalActivated = false
|
||||
}
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue