@@ -142,7 +142,7 @@ const addMailboxToState = curry((mailboxes, account, mailbox) => {
142
142
mailbox . mailboxes = [ ]
143
143
Vue . set ( mailbox , 'envelopeLists' , { } )
144
144
145
- mainStoreActions ( ) . transformMailboxName ( account , mailbox )
145
+ transformMailboxName ( account , mailbox )
146
146
147
147
Vue . set ( mailboxes , mailbox . databaseId , mailbox )
148
148
const parent = Object . values ( mailboxes )
@@ -155,6 +155,32 @@ const addMailboxToState = curry((mailboxes, account, mailbox) => {
155
155
}
156
156
} )
157
157
158
+ function transformMailboxName ( account , mailbox ) {
159
+ // Add all mailboxes (including submailboxes to state, but only toplevel to account
160
+ const nameWithoutPrefix = account . personalNamespace
161
+ ? mailbox . name . replace ( new RegExp ( escapeRegExp ( account . personalNamespace ) ) , '' )
162
+ : mailbox . name
163
+ if ( nameWithoutPrefix . includes ( mailbox . delimiter ) ) {
164
+ /**
165
+ * Sub-mailbox, e.g. 'Archive.2020' or 'INBOX.Archive.2020'
166
+ */
167
+ mailbox . displayName = mailbox . name . substring ( mailbox . name . lastIndexOf ( mailbox . delimiter ) + 1 )
168
+ mailbox . path = mailbox . name . substring ( 0 , mailbox . name . lastIndexOf ( mailbox . delimiter ) )
169
+ } else if ( account . personalNamespace && mailbox . name . startsWith ( account . personalNamespace ) ) {
170
+ /**
171
+ * Top-level mailbox, but with a personal namespace, e.g. 'INBOX.Sent'
172
+ */
173
+ mailbox . displayName = nameWithoutPrefix
174
+ mailbox . path = account . personalNamespace
175
+ } else {
176
+ /**
177
+ * Top-level mailbox, e.g. 'INBOX' or 'Draft'
178
+ */
179
+ mailbox . displayName = nameWithoutPrefix
180
+ mailbox . path = ''
181
+ }
182
+ }
183
+
158
184
export default function mainStoreActions ( ) {
159
185
return {
160
186
savePreference ( {
@@ -1754,32 +1780,6 @@ export default function mainStoreActions() {
1754
1780
await this . clearFollowUpReminder ( { envelope } )
1755
1781
}
1756
1782
} ,
1757
- transformMailboxName ( account , mailbox ) {
1758
- // Add all mailboxes (including submailboxes to state, but only toplevel to account
1759
- const nameWithoutPrefix = account . personalNamespace
1760
- ? mailbox . name . replace ( new RegExp ( escapeRegExp ( account . personalNamespace ) ) , '' )
1761
- : mailbox . name
1762
- if ( nameWithoutPrefix . includes ( mailbox . delimiter ) ) {
1763
- /**
1764
- * Sub-mailbox, e.g. 'Archive.2020' or 'INBOX.Archive.2020'
1765
- */
1766
- mailbox . displayName = mailbox . name . substring ( mailbox . name . lastIndexOf ( mailbox . delimiter ) + 1 )
1767
- mailbox . path = mailbox . name . substring ( 0 , mailbox . name . lastIndexOf ( mailbox . delimiter ) )
1768
- } else if ( account . personalNamespace && mailbox . name . startsWith ( account . personalNamespace ) ) {
1769
- /**
1770
- * Top-level mailbox, but with a personal namespace, e.g. 'INBOX.Sent'
1771
- */
1772
- mailbox . displayName = nameWithoutPrefix
1773
- mailbox . path = account . personalNamespace
1774
- } else {
1775
- /**
1776
- * Top-level mailbox, e.g. 'INBOX' or 'Draft'
1777
- */
1778
- mailbox . displayName = nameWithoutPrefix
1779
- mailbox . path = ''
1780
- }
1781
- } ,
1782
-
1783
1783
sortAccounts ( accounts ) {
1784
1784
accounts . sort ( ( a1 , a2 ) => a1 . order - a2 . order )
1785
1785
return accounts
@@ -1901,7 +1901,7 @@ export default function mainStoreActions() {
1901
1901
} ,
1902
1902
updateMailboxMutation ( { mailbox } ) {
1903
1903
const account = this . accountsUnmapped [ mailbox . accountId ]
1904
- this . transformMailboxName ( account , mailbox )
1904
+ transformMailboxName ( account , mailbox )
1905
1905
Vue . set ( this . mailboxes , mailbox . databaseId , mailbox )
1906
1906
} ,
1907
1907
removeMailboxMutation ( { id } ) {
0 commit comments