Обновлять бейджи всех папок при нажатии кнопки обновить
Добавлен метод refreshUnreadCounts в folders.store — перезапрашивает IMAP STATUS для всех папок без смены активной папки. Вызывается параллельно с loadMessages при refresh(), чтобы виртуальные папки Gmail (Вся почта, Важное) тоже отражали актуальные счётчики. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8eb95afbc4
commit
6c288dcb3f
2 changed files with 12 additions and 1 deletions
|
|
@ -28,7 +28,10 @@ const allVisibleSelected = computed(() =>
|
|||
// ── Refresh ───────────────────────────────────────────────
|
||||
async function refresh(): Promise<void> {
|
||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
||||
await messagesStore.loadMessages(accountsStore.activeAccountId, foldersStore.activeFolderId, 0)
|
||||
await Promise.all([
|
||||
messagesStore.loadMessages(accountsStore.activeAccountId, foldersStore.activeFolderId, 0),
|
||||
foldersStore.refreshUnreadCounts(accountsStore.activeAccountId)
|
||||
])
|
||||
}
|
||||
|
||||
// ── Auto-check timer ──────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -66,6 +66,13 @@ export const useFoldersStore = defineStore('folders', () => {
|
|||
unreadCounts.value[`${accountId}:${folderId}`] = Math.max(0, count)
|
||||
}
|
||||
|
||||
async function refreshUnreadCounts(accountId: string): Promise<void> {
|
||||
const result = await invoke('folders:list', { accountId })
|
||||
foldersByAccount.value[accountId] = result.folders
|
||||
initUnreadCounts(accountId, result.folders)
|
||||
// activeFolderId не меняем
|
||||
}
|
||||
|
||||
function getFolderUnread(accountId: string, folderId: string): number {
|
||||
return unreadCounts.value[`${accountId}:${folderId}`] ?? 0
|
||||
}
|
||||
|
|
@ -99,6 +106,7 @@ export const useFoldersStore = defineStore('folders', () => {
|
|||
activeFolder,
|
||||
loading,
|
||||
loadFolders,
|
||||
refreshUnreadCounts,
|
||||
setActiveFolder,
|
||||
updateFolderUnread,
|
||||
setFolderUnread,
|
||||
|
|
|
|||
Loading…
Reference in a new issue