Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move vuex store to a namespaced vuex store module
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Nov 16, 2022
commit 9c78a95a0007af54759da26a8be260e6e373e889
12 changes: 7 additions & 5 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ export default {
}
},
computed: {
...mapState(['showAuthorAnnotations']),
...mapState({
showAuthorAnnotations: (state) => state.text.showAuthorAnnotations,
}),
isRichWorkspace() {
return this.richWorkspace
},
Expand Down Expand Up @@ -326,9 +328,9 @@ export default {
this.close()
},
methods: {
...mapActions({
dispatchSetCurrentSession: 'setCurrentSession',
}),
...mapActions('text', [
'setCurrentSession',
]),

updateLastSavedStatus() {
if (this.document) {
Expand Down Expand Up @@ -478,7 +480,7 @@ export default {
this.readOnly = document.readOnly
this.lock = this.$syncService.lock
localStorage.setItem('nick', this.currentSession.guestName)
this.dispatchSetCurrentSession(this.currentSession)
this.setCurrentSession(this.currentSession)
this.$attachmentResolver = new AttachmentResolver({
session: this.currentSession,
user: getCurrentUser(),
Expand Down
10 changes: 5 additions & 5 deletions src/components/Editor/SessionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
},
computed: {
...mapState({
storeShowAuthorAnnotations: (state) => state.showAuthorAnnotations,
storeShowAuthorAnnotations: (state) => state.text.showAuthorAnnotations,
}),

label() {
Expand All @@ -104,7 +104,7 @@ export default {
return this.storeShowAuthorAnnotations
},
set(value) {
this.dispatchSetShowAuthorAnnotations(value)
this.setShowAuthorAnnotations(value)
},
},
participantsPopover() {
Expand Down Expand Up @@ -138,9 +138,9 @@ export default {
},

methods: {
...mapActions({
dispatchSetShowAuthorAnnotations: 'setShowAuthorAnnotations',
}),
...mapActions('text', [
'setShowAuthorAnnotations',
]),
},
}
</script>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/TableOfContents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default {
initialRender: true,
}),
computed: {
...mapState(['headings']),
...mapState({
headings: (state) => state.text.headings,
}),
},
mounted() {

Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/Wrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export default {
}),

computed: {
...mapState(['viewWidth']),
...mapState({
viewWidth: (state) => state.text.viewWidth,
}),

hasSyncCollission() {
return this.syncError && this.syncError.type === ERROR_TYPE.SAVE_COLLISSION
Expand Down
3 changes: 1 addition & 2 deletions src/nodes/Heading/extractor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

import store from '../../store/index.js'
import { slugify } from './slug.js'
import { v4 as uuidv4 } from 'uuid'

const setHeadings = (val) => store.dispatch('setHeadings', val)
const setHeadings = (val) => store.dispatch('text/setHeadings', val)

const extractHeadings = (editor) => {
const counter = new Map()
Expand Down
13 changes: 11 additions & 2 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const persistentStorage = getBuilder('text').persist().build()

Vue.use(Vuex)

const store = new Store({
plugins: [plugin],
const textModule = {
state: {
showAuthorAnnotations: persistentStorage.getItem('showAuthorAnnotations') === 'true',
currentSession: persistentStorage.getItem('currentSession'),
Expand Down Expand Up @@ -87,6 +86,16 @@ const store = new Store({
commit(SET_HEADINGS, value)
},
},
}

const store = new Store({
plugins: [plugin],
modules: {
text: {
namespaced: true,
...textModule,
},
},
})

export default store
2 changes: 1 addition & 1 deletion src/store/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const getClientWidth = () => document.documentElement.clientWidth

const plugin = ({ commit }) => {
const onResize = debounce(() => {
commit(SET_VIEW_WIDTH, getClientWidth())
commit(`text/${SET_VIEW_WIDTH}`, getClientWidth())
}, 100)

window.addEventListener('resize', onResize)
Expand Down