Skip to content

Commit feac25f

Browse files
committed
chore: migrate dispatch and commit usages in components
Signed-off-by: Grigory V <[email protected]>
1 parent 5fb7128 commit feac25f

40 files changed

+281
-228
lines changed

Diff for: src/App.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export default {
4848
}
4949

5050
this.sync()
51-
await this.$store.dispatch('fetchCurrentUserPrincipal')
52-
await this.$store.dispatch('loadCollections')
53-
this.$store.commit('hasCurrentUserPrincipalAndCollections', true)
51+
await this.mainStore.fetchCurrentUserPrincipal()
52+
await this.mainStore.loadCollections()
53+
this.mainStore.hasCurrentUserPrincipalAndCollectionsMutation(true)
5454
},
5555
methods: {
5656
reload() {
@@ -59,7 +59,7 @@ export default {
5959
sync() {
6060
setTimeout(async () => {
6161
try {
62-
await this.$store.dispatch('syncInboxes')
62+
await this.mainStore.syncInboxes()
6363

6464
logger.debug("Inboxes sync'ed in background")
6565
} catch (error) {

Diff for: src/components/AccountDefaultsSettings.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default {
7474
logger.debug('setting drafts mailbox to ' + draftsMailboxId)
7575
this.saving = true
7676
try {
77-
await this.$store.dispatch('patchAccount', {
77+
await this.mainStore.patchAccount({
7878
account: this.account,
7979
data: {
8080
draftsMailboxId,
@@ -101,7 +101,7 @@ export default {
101101
logger.debug('setting sent mailbox to ' + sentMailboxId)
102102
this.saving = true
103103
try {
104-
await this.$store.dispatch('patchAccount', {
104+
await this.mainStore.patchAccount({
105105
account: this.account,
106106
data: {
107107
sentMailboxId,
@@ -128,7 +128,7 @@ export default {
128128
logger.debug('setting trash mailbox to ' + trashMailboxId)
129129
this.saving = true
130130
try {
131-
await this.$store.dispatch('patchAccount', {
131+
await this.mainStore.patchAccount({
132132
account: this.account,
133133
data: {
134134
trashMailboxId,
@@ -155,7 +155,7 @@ export default {
155155
logger.debug('setting archive mailbox to ' + archiveMailboxId)
156156
this.saving = true
157157
try {
158-
await this.$store.dispatch('patchAccount', {
158+
await this.mainStore.patchAccount({
159159
account: this.account,
160160
data: {
161161
archiveMailboxId,
@@ -182,7 +182,7 @@ export default {
182182
logger.debug('setting junk mailbox to ' + junkMailboxId)
183183
this.saving = true
184184
try {
185-
await this.$store.dispatch('patchAccount', {
185+
await this.mainStore.patchAccount({
186186
account: this.account,
187187
data: {
188188
junkMailboxId,
@@ -209,7 +209,7 @@ export default {
209209
logger.debug('setting snooze mailbox to ' + snoozeMailboxId)
210210
this.saving = true
211211
try {
212-
await this.$store.dispatch('patchAccount', {
212+
await this.mainStore.patchAccount({
213213
account: this.account,
214214
data: {
215215
snoozeMailboxId,

Diff for: src/components/AccountForm.vue

+9-7
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@
239239

240240
<script>
241241
import { Tab, Tabs } from 'vue-tabs-component'
242-
import { mapGetters } from 'vuex'
243242
import { NcButton as ButtonVue, NcLoadingIcon as IconLoading, NcPasswordField, NcInputField, NcCheckboxRadioSwitch } from '@nextcloud/vue'
244243
import IconCheck from 'vue-material-design-icons/Check.vue'
245244
import { translate as t } from '@nextcloud/l10n'
@@ -251,6 +250,8 @@ import {
251250
testConnectivity,
252251
} from '../service/AutoConfigService.js'
253252
import { CONSENT_ABORTED, getUserConsent } from '../integration/oauth.js'
253+
import useMainStore from '../store/mainStore.js'
254+
import { mapStores, mapState } from 'pinia'
254255

255256
export default {
256257
name: 'AccountForm',
@@ -314,7 +315,8 @@ export default {
314315
}
315316
},
316317
computed: {
317-
...mapGetters([
318+
...mapStores(useMainStore),
319+
...mapState(useMainStore, [
318320
'googleOauthUrl',
319321
'microsoftOauthUrl',
320322
]),
@@ -563,7 +565,7 @@ export default {
563565
delete data.smtpPassword
564566
}
565567
if (!this.account) {
566-
const account = await this.$store.dispatch('startAccountSetup', data)
568+
const account = await this.mainStore.startAccountSetup(data)
567569
if (this.useOauth) {
568570
this.loadingMessage = t('mail', 'Awaiting user consent')
569571
try {
@@ -584,18 +586,18 @@ export default {
584586
}
585587
} catch (e) {
586588
// Clean up the temporary account before we continue
587-
this.$store.dispatch('deleteAccount', account)
589+
this.mainStore.deleteAccount(account)
588590
logger.info(`Temporary account ${account.id} deleted`)
589591
throw e
590592
}
591593
this.clearFeedback()
592594
}
593595
this.loadingMessage = t('mail', 'Loading account')
594-
await this.$store.dispatch('finishAccountSetup', { account })
596+
await this.mainStore.finishAccountSetup({ account })
595597
this.$emit('account-created', account)
596598
} else {
597599
const oldAccountData = this.account
598-
const account = await this.$store.dispatch('updateAccount', {
600+
const account = await this.mainStore.updateAccount({
599601
...data,
600602
accountId: this.account.id,
601603
})
@@ -619,7 +621,7 @@ export default {
619621
}
620622
} catch (e) {
621623
// Undo changes
622-
await this.$store.dispatch('updateAccount', {
624+
await this.mainStore.updateAccount({
623625
...oldAccountData,
624626
accountId: oldAccountData.id,
625627
})

Diff for: src/components/AccountSettings.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ import CertificateSettings from './CertificateSettings.vue'
104104
import SearchSettings from './SearchSettings.vue'
105105
import TrashRetentionSettings from './TrashRetentionSettings.vue'
106106
import logger from '../logger.js'
107+
import useMainStore from '../store/mainStore.js'
108+
import { mapStores } from 'pinia'
107109

108110
export default {
109111
name: 'AccountSettings',
@@ -139,6 +141,7 @@ export default {
139141
}
140142
},
141143
computed: {
144+
...mapStores(useMainStore),
142145
displayName() {
143146
return this.account.name
144147
},
@@ -151,7 +154,7 @@ export default {
151154
if (newState === true && this.fetchActiveSieveScript === true) {
152155
logger.debug(`Load active sieve script for account ${this.account.accountId}`)
153156
this.fetchActiveSieveScript = false
154-
this.$store.dispatch('fetchActiveSieveScript', {
157+
this.mainStore.fetchActiveSieveScript({
155158
accountId: this.account.id,
156159
})
157160
}

Diff for: src/components/AliasSettings.vue

+6-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ import IconCheck from 'vue-material-design-icons/Check.vue'
8383
import IconRename from 'vue-material-design-icons/Pencil.vue'
8484
import logger from '../logger.js'
8585
import AliasForm from './AliasForm.vue'
86+
import useMainStore from '../store/mainStore.js'
87+
import { mapStores } from 'pinia'
8688

8789
export default {
8890
name: 'AliasSettings',
@@ -108,6 +110,7 @@ export default {
108110
}
109111
},
110112
computed: {
113+
...mapStores(useMainStore),
111114
aliases() {
112115
return this.account.aliases
113116
},
@@ -124,7 +127,7 @@ export default {
124127
async createAlias() {
125128
this.loading = true
126129

127-
await this.$store.dispatch('createAlias', {
130+
await this.mainStore.createAlias({
128131
account: this.account,
129132
alias: this.newAlias,
130133
name: this.newName,
@@ -147,7 +150,7 @@ export default {
147150

148151
async updateAlias(aliasId, newAlias) {
149152
const alias = this.aliases.find((alias) => alias.id === aliasId)
150-
await this.$store.dispatch('updateAlias', {
153+
await this.mainStore.updateAlias({
151154
account: this.account,
152155
aliasId: alias.id,
153156
alias: newAlias.alias,
@@ -156,7 +159,7 @@ export default {
156159
})
157160
},
158161
async deleteAlias(aliasId) {
159-
await this.$store.dispatch('deleteAlias', {
162+
await this.mainStore.deleteAlias({
160163
account: this.account,
161164
aliasId,
162165
})

Diff for: src/components/AppSettingsMenu.vue

+11-19
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ import SmimeCertificateModal from './smime/SmimeCertificateModal.vue'
312312
import TrustedSenders from './TrustedSenders.vue'
313313
import InternalAddress from './InternalAddress.vue'
314314
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile.js'
315-
import { mapGetters } from 'vuex'
316315
import useMainStore from '../store/mainStore.js'
317316
import { mapStores, mapState } from 'pinia'
318317

@@ -421,15 +420,15 @@ export default {
421420
this.showAccountSettings = false
422421
},
423422
openAccountSettings(accountId) {
424-
this.$store.commit('showSettingsForAccount', accountId)
423+
this.mainStore.showSettingsForAccountMutation(accountId)
425424
this.showSettings = false
426425
},
427426
checkMailvelope() {
428427
this.mailvelopeIsAvailable = !!window.mailvelope
429428
},
430429
async setLayout(layoutMode) {
431430
try {
432-
await this.$store.dispatch('savePreference', {
431+
await this.mainStore.savePreference({
433432
key: 'layout-mode',
434433
value: layoutMode,
435434
})
@@ -443,8 +442,7 @@ export default {
443442
onToggleButtonReplies(e) {
444443
this.loadingReplySettings = true
445444

446-
this.$store
447-
.dispatch('savePreference', {
445+
this.mainStore.savePreference({
448446
key: 'reply-mode',
449447
value: e.target.checked ? 'bottom' : 'top',
450448
})
@@ -456,8 +454,7 @@ export default {
456454
onToggleExternalAvatars(e) {
457455
this.loadingAvatarSettings = true
458456

459-
this.$store
460-
.dispatch('savePreference', {
457+
this.mainStore.savePreference({
461458
key: 'external-avatars',
462459
value: e.target.checked ? 'true' : 'false',
463460
})
@@ -469,8 +466,7 @@ export default {
469466
async onToggleSearchPriorityBody(e) {
470467
this.loadingPrioritySettings = true
471468
try {
472-
await this.$store
473-
.dispatch('savePreference', {
469+
await this.mainStore.savePreference({
474470
key: 'search-priority-body',
475471
value: e.target.checked ? 'true' : 'false',
476472
})
@@ -483,8 +479,7 @@ export default {
483479
onToggleCollectData(e) {
484480
this.loadingOptOutSettings = true
485481

486-
this.$store
487-
.dispatch('savePreference', {
482+
this.mainStore.savePreference({
488483
key: 'collect-data',
489484
value: e.target.checked ? 'true' : 'false',
490485
})
@@ -497,13 +492,11 @@ export default {
497492
const previousValue = this.sortOrder
498493
try {
499494
this.sortOrder = e
500-
await this.$store
501-
.dispatch('savePreference', {
495+
await this.mainStore.savePreference({
502496
key: 'sort-order',
503497
value: e,
504498
})
505-
this.$store.commit('removeAllEnvelopes')
506-
499+
this.mainStore.removeAllEnvelopesMutation()
507500
} catch (error) {
508501
Logger.error('could not save preferences', { error })
509502
this.sortOrder = previousValue
@@ -514,8 +507,7 @@ export default {
514507
this.toggleAutoTagging = true
515508

516509
try {
517-
await this.$store
518-
.dispatch('savePreference', {
510+
await this.mainStore.savePreference({
519511
key: 'tag-classified-messages',
520512
value: e.target.checked ? 'true' : 'false',
521513
})
@@ -529,7 +521,7 @@ export default {
529521
},
530522
async onToggleFollowUpReminders(e) {
531523
try {
532-
await this.$store.dispatch('savePreference', {
524+
await this.mainStore.savePreference({
533525
key: 'follow-up-reminders',
534526
value: e.target.checked ? 'true' : 'false',
535527
})
@@ -540,7 +532,7 @@ export default {
540532
},
541533
async onToggleInternalAddress(e) {
542534
try {
543-
await this.$store.dispatch('savePreference', {
535+
await this.mainStore.savePreference({
544536
key: 'internal-addresses',
545537
value: e.target.checked ? 'true' : 'false',
546538
})

Diff for: src/components/CertificateSettings.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
<script>
3737
import { NcSelect, NcButton, NcNoteCard } from '@nextcloud/vue'
3838
import { compareSmimeCertificates } from '../util/smime.js'
39-
import { mapGetters } from 'vuex'
4039
import { showError, showSuccess } from '@nextcloud/dialogs'
4140
import Logger from '../logger.js'
4241
import moment from '@nextcloud/moment'
42+
import useMainStore from '../store/mainStore.js'
43+
import { mapStores, mapState } from 'pinia'
4344

4445
export default {
4546
name: 'CertificateSettings',
@@ -61,7 +62,8 @@ export default {
6162
}
6263
},
6364
computed: {
64-
...mapGetters({
65+
...mapStores(useMainStore),
66+
...mapState(useMainState, {
6567
smimeCertificates: 'getSmimeCertificates',
6668
}),
6769
savedCertificate: {
@@ -133,7 +135,7 @@ export default {
133135
methods: {
134136
async updateSmimeCertificate() {
135137
if (this.alias.isAccountCertificate) {
136-
await this.$store.dispatch('updateAccountSmimeCertificate', {
138+
await this.mainStore.updateAccountSmimeCertificate({
137139
account: this.account,
138140
smimeCertificateId: this.certificate.id,
139141
}).then(() => {
@@ -144,7 +146,7 @@ export default {
144146
},
145147
)
146148
} else {
147-
await this.$store.dispatch('updateAlias', {
149+
await this.mainStore.updateAlias({
148150
account: this.account,
149151
aliasId: this.alias.id,
150152
alias: this.alias.alias,

Diff for: src/components/ComposerSessionIndicator.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
</template>
3939

4040
<script>
41-
import { mapGetters } from 'vuex'
4241
import { NcActions, NcActionButton } from '@nextcloud/vue'
4342
import PencilIcon from 'vue-material-design-icons/Pencil.vue'
4443
import ArrowExpandIcon from 'vue-material-design-icons/ArrowExpand.vue'
4544
import CloseIcon from 'vue-material-design-icons/Close.vue'
45+
import useMainStore from '../store/mainStore.js'
46+
import { mapStores, mapState } from 'pinia'
4647

4748
export default {
4849
name: 'ComposerSessionIndicator',
@@ -59,7 +60,8 @@ export default {
5960
}
6061
},
6162
computed: {
62-
...mapGetters(['composerMessage']),
63+
...mapStores(useMainStore),
64+
...mapState(useMainStore, ['composerMessage']),
6365
title() {
6466
return this.composerMessage?.data.subject || t('mail', 'Untitled message')
6567
},
@@ -73,7 +75,7 @@ export default {
7375
return
7476
}
7577

76-
await this.$store.dispatch('showMessageComposer')
78+
await this.mainStore.showMessageComposer()
7779
},
7880
onClose() {
7981
if (this.disabled) {

0 commit comments

Comments
 (0)