Skip to content

Commit 5e15118

Browse files
committed
[#35] do not use localStore in vuex-mutations
1 parent 6056299 commit 5e15118

20 files changed

+185
-101
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ For detailed explanation on how things work, check out [Nuxt.js docs](https://nu
6565
## Changelog
6666

6767
### 0.9.16
68+
* technical issue [#35](https://github.com/rainu/dev-notes/issues/35)
6869
* UX: redesign the new-note workflow
6970
* UX: redesign the backup view
7071

components/backup/aws/S3Import.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</template>
3232

3333
<script>
34-
import { mapMutations, mapGetters } from 'vuex';
34+
import { mapActions, mapGetters } from 'vuex';
3535
import S3 from 'aws-sdk/clients/s3'
3636
import { importAll } from "../../../common/importExport";
3737
import BackupUnlock from "../Unlock";
@@ -65,13 +65,13 @@
6565
}),
6666
},
6767
methods:{
68-
...mapMutations({
69-
clearNotes: 'note/clearNotes',
68+
...mapActions({
69+
setBoardOrder: 'board/setBoardOrder',
70+
addBoard: 'board/addBoard',
7071
clearBoards: 'board/clearBoards',
71-
addNote: 'note/addNote',
7272
setNoteOrder: 'note/setNoteOrder',
73-
addBoard: 'board/addBoard',
74-
setBoardOrder: 'board/setBoardOrder',
73+
addNote: 'note/addNote',
74+
clearNotes: 'note/clearNotes',
7575
}),
7676
onUploadFile(){
7777
this.uploadError = null

components/backup/dropbox/DropboxImport.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</template>
3232

3333
<script>
34-
import { mapMutations, mapGetters } from 'vuex';
34+
import { mapActions, mapGetters } from 'vuex';
3535
import { importAll } from "../../../common/importExport";
3636
import BackupUnlock from "../Unlock";
3737
import { Dropbox } from 'dropbox'
@@ -65,13 +65,13 @@
6565
}),
6666
},
6767
methods:{
68-
...mapMutations({
69-
clearNotes: 'note/clearNotes',
68+
...mapActions({
69+
setBoardOrder: 'board/setBoardOrder',
70+
addBoard: 'board/addBoard',
7071
clearBoards: 'board/clearBoards',
71-
addNote: 'note/addNote',
7272
setNoteOrder: 'note/setNoteOrder',
73-
addBoard: 'board/addBoard',
74-
setBoardOrder: 'board/setBoardOrder',
73+
addNote: 'note/addNote',
74+
clearNotes: 'note/clearNotes',
7575
}),
7676
onUploadFile(){
7777
this.downloadError = null

components/backup/file/FileImport.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</template>
2626

2727
<script>
28-
import { mapMutations } from 'vuex';
28+
import { mapActions } from 'vuex';
2929
import { importAll } from "../../../common/importExport";
3030
import BackupUnlock from "../Unlock";
3131
@@ -46,13 +46,13 @@
4646
}
4747
},
4848
methods:{
49-
...mapMutations({
50-
clearNotes: 'note/clearNotes',
49+
...mapActions({
50+
setBoardOrder: 'board/setBoardOrder',
51+
addBoard: 'board/addBoard',
5152
clearBoards: 'board/clearBoards',
52-
addNote: 'note/addNote',
5353
setNoteOrder: 'note/setNoteOrder',
54-
addBoard: 'board/addBoard',
55-
setBoardOrder: 'board/setBoardOrder',
54+
addNote: 'note/addNote',
55+
clearNotes: 'note/clearNotes',
5656
}),
5757
onUploadFile(){
5858
if(!this.$refs.fileInput.files[0]) return

components/backup/gist/GistImport.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</template>
3232

3333
<script>
34-
import { mapMutations, mapGetters } from 'vuex';
34+
import { mapActions, mapGetters } from 'vuex';
3535
import { importAll } from "../../../common/importExport";
3636
import BackupUnlock from "../Unlock";
3737
import { newGistClient } from '../../../common/gist'
@@ -65,13 +65,13 @@
6565
}),
6666
},
6767
methods:{
68-
...mapMutations({
69-
clearNotes: 'note/clearNotes',
68+
...mapActions({
69+
setBoardOrder: 'board/setBoardOrder',
70+
addBoard: 'board/addBoard',
7071
clearBoards: 'board/clearBoards',
71-
addNote: 'note/addNote',
7272
setNoteOrder: 'note/setNoteOrder',
73-
addBoard: 'board/addBoard',
74-
setBoardOrder: 'board/setBoardOrder',
73+
addNote: 'note/addNote',
74+
clearNotes: 'note/clearNotes',
7575
}),
7676
onUploadFile(){
7777
this.downloadError = null

components/backup/webdav/WebdavImport.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</template>
3232

3333
<script>
34-
import { mapMutations, mapGetters } from 'vuex';
34+
import { mapActions, mapGetters } from 'vuex';
3535
import { importAll } from "../../../common/importExport";
3636
import BackupUnlock from "../Unlock";
3737
import webdav from 'webdav'
@@ -65,13 +65,13 @@
6565
}),
6666
},
6767
methods:{
68-
...mapMutations({
69-
clearNotes: 'note/clearNotes',
68+
...mapActions({
69+
setBoardOrder: 'board/setBoardOrder',
70+
addBoard: 'board/addBoard',
7071
clearBoards: 'board/clearBoards',
71-
addNote: 'note/addNote',
7272
setNoteOrder: 'note/setNoteOrder',
73-
addBoard: 'board/addBoard',
74-
setBoardOrder: 'board/setBoardOrder',
73+
addNote: 'note/addNote',
74+
clearNotes: 'note/clearNotes',
7575
}),
7676
onUploadFile(){
7777
this.downloadError = null

components/note/OrderConfig.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
return this.$store.state.note.noteOrder
5757
},
5858
set(value) {
59-
this.$store.commit('note/setNoteOrder', value)
59+
this.$store.dispatch('note/setNoteOrder', value)
6060
}
6161
},
6262
noteMap(){

components/note/OverdueNotifications.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</template>
1616

1717
<script>
18-
import { mapGetters, mapMutations } from 'vuex';
18+
import { mapGetters, mapActions } from 'vuex';
1919
export default {
2020
name: "OverdueNotifications",
2121
computed: {
@@ -24,7 +24,7 @@ export default {
2424
}),
2525
},
2626
methods: {
27-
...mapMutations({
27+
...mapActions({
2828
removeAlarm: 'note/removeOverdueAlarm'
2929
}),
3030
}

components/settings/Board.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
</template>
119119

120120
<script>
121-
import { mapMutations, mapState } from 'vuex';
121+
import { mapActions, mapState } from 'vuex';
122122
import uuid4 from 'uuid4'
123123
import draggable from 'vuedraggable'
124124
import BoardForm from "../board/Form";
@@ -168,12 +168,12 @@
168168
return this.$store.state.board.boardOrder
169169
},
170170
set(value) {
171-
this.$store.commit('board/setBoardOrder', value)
171+
this.$store.dispatch('board/setBoardOrder', value)
172172
}
173173
}
174174
},
175175
methods: {
176-
...mapMutations({
176+
...mapActions({
177177
addBoard: 'board/addBoard',
178178
editBoard: 'board/editBoard',
179179
deleteBoard: 'board/deleteBoard',

components/settings/DateTime.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</template>
3131

3232
<script>
33-
import { mapMutations, mapState } from 'vuex';
33+
import { mapActions, mapState } from 'vuex';
3434
3535
export default {
3636
name: "SettingsDateTime",
@@ -63,7 +63,7 @@
6363
})
6464
},
6565
methods: {
66-
...mapMutations({
66+
...mapActions({
6767
setDateTimeFormat: 'settings/setDateTimeFormat',
6868
setDateFirstDay: 'settings/setDateFirstDay'
6969
}),

components/settings/Note.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</template>
3838

3939
<script>
40-
import { mapMutations, mapState } from 'vuex';
40+
import { mapActions, mapState } from 'vuex';
4141
import noteTypes from '../../components/note/types'
4242
4343
export default {
@@ -68,7 +68,7 @@
6868
}
6969
},
7070
methods: {
71-
...mapMutations({
71+
...mapActions({
7272
setNoteSize: 'settings/setNoteSize',
7373
setNoteDeleteHard: 'settings/setNoteDeleteHard',
7474
setNoteDefaultType: 'settings/setNoteDefaultType',

pages/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
</template>
126126

127127
<script>
128-
import { mapGetters, mapState, mapMutations } from 'vuex';
128+
import { mapGetters, mapState, mapActions } from 'vuex';
129129
import noteTypes from '../components/note/types'
130130
import Vue from 'vue'
131131
import copy from 'copy-to-clipboard';
@@ -254,7 +254,7 @@ export default {
254254
},
255255
},
256256
methods: {
257-
...mapMutations({
257+
...mapActions({
258258
deleteNote: 'note/deleteNote',
259259
deleteNoteSoft: 'note/deleteNoteSoft',
260260
}),

pages/notes/edit/_id.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</template>
2323

2424
<script>
25-
import { mapMutations } from 'vuex';
25+
import { mapActions } from 'vuex';
2626
2727
import NoteCardText from "../../../components/note/card/Text";
2828
import NoteCardPicture from "../../../components/note/card/Picture";
@@ -69,7 +69,7 @@ export default {
6969
},
7070
},
7171
methods: {
72-
...mapMutations({
72+
...mapActions({
7373
editNote: 'note/editNote',
7474
}),
7575
onAbort(){

pages/notes/new/_type.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</template>
3232

3333
<script>
34-
import { mapMutations } from 'vuex';
34+
import { mapActions } from 'vuex';
3535
import uuid4 from 'uuid4';
3636
3737
import NoteCardText from "../../../components/note/card/Text";
@@ -78,7 +78,7 @@ export default {
7878
},
7979
},
8080
methods: {
81-
...mapMutations({
81+
...mapActions({
8282
addNote: 'note/addNote',
8383
}),
8484
onAbort(){

pages/trash/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
</template>
106106

107107
<script>
108-
import { mapState, mapMutations } from 'vuex';
108+
import { mapState, mapActions } from 'vuex';
109109
import copy from 'copy-to-clipboard';
110110
import NoteCardText from "../../components/note/card/Text";
111111
import NoteCardPicture from "../../components/note/card/Picture";
@@ -150,7 +150,7 @@ export default {
150150
}),
151151
},
152152
methods: {
153-
...mapMutations({
153+
...mapActions({
154154
deleteNote: 'note/deleteNote',
155155
deleteAllNotes: 'note/clearDeletedNotes',
156156
restoreNote: 'note/restoreDeletedNote',

plugins/reminder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const checkOverdue = (store, env) => {
1414
requireInteraction: true,
1515
})
1616
activeNotifications[overdueNote.id].onclick = () => {
17-
store.commit('note/removeOverdueAlarm', overdueNote.id)
17+
store.dispatch('note/removeOverdueAlarm', overdueNote.id)
1818
delete activeNotifications[overdueNote.id]
1919
}
2020
}

store/board.js

+30-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const mutations = {
1717
}
1818

1919
state.boardOrder = order
20-
this.$localStore.setBoardOrder(state.boardOrder)
2120
},
2221
addBoard(state, board) {
2322
if(!board || !board.id || !board.title || !board.icon || !board.filter) {
@@ -27,8 +26,6 @@ export const mutations = {
2726

2827
state.boards.push(board)
2928
state.boardOrder.push(board.id)
30-
this.$localStore.setBoard(board)
31-
this.$localStore.setBoardOrder(state.boardOrder)
3229
},
3330
editBoard(state, board) {
3431
let index = state.boards.findIndex(r => r.id === board.id)
@@ -38,23 +35,17 @@ export const mutations = {
3835
}
3936

4037
Vue.set(state.boards, index, board)
41-
this.$localStore.setBoard(board)
4238
},
4339
deleteBoard(state, boardId) {
4440
let index = state.boards.findIndex(r => r.id === boardId)
4541
state.boards.splice(index, 1)
4642

4743
index = state.boardOrder.findIndex(bId => bId === boardId)
4844
state.boardOrder.splice(index, 1)
49-
50-
this.$localStore.removeBoard(boardId)
51-
this.$localStore.setBoardOrder(state.boardOrder)
5245
},
5346
clearBoards(state){
5447
state.boards = []
5548
state.boardOrder = []
56-
57-
this.$localStore.clearBoards()
5849
},
5950
}
6051

@@ -80,7 +71,36 @@ export const actions = {
8071
init(ctx) {
8172
return Promise.all([this.$localStore.getBoards(), this.$localStore.getBoardOrder()])
8273
.then(([boards, order]) => ctx.commit('loadBoards', {boards, order}))
83-
}
74+
},
75+
76+
setBoardOrder(ctx, order) {
77+
ctx.commit('setBoardOrder', order)
78+
return this.$localStore.setBoardOrder(ctx.state.boardOrder)
79+
},
80+
addBoard(ctx, board) {
81+
ctx.commit('addBoard', board)
82+
83+
return Promise.all([
84+
this.$localStore.setBoard(board),
85+
this.$localStore.setBoardOrder(ctx.state.boardOrder)
86+
])
87+
},
88+
editBoard(ctx, board) {
89+
ctx.commit('editBoard', board)
90+
return this.$localStore.setBoard(board)
91+
},
92+
deleteBoard(ctx, boardId) {
93+
ctx.commit('deleteBoard', boardId)
94+
95+
return Promise.all([
96+
this.$localStore.removeBoard(boardId),
97+
this.$localStore.setBoardOrder(ctx.state.boardOrder)
98+
])
99+
},
100+
clearBoards(ctx){
101+
ctx.commit('clearBoards')
102+
return this.$localStore.clearBoards()
103+
},
84104
}
85105

86106
export default {

0 commit comments

Comments
 (0)