Пометить все сообщения в папке как прочитанные
All checks were successful
Release / release (push) Successful in 2m45s
All checks were successful
Release / release (push) Successful in 2m45s
This commit is contained in:
parent
6dc7dde3f2
commit
46227b27f6
8 changed files with 67 additions and 1 deletions
|
|
@ -88,6 +88,12 @@ export function registerMessageHandlers(manager: AccountManager): void {
|
||||||
await manager.deleteMessages(accountId, folderId, messageIds)
|
await manager.deleteMessages(accountId, folderId, messageIds)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
registerHandler('messages:markAllRead', async ({ accountId, folderId }) => {
|
||||||
|
assertId(accountId, 'accountId')
|
||||||
|
assertId(folderId, 'folderId')
|
||||||
|
await manager.markAllRead(accountId, folderId)
|
||||||
|
})
|
||||||
|
|
||||||
registerHandler('messages:attachment:download', async ({ accountId, folderId, messageId, attachmentId, filename, downloadFolder }) => {
|
registerHandler('messages:attachment:download', async ({ accountId, folderId, messageId, attachmentId, filename, downloadFolder }) => {
|
||||||
try {
|
try {
|
||||||
sendProgress(attachmentId, 'downloading', 10)
|
sendProgress(attachmentId, 'downloading', 10)
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,17 @@ export class ImapProvider implements IEmailProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async markAllRead(folderId: string): Promise<void> {
|
||||||
|
const lock = await this.client.getMailboxLock(folderId)
|
||||||
|
try {
|
||||||
|
const uids = await this.client.search({ seen: false }, { uid: true }) as number[]
|
||||||
|
if (!uids || uids.length === 0) return
|
||||||
|
await this.client.messageFlagsAdd(uids.join(','), ['\\Seen'], { uid: true })
|
||||||
|
} finally {
|
||||||
|
lock.release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async deleteMessages(folderId: string, messageIds: string[]): Promise<void> {
|
async deleteMessages(folderId: string, messageIds: string[]): Promise<void> {
|
||||||
const lock = await this.client.getMailboxLock(folderId)
|
const lock = await this.client.getMailboxLock(folderId)
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,12 @@ export class AccountManager {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async markAllRead(accountId: string, folderId: string): Promise<void> {
|
||||||
|
return this.withAutoReconnect(accountId, () =>
|
||||||
|
this.getProvider(accountId).markAllRead(folderId)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// ── Calendar ────────────────────────────────────────────
|
// ── Calendar ────────────────────────────────────────────
|
||||||
|
|
||||||
async listCalendars(accountId: string): Promise<CalendarInfo[]> {
|
async listCalendars(accountId: string): Promise<CalendarInfo[]> {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const emit = defineEmits<{
|
||||||
close: []
|
close: []
|
||||||
mute: [durationMs: number | null]
|
mute: [durationMs: number | null]
|
||||||
unmute: []
|
unmute: []
|
||||||
|
markAllRead: []
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const menuEl = ref<HTMLElement | null>(null)
|
const menuEl = ref<HTMLElement | null>(null)
|
||||||
|
|
@ -37,6 +38,10 @@ function handleUnmute(): void {
|
||||||
emit('unmute')
|
emit('unmute')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMarkAllRead(): void {
|
||||||
|
emit('markAllRead')
|
||||||
|
}
|
||||||
|
|
||||||
function onMouseDown(e: MouseEvent): void {
|
function onMouseDown(e: MouseEvent): void {
|
||||||
if (menuEl.value && !menuEl.value.contains(e.target as Node)) {
|
if (menuEl.value && !menuEl.value.contains(e.target as Node)) {
|
||||||
emit('close')
|
emit('close')
|
||||||
|
|
@ -70,6 +75,12 @@ onUnmounted(() => {
|
||||||
class="context-menu"
|
class="context-menu"
|
||||||
:style="{ left: menuX + 'px', top: menuY + 'px' }"
|
:style="{ left: menuX + 'px', top: menuY + 'px' }"
|
||||||
>
|
>
|
||||||
|
<button class="menu-item" @click="handleMarkAllRead">
|
||||||
|
Отметить всё как прочитанное
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="menu-divider" />
|
||||||
|
|
||||||
<!-- Unmute if already muted -->
|
<!-- Unmute if already muted -->
|
||||||
<button v-if="isMuted" class="menu-item" @click="handleUnmute">
|
<button v-if="isMuted" class="menu-item" @click="handleUnmute">
|
||||||
Включить уведомления
|
Включить уведомления
|
||||||
|
|
@ -152,6 +163,12 @@ onUnmounted(() => {
|
||||||
background: rgba(255, 255, 255, 0.05);
|
background: rgba(255, 255, 255, 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.menu-divider {
|
||||||
|
height: 1px;
|
||||||
|
margin: 4px 6px;
|
||||||
|
background: rgba(255, 255, 255, 0.10);
|
||||||
|
}
|
||||||
|
|
||||||
.menu-item-submenu {
|
.menu-item-submenu {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { SpecialFolderRole } from '@shared/types/folder'
|
||||||
import { useFoldersStore } from '../../stores/folders.store'
|
import { useFoldersStore } from '../../stores/folders.store'
|
||||||
import { useAccountsStore } from '../../stores/accounts.store'
|
import { useAccountsStore } from '../../stores/accounts.store'
|
||||||
import { useNotificationsStore } from '../../stores/notifications.store'
|
import { useNotificationsStore } from '../../stores/notifications.store'
|
||||||
|
import { useMessagesStore } from '../../stores/messages.store'
|
||||||
import AppIcon from '../AppIcon.vue'
|
import AppIcon from '../AppIcon.vue'
|
||||||
import type { IconName } from '../AppIcon.vue'
|
import type { IconName } from '../AppIcon.vue'
|
||||||
import FolderContextMenu from './FolderContextMenu.vue'
|
import FolderContextMenu from './FolderContextMenu.vue'
|
||||||
|
|
@ -17,6 +18,7 @@ const props = defineProps<{
|
||||||
const foldersStore = useFoldersStore()
|
const foldersStore = useFoldersStore()
|
||||||
const accountsStore = useAccountsStore()
|
const accountsStore = useAccountsStore()
|
||||||
const notificationsStore = useNotificationsStore()
|
const notificationsStore = useNotificationsStore()
|
||||||
|
const messagesStore = useMessagesStore()
|
||||||
const expanded = ref(true)
|
const expanded = ref(true)
|
||||||
const contextMenu = ref<{ x: number; y: number } | null>(null)
|
const contextMenu = ref<{ x: number; y: number } | null>(null)
|
||||||
|
|
||||||
|
|
@ -74,6 +76,13 @@ function handleUnmute(): void {
|
||||||
}
|
}
|
||||||
contextMenu.value = null
|
contextMenu.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMarkAllRead(): void {
|
||||||
|
if (accountsStore.activeAccountId) {
|
||||||
|
messagesStore.markAllRead(accountsStore.activeAccountId, props.folder.id)
|
||||||
|
}
|
||||||
|
contextMenu.value = null
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -114,6 +123,7 @@ function handleUnmute(): void {
|
||||||
@close="closeContextMenu"
|
@close="closeContextMenu"
|
||||||
@mute="handleMute"
|
@mute="handleMute"
|
||||||
@unmute="handleUnmute"
|
@unmute="handleUnmute"
|
||||||
|
@mark-all-read="handleMarkAllRead"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div v-if="hasChildren && expanded" class="folder-children">
|
<div v-if="hasChildren && expanded" class="folder-children">
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,16 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function markAllRead(accountId: string, folderId: string): Promise<void> {
|
||||||
|
await invoke('messages:markAllRead', { accountId, folderId })
|
||||||
|
if (accountsStore.activeAccountId === accountId && foldersStore.activeFolderId === folderId) {
|
||||||
|
for (const msg of messages.value) {
|
||||||
|
msg.flags.seen = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foldersStore.setFolderUnread(accountId, folderId, 0)
|
||||||
|
}
|
||||||
|
|
||||||
async function toggleFlag(messageId: string): Promise<void> {
|
async function toggleFlag(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 msg = messages.value.find((m) => m.id === messageId)
|
||||||
|
|
@ -428,6 +438,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
deleteOne,
|
deleteOne,
|
||||||
toggleRead,
|
toggleRead,
|
||||||
toggleFlag,
|
toggleFlag,
|
||||||
flagSelected
|
flagSelected,
|
||||||
|
markAllRead
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ export interface IpcChannelMap {
|
||||||
{ accountId: string; folderId: string; messageIds: string[] },
|
{ accountId: string; folderId: string; messageIds: string[] },
|
||||||
void
|
void
|
||||||
]
|
]
|
||||||
|
'messages:markAllRead': [
|
||||||
|
{ accountId: string; folderId: string },
|
||||||
|
void
|
||||||
|
]
|
||||||
'messages:attachment:download': [
|
'messages:attachment:download': [
|
||||||
{ accountId: string; folderId: string; messageId: string; attachmentId: string; filename: string; downloadFolder?: string },
|
{ accountId: string; folderId: string; messageId: string; attachmentId: string; filename: string; downloadFolder?: string },
|
||||||
{ success: boolean; savedPath?: string; error?: string }
|
{ success: boolean; savedPath?: string; error?: string }
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export interface IEmailProvider {
|
||||||
fetchMessageBody(folderId: string, messageId: string): Promise<MessageBody>
|
fetchMessageBody(folderId: string, messageId: string): Promise<MessageBody>
|
||||||
downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise<Buffer>
|
downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise<Buffer>
|
||||||
updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void>
|
updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void>
|
||||||
|
markAllRead(folderId: string): Promise<void>
|
||||||
deleteMessages(folderId: string, messageIds: string[]): Promise<void>
|
deleteMessages(folderId: string, messageIds: string[]): Promise<void>
|
||||||
onNewMail(callback: (folderId: string, envelope: MessageEnvelope) => void): void
|
onNewMail(callback: (folderId: string, envelope: MessageEnvelope) => void): void
|
||||||
offNewMail(): void
|
offNewMail(): void
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue