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 {
|
import {
|
||||||
faPen
|
faPen
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { usePostStatusStore } from '../../stores/postStatus'
|
||||||
|
|
||||||
library.add(
|
library.add(
|
||||||
faPen
|
faPen
|
||||||
|
@ -71,7 +72,7 @@ const MobilePostStatusButton = {
|
||||||
window.removeEventListener('scroll', this.handleScrollEnd)
|
window.removeEventListener('scroll', this.handleScrollEnd)
|
||||||
},
|
},
|
||||||
openPostForm () {
|
openPostForm () {
|
||||||
this.$store.dispatch('openPostStatusModal')
|
usePostStatusStore().openPostStatusModal()
|
||||||
},
|
},
|
||||||
handleOSK () {
|
handleOSK () {
|
||||||
// This is a big hack: we're guessing from changed window sizes if the
|
// 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 PostStatusForm from '../post_status_form/post_status_form.vue'
|
||||||
import Modal from '../modal/modal.vue'
|
import Modal from '../modal/modal.vue'
|
||||||
import get from 'lodash/get'
|
import get from 'lodash/get'
|
||||||
|
import { usePostStatusStore } from '../../stores/postStatus'
|
||||||
|
|
||||||
const PostStatusModal = {
|
const PostStatusModal = {
|
||||||
components: {
|
components: {
|
||||||
|
@ -17,13 +18,13 @@ const PostStatusModal = {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
modalActivated () {
|
modalActivated () {
|
||||||
return this.$store.state.postStatus.modalActivated
|
return usePostStatusStore().modalActivated
|
||||||
},
|
},
|
||||||
isFormVisible () {
|
isFormVisible () {
|
||||||
return this.isLoggedIn && !this.resettingForm && this.modalActivated
|
return this.isLoggedIn && !this.resettingForm && this.modalActivated
|
||||||
},
|
},
|
||||||
params () {
|
params () {
|
||||||
return this.$store.state.postStatus.params || {}
|
return usePostStatusStore().params || {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -43,7 +44,7 @@ const PostStatusModal = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeModal () {
|
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 ConfirmModal from '../confirm_modal/confirm_modal.vue'
|
||||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
import { usePostStatusStore } from '../../stores/postStatus'
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
faBell,
|
faBell,
|
||||||
|
@ -225,7 +226,7 @@ export default {
|
||||||
this.$store.dispatch('setCurrentMedia', attachment)
|
this.$store.dispatch('setCurrentMedia', attachment)
|
||||||
},
|
},
|
||||||
mentionUser () {
|
mentionUser () {
|
||||||
this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user })
|
usePostStatusStore().openPostStatusModal({ replyTo: true, repliedUser: this.user })
|
||||||
},
|
},
|
||||||
onAvatarClickHandler (e) {
|
onAvatarClickHandler (e) {
|
||||||
if (this.onAvatarClick) {
|
if (this.onAvatarClick) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import mediaViewerModule from './modules/media_viewer.js'
|
||||||
import oauthTokensModule from './modules/oauth_tokens.js'
|
import oauthTokensModule from './modules/oauth_tokens.js'
|
||||||
import reportsModule from './modules/reports.js'
|
import reportsModule from './modules/reports.js'
|
||||||
import pollsModule from './modules/polls.js'
|
import pollsModule from './modules/polls.js'
|
||||||
import postStatusModule from './modules/postStatus.js'
|
|
||||||
import editStatusModule from './modules/editStatus.js'
|
import editStatusModule from './modules/editStatus.js'
|
||||||
import statusHistoryModule from './modules/statusHistory.js'
|
import statusHistoryModule from './modules/statusHistory.js'
|
||||||
|
|
||||||
|
@ -84,7 +83,6 @@ const persistedStateOptions = {
|
||||||
oauthTokens: oauthTokensModule,
|
oauthTokens: oauthTokensModule,
|
||||||
reports: reportsModule,
|
reports: reportsModule,
|
||||||
polls: pollsModule,
|
polls: pollsModule,
|
||||||
postStatus: postStatusModule,
|
|
||||||
editStatus: editStatusModule,
|
editStatus: editStatusModule,
|
||||||
statusHistory: statusHistoryModule,
|
statusHistory: statusHistoryModule,
|
||||||
chats: chatsModule,
|
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