Отображать счётчик непрочитанных вместо общего числа писем
- Бейдж в заголовке списка теперь показывает unreadCount папки (скрывается, когда непрочитанных нет) - Бейджи папок в сайдбаре обновлены в стиле liquid glass (glass red pill) с hover/active состояниями - folders.store: добавлен updateFolderUnread(accountId, folderId, delta) - messages.store: счётчик обновляется при открытии письма, toggleRead, markSelectedAsRead, deleteOne, deleteSelected, mail:new Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4c5afdd3a4
commit
62f38673b0
4 changed files with 58 additions and 9 deletions
|
|
@ -136,13 +136,13 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
<div class="message-list-header">
|
<div class="message-list-header">
|
||||||
<h2 class="folder-title truncate">{{ folderName }}</h2>
|
<h2 class="folder-title truncate">{{ folderName }}</h2>
|
||||||
<button
|
<button
|
||||||
v-if="messagesStore.totalCount > 0"
|
v-if="(foldersStore.activeFolder?.unreadCount ?? 0) > 0"
|
||||||
class="message-count"
|
class="message-count"
|
||||||
:class="{ 'unread-active': messagesStore.unreadOnly }"
|
:class="{ 'unread-active': messagesStore.unreadOnly }"
|
||||||
title="Только непрочитанные"
|
title="Только непрочитанные"
|
||||||
@click="messagesStore.unreadOnly = !messagesStore.unreadOnly"
|
@click="messagesStore.unreadOnly = !messagesStore.unreadOnly"
|
||||||
>
|
>
|
||||||
{{ messagesStore.totalCount }}
|
{{ foldersStore.activeFolder?.unreadCount }}
|
||||||
</button>
|
</button>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button
|
<button
|
||||||
|
|
|
||||||
|
|
@ -158,12 +158,33 @@ function toggleExpand(event: Event): void {
|
||||||
.unread-badge {
|
.unread-badge {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #fff;
|
color: rgba(255, 255, 255, 0.92);
|
||||||
padding: 1px 5px;
|
padding: 0 6px;
|
||||||
|
min-height: 18px;
|
||||||
|
line-height: 18px;
|
||||||
border-radius: var(--radius-full);
|
border-radius: var(--radius-full);
|
||||||
background: var(--danger);
|
background: rgba(210, 45, 45, 0.55);
|
||||||
|
border: 1px solid rgba(255, 100, 100, 0.3);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 160, 160, 0.18),
|
||||||
|
0 1px 5px rgba(180, 30, 30, 0.3);
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
|
-webkit-backdrop-filter: blur(6px);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
min-width: 18px;
|
min-width: 18px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
transition: background var(--transition-fast), box-shadow var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-item:hover .unread-badge {
|
||||||
|
background: rgba(210, 45, 45, 0.7);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 160, 160, 0.22),
|
||||||
|
0 2px 8px rgba(180, 30, 30, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-item.active .unread-badge {
|
||||||
|
background: rgba(200, 40, 40, 0.65);
|
||||||
|
border-color: rgba(255, 100, 100, 0.4);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,13 @@ export const useFoldersStore = defineStore('folders', () => {
|
||||||
activeFolderId.value = folderId
|
activeFolderId.value = folderId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateFolderUnread(accountId: string, folderId: string, delta: number): void {
|
||||||
|
const tree = foldersByAccount.value[accountId]
|
||||||
|
if (!tree) return
|
||||||
|
const folder = findFolderById(tree, folderId)
|
||||||
|
if (folder) folder.unreadCount = Math.max(0, folder.unreadCount + delta)
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-load folders when active account changes
|
// Auto-load folders when active account changes
|
||||||
watch(
|
watch(
|
||||||
() => accountsStore.activeAccountId,
|
() => accountsStore.activeAccountId,
|
||||||
|
|
@ -72,7 +79,8 @@ export const useFoldersStore = defineStore('folders', () => {
|
||||||
activeFolder,
|
activeFolder,
|
||||||
loading,
|
loading,
|
||||||
loadFolders,
|
loadFolders,
|
||||||
setActiveFolder
|
setActiveFolder,
|
||||||
|
updateFolderUnread
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
flags: { seen: true }
|
flags: { seen: true }
|
||||||
})
|
})
|
||||||
msg.flags.seen = true
|
msg.flags.seen = true
|
||||||
|
foldersStore.updateFolderUnread(accountsStore.activeAccountId, foldersStore.activeFolderId, -1)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loadingBody.value = false
|
loadingBody.value = false
|
||||||
|
|
@ -177,6 +178,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
async function deleteSelected(): Promise<void> {
|
async function deleteSelected(): Promise<void> {
|
||||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId || selectedIds.value.size === 0) return
|
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId || selectedIds.value.size === 0) return
|
||||||
const ids = [...selectedIds.value]
|
const ids = [...selectedIds.value]
|
||||||
|
const unreadDelta = messages.value.filter((m) => selectedIds.value.has(m.id) && !m.flags.seen).length
|
||||||
await invoke('messages:delete', {
|
await invoke('messages:delete', {
|
||||||
accountId: accountsStore.activeAccountId,
|
accountId: accountsStore.activeAccountId,
|
||||||
folderId: foldersStore.activeFolderId,
|
folderId: foldersStore.activeFolderId,
|
||||||
|
|
@ -184,6 +186,9 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
})
|
})
|
||||||
messages.value = messages.value.filter((m) => !selectedIds.value.has(m.id))
|
messages.value = messages.value.filter((m) => !selectedIds.value.has(m.id))
|
||||||
totalCount.value = Math.max(0, totalCount.value - ids.length)
|
totalCount.value = Math.max(0, totalCount.value - ids.length)
|
||||||
|
if (unreadDelta > 0) {
|
||||||
|
foldersStore.updateFolderUnread(accountsStore.activeAccountId, foldersStore.activeFolderId, -unreadDelta)
|
||||||
|
}
|
||||||
if (selectedMessageId.value && selectedIds.value.has(selectedMessageId.value)) {
|
if (selectedMessageId.value && selectedIds.value.has(selectedMessageId.value)) {
|
||||||
clearSelection()
|
clearSelection()
|
||||||
}
|
}
|
||||||
|
|
@ -192,6 +197,8 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
|
|
||||||
async function deleteOne(messageId: string): Promise<void> {
|
async function deleteOne(messageId: string): Promise<void> {
|
||||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
||||||
|
const msg = messages.value.find((m) => m.id === messageId)
|
||||||
|
const wasUnread = msg && !msg.flags.seen
|
||||||
await invoke('messages:delete', {
|
await invoke('messages:delete', {
|
||||||
accountId: accountsStore.activeAccountId,
|
accountId: accountsStore.activeAccountId,
|
||||||
folderId: foldersStore.activeFolderId,
|
folderId: foldersStore.activeFolderId,
|
||||||
|
|
@ -199,6 +206,9 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
})
|
})
|
||||||
messages.value = messages.value.filter((m) => m.id !== messageId)
|
messages.value = messages.value.filter((m) => m.id !== messageId)
|
||||||
totalCount.value = Math.max(0, totalCount.value - 1)
|
totalCount.value = Math.max(0, totalCount.value - 1)
|
||||||
|
if (wasUnread) {
|
||||||
|
foldersStore.updateFolderUnread(accountsStore.activeAccountId, foldersStore.activeFolderId, -1)
|
||||||
|
}
|
||||||
if (selectedMessageId.value === messageId) clearSelection()
|
if (selectedMessageId.value === messageId) clearSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,6 +224,11 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
flags: { seen: newSeen }
|
flags: { seen: newSeen }
|
||||||
})
|
})
|
||||||
msg.flags.seen = newSeen
|
msg.flags.seen = newSeen
|
||||||
|
foldersStore.updateFolderUnread(
|
||||||
|
accountsStore.activeAccountId,
|
||||||
|
foldersStore.activeFolderId,
|
||||||
|
newSeen ? -1 : 1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleFlag(messageId: string): Promise<void> {
|
async function toggleFlag(messageId: string): Promise<void> {
|
||||||
|
|
@ -251,6 +266,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
async function markSelectedAsRead(): Promise<void> {
|
async function markSelectedAsRead(): Promise<void> {
|
||||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId || selectedIds.value.size === 0) return
|
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId || selectedIds.value.size === 0) return
|
||||||
const ids = [...selectedIds.value]
|
const ids = [...selectedIds.value]
|
||||||
|
const unreadDelta = messages.value.filter((m) => selectedIds.value.has(m.id) && !m.flags.seen).length
|
||||||
await invoke('messages:setFlags', {
|
await invoke('messages:setFlags', {
|
||||||
accountId: accountsStore.activeAccountId,
|
accountId: accountsStore.activeAccountId,
|
||||||
folderId: foldersStore.activeFolderId,
|
folderId: foldersStore.activeFolderId,
|
||||||
|
|
@ -258,9 +274,10 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
flags: { seen: true }
|
flags: { seen: true }
|
||||||
})
|
})
|
||||||
for (const msg of messages.value) {
|
for (const msg of messages.value) {
|
||||||
if (selectedIds.value.has(msg.id)) {
|
if (selectedIds.value.has(msg.id)) msg.flags.seen = true
|
||||||
msg.flags.seen = true
|
|
||||||
}
|
}
|
||||||
|
if (unreadDelta > 0) {
|
||||||
|
foldersStore.updateFolderUnread(accountsStore.activeAccountId, foldersStore.activeFolderId, -unreadDelta)
|
||||||
}
|
}
|
||||||
selectedIds.value = new Set()
|
selectedIds.value = new Set()
|
||||||
}
|
}
|
||||||
|
|
@ -289,6 +306,9 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
messages.value.unshift(data.envelope)
|
messages.value.unshift(data.envelope)
|
||||||
totalCount.value++
|
totalCount.value++
|
||||||
}
|
}
|
||||||
|
if (!data.envelope.flags.seen) {
|
||||||
|
foldersStore.updateFolderUnread(data.accountId, data.folderId, 1)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue