diff --git a/src/main/providers/imap.provider.ts b/src/main/providers/imap.provider.ts index c64316f..9e158ae 100644 --- a/src/main/providers/imap.provider.ts +++ b/src/main/providers/imap.provider.ts @@ -293,28 +293,26 @@ export class ImapProvider implements IEmailProvider { ): Promise { for (const folder of folders) { if (results.length >= limit) break + let lock: Awaited> | null = null try { - const lock = await this.client.getMailboxLock(folder.path) - try { - // OR SUBJECT FROM — быстрый поиск по заголовкам без загрузки тел - const uids = await this.client.search( - { or: [{ subject: query }, { from: query }] }, - { uid: true } - ) as number[] + lock = await this.client.getMailboxLock(folder.path) - if (uids?.length) { - const remaining = limit - results.length - const sorted = [...uids].sort((a, b) => b - a).slice(0, remaining) - for await (const msg of this.client.fetch(sorted.join(','), { - uid: true, envelope: true, flags: true, bodyStructure: true - }, { uid: true })) { - results.push(this.convertMessage(msg, folder.path)) - } + // TEXT ищет в заголовках + теле — работает на всех IMAP-серверах + const uids = await this.client.search({ text: query }, { uid: true }) as number[] + + if (uids?.length) { + const remaining = limit - results.length + const sorted = [...uids].sort((a, b) => b - a).slice(0, remaining) + for await (const msg of this.client.fetch(sorted.join(','), { + uid: true, envelope: true, flags: true, bodyStructure: true + }, { uid: true })) { + results.push(this.convertMessage(msg, folder.path)) } - } finally { - lock.release() } } catch { /* папка не поддерживает SEARCH или временно недоступна */ } + finally { + lock?.release() + } if (folder.folders?.length && results.length < limit) { await this.searchFolderTree(folder.folders, query, limit, results) diff --git a/src/renderer/src/components/messages/MessageList.vue b/src/renderer/src/components/messages/MessageList.vue index 9209d7a..4327670 100644 --- a/src/renderer/src/components/messages/MessageList.vue +++ b/src/renderer/src/components/messages/MessageList.vue @@ -26,11 +26,16 @@ let searchDebounce: ReturnType | null = null function openSearch(): void { searchOpen.value = true - nextTick(() => searchInputEl.value?.focus()) + // Фокус после того как анимация начнётся (иначе браузер скроллит до элемента) + setTimeout(() => { + searchInputEl.value?.removeAttribute('tabindex') + searchInputEl.value?.focus() + }, 60) } function closeSearch(): void { searchOpen.value = false + searchInputEl.value?.setAttribute('tabindex', '-1') messagesStore.clearSearch() } @@ -313,8 +318,9 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis