Skip to content

Commit

Permalink
chore: a little more bugfixing and move state back into main file, di…
Browse files Browse the repository at this point in the history
…dn't work if not

Signed-off-by: Grigory V <[email protected]>
  • Loading branch information
GVodyanov committed Sep 18, 2024
1 parent d3a44c0 commit f22aed6
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 107 deletions.
1 change: 1 addition & 0 deletions src/components/AppSettingsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ export default {
}
},
computed: {
...mapStores(useMainStore),
...mapState(useMainStore, ['accounts', 'isFollowUpFeatureAvailable']),
searchPriorityBody() {
return this.mainStore.getPreference('search-priority-body', 'false') === 'true'
Expand Down
5 changes: 3 additions & 2 deletions src/components/NewMessageModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ import DefaultComposerIcon from 'vue-material-design-icons/ArrowCollapse.vue'
import { deleteDraft, saveDraft, updateDraft } from '../service/DraftService.js'
import useOutboxStore from '../store/outboxStore.js'
import useMainStore from '../store/mainStore.js'
import { mapStores, mapState } from 'pinia'
import { mapStores, mapState, mapActions } from 'pinia'
export default {
name: 'NewMessageModal',
Expand Down Expand Up @@ -178,7 +178,8 @@ export default {
},
computed: {
...mapStores(useOutboxStore, useMainStore),
...mapState(useMainStore, ['showMessageComposer', 'getPreference']),
...mapState(useMainStore, ['showMessageComposer']),
...mapActions(useMainStore, ['getPreference']),
modalTitle() {
if (this.composerMessage.type === 'outbox') {
return t('mail', 'Edit message')
Expand Down
95 changes: 91 additions & 4 deletions src/store/mainStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,105 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import { defineStore } from 'pinia'
import mapStoreState from './mainStore/state.js'
import mapStoreGetters from './mainStore/getters.js'
import mapStoreActions from './mainStore/actions.js'
import { FOLLOW_UP_MAILBOX_ID, PRIORITY_INBOX_ID, UNIFIED_ACCOUNT_ID, UNIFIED_INBOX_ID } from './constants'

export default defineStore('main', {
state: mapStoreState(),
state: () => {
return {
isExpiredSession: false,
preferences: {},
accountsUnmapped: {
[UNIFIED_ACCOUNT_ID]: {
id: UNIFIED_ACCOUNT_ID,
accountId: UNIFIED_ACCOUNT_ID,
isUnified: true,
mailboxes: [PRIORITY_INBOX_ID, UNIFIED_INBOX_ID, FOLLOW_UP_MAILBOX_ID],
aliases: [],
collapsed: false,
emailAddress: '',
name: '',
showSubscribedOnly: false,
signatureAboveQuote: false,
},
},
accountList: [UNIFIED_ACCOUNT_ID],
allAccountSettings: [],
mailboxes: {
[UNIFIED_INBOX_ID]: {
id: UNIFIED_INBOX_ID,
databaseId: UNIFIED_INBOX_ID,
accountId: 0,
attributes: ['\\subscribed'],
isUnified: true,
path: '',
specialUse: ['inbox'],
specialRole: 'inbox',
unread: 0,
mailboxes: [],
envelopeLists: {},
name: 'UNIFIED INBOX',
},
[PRIORITY_INBOX_ID]: {
id: PRIORITY_INBOX_ID,
databaseId: PRIORITY_INBOX_ID,
accountId: 0,
attributes: ['\\subscribed'],
isPriorityInbox: true,
path: '',
specialUse: ['inbox'],
specialRole: 'inbox',
unread: 0,
mailboxes: [],
envelopeLists: {},
name: 'PRIORITY INBOX',
},
[FOLLOW_UP_MAILBOX_ID]: {
id: FOLLOW_UP_MAILBOX_ID,
databaseId: FOLLOW_UP_MAILBOX_ID,
accountId: 0,
attributes: ['\\subscribed'],
isUnified: true,
path: '',
specialUse: ['sent'],
specialRole: 'sent',
unread: 0,
mailboxes: [],
envelopeLists: {},
name: 'FOLLOW UP REMINDERS',
},
},
envelopes: {},
messages: {},
newMessage: undefined,
showMessageComposer: false,
composerMessageIsSaved: false,
composerSessionId: undefined,
nextComposerSessionId: 1,
autocompleteEntries: [],
tags: {},
tagList: [],
isScheduledSendingDisabled: false,
isSnoozeDisabled: false,
currentUserPrincipal: undefined,
googleOauthUrl: null,
masterPasswordEnabled: false,
sieveScript: {},
calendars: [],
smimeCertificates: [],
hasFetchedInitialEnvelopes: false,
followUpFeatureAvailable: false,
internalAddress: [],
hasCurrentUserPrincipalAndCollections: false,
showAccountSettings: null,
}
},
getters: {
...mapStoreGetters(),
},
actions: {
...mapStoreActions(),
},
});
})
4 changes: 2 additions & 2 deletions src/store/mainStore/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const addMailboxToState = curry((store, account, mailbox) => {
mailbox.mailboxes = []
Vue.set(mailbox, 'envelopeLists', {})

transformMailboxName(account, mailbox)
mainStoreActions().transformMailboxName(account, mailbox)

Vue.set(store.mailboxes, mailbox.databaseId, mailbox)
const parent = Object.values(store.mailboxes)
Expand Down Expand Up @@ -1823,7 +1823,7 @@ export default function mainStoreActions() {
},
savePreferenceMutation({
key,
value
value,
}) {
Vue.set(this.preferences, key, value)
},
Expand Down
5 changes: 1 addition & 4 deletions src/store/mainStore/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import toCalendar from '../../util/calendar.js'
export default function mainStore() {
return {
accounts: (state) => {
return state.accountList.map((id) => state.accounts[id])
return state.accountList.map((id) => state.accountsUnmapped[id])
},
composerMessage: (state) => {
return state.newMessage
Expand Down Expand Up @@ -60,9 +60,6 @@ export default function mainStore() {
getAppVersion: (state) => state.preferences?.version,

isOneLineLayout: (state) => state.list,
hasFetchedInitialEnvelopes: (state) => state.hasFetchedInitialEnvelopes,
isFollowUpFeatureAvailable: (state) => state.followUpFeatureAvailable,
getInternalAddresses: (state) => state.internalAddress?.filter(internalAddress => internalAddress !== undefined),
hasCurrentUserPrincipalAndCollections: (state) => state.hasCurrentUserPrincipalAndCollections,
}
}
95 changes: 0 additions & 95 deletions src/store/mainStore/state.js

This file was deleted.

0 comments on commit f22aed6

Please sign in to comment.