Move statusHistory module to store

This commit is contained in:
Sean King 2023-04-05 14:13:28 -06:00
parent c25cfe540b
commit 872569ae8e
No known key found for this signature in database
GPG Key ID: 510C52BACD6E7257
5 changed files with 23 additions and 31 deletions

View File

@ -17,6 +17,7 @@ import {
faFlag faFlag
} from '@fortawesome/free-regular-svg-icons' } from '@fortawesome/free-regular-svg-icons'
import { useEditStatusStore } from '../../stores/editStatus' import { useEditStatusStore } from '../../stores/editStatus'
import { useStatusHistoryStore } from '../../stores/statusHistory'
library.add( library.add(
faEllipsisH, faEllipsisH,
@ -123,7 +124,7 @@ const ExtraButtons = {
const originalStatus = { ...this.status } const originalStatus = { ...this.status }
const stripFieldsList = ['attachments', 'created_at', 'emojis', 'text', 'raw_html', 'nsfw', 'poll', 'summary', 'summary_raw_html'] const stripFieldsList = ['attachments', 'created_at', 'emojis', 'text', 'raw_html', 'nsfw', 'poll', 'summary', 'summary_raw_html']
stripFieldsList.forEach(p => delete originalStatus[p]) stripFieldsList.forEach(p => delete originalStatus[p])
this.$store.dispatch('openStatusHistoryModal', originalStatus) useStatusHistoryStore().openStatusHistoryModal(originalStatus)
} }
}, },
computed: { computed: {

View File

@ -1,6 +1,7 @@
import { get } from 'lodash' import { get } from 'lodash'
import Modal from '../modal/modal.vue' import Modal from '../modal/modal.vue'
import Status from '../status/status.vue' import Status from '../status/status.vue'
import { useStatusHistoryStore } from '../../stores/statusHistory'
const StatusHistoryModal = { const StatusHistoryModal = {
components: { components: {
@ -14,10 +15,10 @@ const StatusHistoryModal = {
}, },
computed: { computed: {
modalActivated () { modalActivated () {
return this.$store.state.statusHistory.modalActivated return useStatusHistoryStore().modalActivated
}, },
params () { params () {
return this.$store.state.statusHistory.params return useStatusHistoryStore().params
}, },
statusId () { statusId () {
return this.params.id return this.params.id
@ -52,7 +53,7 @@ const StatusHistoryModal = {
}) })
}, },
closeModal () { closeModal () {
this.$store.dispatch('closeStatusHistoryModal') useStatusHistoryStore().closeStatusHistoryModal()
} }
} }
} }

View File

@ -18,7 +18,6 @@ import authFlowModule from './modules/auth_flow.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 statusHistoryModule from './modules/statusHistory.js'
import chatsModule from './modules/chats.js' import chatsModule from './modules/chats.js'
import announcementsModule from './modules/announcements.js' import announcementsModule from './modules/announcements.js'
@ -80,7 +79,6 @@ const persistedStateOptions = {
oauthTokens: oauthTokensModule, oauthTokens: oauthTokensModule,
reports: reportsModule, reports: reportsModule,
polls: pollsModule, polls: pollsModule,
statusHistory: statusHistoryModule,
chats: chatsModule, chats: chatsModule,
announcements: announcementsModule announcements: announcementsModule
}, },

View File

@ -1,25 +0,0 @@
const statusHistory = {
state: {
params: {},
modalActivated: false
},
mutations: {
openStatusHistoryModal (state, params) {
state.params = params
state.modalActivated = true
},
closeStatusHistoryModal (state) {
state.modalActivated = false
}
},
actions: {
openStatusHistoryModal ({ commit }, params) {
commit('openStatusHistoryModal', params)
},
closeStatusHistoryModal ({ commit }) {
commit('closeStatusHistoryModal')
}
}
}
export default statusHistory

View File

@ -0,0 +1,17 @@
import { defineStore } from 'pinia'
export const useStatusHistoryStore = defineStore('statusHistory', {
state: () => ({
params: {},
modalActivated: false
}),
actions: {
openStatusHistoryModal (params) {
this.params = params
this.modalActivated = true
},
closeStatusHistoryModal () {
this.modalActivated = false
}
}
})