All checks were successful
Release / release (push) Successful in 1m42s
Десктопный почтовый клиент для Linux на базе Electron + Vue 3. ## Почта - Поддержка любых IMAP/SMTP почтовых ящиков (Gmail, Яндекс, Mail.ru и др.) - Несколько аккаунтов одновременно - Треды — группировка писем по переписке - HTML-письма с безопасным рендерингом - Вложения: просмотр и скачивание - Ответ, пересылка, новое письмо в отдельном окне - Поиск по отправителю и теме - Свайп-жесты: удалить / прочитать / флаг ## Уведомления - Системные уведомления о новых письмах - Внутренние тосты - Заглушение папок (временное или постоянное) - Дедупликация — одно уведомление на письмо ## Интерфейс - Liquid glass UI в тёмной теме - Настраиваемый акцентный цвет и масштаб - Кастомные SVG-иконки ## Автообновление - Проверка обновлений через Forgejo Releases при запуске - Загрузка и установка AppImage без участия пользователя - Очистка устаревших .desktop-записей и обновление иконки при каждом запуске ## Прочее - Календарь (CalDAV) - Установка через AppImage без root Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import { ref } from 'vue'
|
|
import { defineStore } from 'pinia'
|
|
import { useFoldersStore } from './folders.store'
|
|
import type { Folder } from '@shared/types/folder'
|
|
|
|
const STORAGE_KEY = 'muted-folders'
|
|
|
|
export const useNotificationsStore = defineStore('notifications', () => {
|
|
// Record<"accountId:folderId", expiry timestamp ms | null (= forever)>
|
|
const mutedFolders = ref<Record<string, number | null>>(loadFromStorage())
|
|
|
|
function loadFromStorage(): Record<string, number | null> {
|
|
try {
|
|
const raw = localStorage.getItem(STORAGE_KEY)
|
|
return raw ? JSON.parse(raw) : {}
|
|
} catch {
|
|
return {}
|
|
}
|
|
}
|
|
|
|
function persist(): void {
|
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(mutedFolders.value))
|
|
}
|
|
|
|
function isFolderKeyMuted(accountId: string, folderId: string): boolean {
|
|
const key = `${accountId}:${folderId}`
|
|
const expiry = mutedFolders.value[key]
|
|
if (expiry === undefined) return false
|
|
if (expiry === null) return true
|
|
if (Date.now() < expiry) return true
|
|
// Expired — clean up lazily
|
|
delete mutedFolders.value[key]
|
|
persist()
|
|
return false
|
|
}
|
|
|
|
function findFolderById(folders: Folder[], id: string): Folder | null {
|
|
for (const f of folders) {
|
|
if (f.id === id) return f
|
|
if (f.children.length > 0) {
|
|
const found = findFolderById(f.children, id)
|
|
if (found) return found
|
|
}
|
|
}
|
|
return null
|
|
}
|
|
|
|
function isMuted(accountId: string, folderId: string): boolean {
|
|
const foldersStore = useFoldersStore()
|
|
const allFolders = foldersStore.foldersByAccount[accountId] ?? []
|
|
|
|
let currentId: string | null = folderId
|
|
while (currentId !== null) {
|
|
if (isFolderKeyMuted(accountId, currentId)) return true
|
|
const folder = findFolderById(allFolders, currentId)
|
|
currentId = folder?.parentId ?? null
|
|
}
|
|
return false
|
|
}
|
|
|
|
function muteFolder(accountId: string, folderId: string, durationMs: number | null): void {
|
|
const key = `${accountId}:${folderId}`
|
|
mutedFolders.value[key] = durationMs === null ? null : Date.now() + durationMs
|
|
persist()
|
|
}
|
|
|
|
function unmuteFolder(accountId: string, folderId: string): void {
|
|
const key = `${accountId}:${folderId}`
|
|
delete mutedFolders.value[key]
|
|
persist()
|
|
}
|
|
|
|
return { mutedFolders, isMuted, muteFolder, unmuteFolder }
|
|
})
|