|
|
@ -208,7 +208,7 @@ export const getMailboxCountAction = async (params = { opi_sn: '' }, update = tr
|
|
|
|
const ret = errcode !== 0 ? { [`${params.opi_sn}`]: {} } : { [`${params.opi_sn}`]: result }
|
|
|
|
const ret = errcode !== 0 ? { [`${params.opi_sn}`]: {} } : { [`${params.opi_sn}`]: result }
|
|
|
|
// 更新数量
|
|
|
|
// 更新数量
|
|
|
|
if (update !== false) {
|
|
|
|
if (update !== false) {
|
|
|
|
const readCacheDir = await readIndexDB(Number(params.opi_sn), 'dirs', 'mailbox');
|
|
|
|
const readCacheDir = (await readIndexDB(Number(params.opi_sn), 'dirs', 'mailbox')) || {};
|
|
|
|
const mailboxDir = isEmpty(readCacheDir) ? [] : readCacheDir.tree.filter(node => node?._raw?.IsTrue === 1);
|
|
|
|
const mailboxDir = isEmpty(readCacheDir) ? [] : readCacheDir.tree.filter(node => node?._raw?.IsTrue === 1);
|
|
|
|
const _MapDir = new Map(mailboxDir.map((obj) => [obj.key, obj]))
|
|
|
|
const _MapDir = new Map(mailboxDir.map((obj) => [obj.key, obj]))
|
|
|
|
Object.keys(result).map(dirKey => {
|
|
|
|
Object.keys(result).map(dirKey => {
|
|
|
@ -220,7 +220,7 @@ export const getMailboxCountAction = async (params = { opi_sn: '' }, update = tr
|
|
|
|
_MapRoot.set(row.key, row)
|
|
|
|
_MapRoot.set(row.key, row)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const _newRoot = Array.from(_MapRoot.values())
|
|
|
|
const _newRoot = Array.from(_MapRoot.values())
|
|
|
|
writeIndexDB([{ key: Number(params.opi_sn), tree: _newRoot }], 'dirs', 'mailbox')
|
|
|
|
writeIndexDB([{ ...readCacheDir, key: Number(params.opi_sn), tree: _newRoot }], 'dirs', 'mailbox')
|
|
|
|
notifyMailboxUpdate({ type: 'dirs', key: Number(params.opi_sn) })
|
|
|
|
notifyMailboxUpdate({ type: 'dirs', key: Number(params.opi_sn) })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -338,7 +338,7 @@ export const getRootMailboxDirAction = async ({ opi_sn = 0, userIdStr = '' } = {
|
|
|
|
const mailBoxCount = await Promise.all(userIdStr.split(',').map(_opi => getMailboxCountAction({ opi_sn: _opi }, false)));
|
|
|
|
const mailBoxCount = await Promise.all(userIdStr.split(',').map(_opi => getMailboxCountAction({ opi_sn: _opi }, false)));
|
|
|
|
const mailboxDirCountByOPI = mailBoxCount.reduce((a, c) => ({ ...a, ...c, }), {})
|
|
|
|
const mailboxDirCountByOPI = mailBoxCount.reduce((a, c) => ({ ...a, ...c, }), {})
|
|
|
|
const mailboxDirByOPI = mailboxDir.reduce((a, c) => ({ ...a, ...(Object.keys(c).reduce((a, opi) => ({...a, [opi]: c[`${opi}`].map((dir) => ({ ...dir, count: mailboxDirCountByOPI[opi][`${dir.key}`] })) }), {} )) }), {})
|
|
|
|
const mailboxDirByOPI = mailboxDir.reduce((a, c) => ({ ...a, ...(Object.keys(c).reduce((a, opi) => ({...a, [opi]: c[`${opi}`].map((dir) => ({ ...dir, count: mailboxDirCountByOPI[opi][`${dir.key}`] })) }), {} )) }), {})
|
|
|
|
const rootTree = Object.keys(stickyTree).map((opi) => ({ key: Number(opi), tree: [...stickyTree[opi], ...(mailboxDirByOPI?.[opi] || [])] }))
|
|
|
|
const rootTree = Object.keys(stickyTree).map((opi) => ({ key: Number(opi), tree: [...stickyTree[opi], ...(mailboxDirByOPI?.[opi] || [])], treeTimestamp: Date.now() }))
|
|
|
|
writeIndexDB(rootTree, 'dirs', 'mailbox')
|
|
|
|
writeIndexDB(rootTree, 'dirs', 'mailbox')
|
|
|
|
const _mapped = groupBy(rootTree, 'key')
|
|
|
|
const _mapped = groupBy(rootTree, 'key')
|
|
|
|
return _mapped[opi_sn]?.[0]?.tree || []
|
|
|
|
return _mapped[opi_sn]?.[0]?.tree || []
|
|
|
|