.
This commit is contained in:
parent
121cc3dd9a
commit
2a1d56a034
4 changed files with 36 additions and 10 deletions
12
README.md
12
README.md
|
|
@ -125,12 +125,12 @@ src/
|
||||||
```
|
```
|
||||||
┌─────────────────────────────────────────────────────┐
|
┌─────────────────────────────────────────────────────┐
|
||||||
│ Main Process (Node.js) │
|
│ Main Process (Node.js) │
|
||||||
│ ┌─────────────────┐ ┌────────────────────────┐ │
|
│ ┌─────────────────┐ ┌────────────────────────┐ │
|
||||||
│ │ AccountManager │ │ IPC Handlers │ │
|
│ │ AccountManager │ │ IPC Handlers │ │
|
||||||
│ │ providers Map │ │ accounts/folders/ │ │
|
│ │ providers Map │ │ accounts/folders/ │ │
|
||||||
│ │ ImapProvider │ │ messages handlers │ │
|
│ │ ImapProvider │ │ messages handlers │ │
|
||||||
│ └────────┬────────┘ └───────────┬────────────┘ │
|
│ └────────┬────────┘ └───────────┬────────────┘ │
|
||||||
└───────────┼───────────────────────┼────────────────┘
|
└───────────┼───────────────────────┼─────────────────┘
|
||||||
│ IMAP/SMTP │ ipcMain.handle / webContents.send
|
│ IMAP/SMTP │ ipcMain.handle / webContents.send
|
||||||
▼ ▼
|
▼ ▼
|
||||||
Mail server ┌───────────────┐
|
Mail server ┌───────────────┐
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import { useFoldersStore } from './folders.store'
|
||||||
|
import type { Folder } from '@shared/types/folder'
|
||||||
|
|
||||||
const STORAGE_KEY = 'muted-folders'
|
const STORAGE_KEY = 'muted-folders'
|
||||||
|
|
||||||
|
|
@ -20,18 +22,42 @@ export const useNotificationsStore = defineStore('notifications', () => {
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(mutedFolders.value))
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(mutedFolders.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMuted(accountId: string, folderId: string): boolean {
|
function isFolderKeyMuted(accountId: string, folderId: string): boolean {
|
||||||
const key = `${accountId}:${folderId}`
|
const key = `${accountId}:${folderId}`
|
||||||
const expiry = mutedFolders.value[key]
|
const expiry = mutedFolders.value[key]
|
||||||
if (expiry === undefined) return false
|
if (expiry === undefined) return false
|
||||||
if (expiry === null) return true // forever
|
if (expiry === null) return true
|
||||||
if (Date.now() < expiry) return true // not yet expired
|
if (Date.now() < expiry) return true
|
||||||
// Expired — clean up lazily
|
// Expired — clean up lazily
|
||||||
delete mutedFolders.value[key]
|
delete mutedFolders.value[key]
|
||||||
persist()
|
persist()
|
||||||
return false
|
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 {
|
function muteFolder(accountId: string, folderId: string, durationMs: number | null): void {
|
||||||
const key = `${accountId}:${folderId}`
|
const key = `${accountId}:${folderId}`
|
||||||
mutedFolders.value[key] = durationMs === null ? null : Date.now() + durationMs
|
mutedFolders.value[key] = durationMs === null ? null : Date.now() + durationMs
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||||
const swipeLeftAction = ref<SwipeAction>(saved.swipeLeftAction ?? 'delete')
|
const swipeLeftAction = ref<SwipeAction>(saved.swipeLeftAction ?? 'delete')
|
||||||
const swipeRightAction = ref<SwipeAction>(saved.swipeRightAction ?? 'toggleRead')
|
const swipeRightAction = ref<SwipeAction>(saved.swipeRightAction ?? 'toggleRead')
|
||||||
const accentColor = ref<string>(saved.accentColor ?? '#a8e600')
|
const accentColor = ref<string>(saved.accentColor ?? '#a8e600')
|
||||||
const autoCheckInterval = ref<number>(saved.autoCheckInterval ?? 5)
|
const autoCheckInterval = ref<number>(saved.autoCheckInterval ?? 1)
|
||||||
const uiScale = ref<number>(saved.uiScale ?? 1.0)
|
const uiScale = ref<number>(saved.uiScale ?? 1.0)
|
||||||
const downloadFolder = ref<string>(saved.downloadFolder ?? '')
|
const downloadFolder = ref<string>(saved.downloadFolder ?? '')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue