feat: message list density

Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
2026-06-23 21:34:02 -04:00
parent b419af09eb
commit 7e1a7679c8
3 changed files with 89 additions and 8 deletions
+34
View File
@@ -5,13 +5,34 @@ import { useUserStore } from '@KTXC'
const MESSAGE_READ_ENABLED_KEY = 'mail.behaviour.messageReadEnabled'
const MESSAGE_READ_DELAY_KEY = 'mail.behaviour.messageReadDelay'
const FOLDER_VIEW_MODE_KEY = 'mail.folderViewMode'
const MESSAGE_LIST_DENSITY_KEY = 'mail.messageListDensity'
const DEFAULT_MESSAGE_READ_ENABLED = false
const DEFAULT_MESSAGE_READ_DELAY = 5
const DEFAULT_FOLDER_VIEW_MODE = 'tree'
const DEFAULT_MESSAGE_LIST_DENSITY = 'cozy'
export type FolderViewMode = 'tree' | 'page'
export type MessageListDensity = 'compact' | 'cozy' | 'comfortable'
export const messageListDensityOptions = [
{ value: 'compact', title: 'Compact' },
{ value: 'cozy', title: 'Cozy' },
{ value: 'comfortable', title: 'Comfortable' },
]
export const messageListDensityConfig: Record<MessageListDensity, {
itemHeight: number
lines: 'one' | 'two' | 'three'
showSubjectLine: boolean
showThirdLine: boolean
}> = {
compact: { itemHeight: 56, lines: 'one', showSubjectLine: false, showThirdLine: false },
cozy: { itemHeight: 72, lines: 'two', showSubjectLine: true, showThirdLine: false },
comfortable: { itemHeight: 96, lines: 'three', showSubjectLine: true, showThirdLine: true },
}
export const messageReadDelayOptions = [
{ value: 2, title: '2 seconds' },
{ value: 5, title: '5 seconds' },
@@ -42,6 +63,10 @@ function normalizeFolderViewMode(value: unknown, fallback: FolderViewMode): Fold
return value === 'tree' || value === 'page' ? value : fallback
}
function normalizeMessageListDensity(value: unknown, fallback: MessageListDensity): MessageListDensity {
return value === 'compact' || value === 'cozy' || value === 'comfortable' ? value : fallback
}
export const useMailSettingsStore = defineStore('mailSettingsStore', () => {
const userStore = useUserStore()
@@ -66,8 +91,17 @@ export const useMailSettingsStore = defineStore('mailSettingsStore', () => {
),
})
const messageListDensity = computed({
get: () => normalizeMessageListDensity(userStore.getSetting(MESSAGE_LIST_DENSITY_KEY), DEFAULT_MESSAGE_LIST_DENSITY),
set: (value: MessageListDensity) => userStore.setSetting(
MESSAGE_LIST_DENSITY_KEY,
normalizeMessageListDensity(value, DEFAULT_MESSAGE_LIST_DENSITY),
),
})
return {
folderViewMode,
messageListDensity,
messageReadEnabled,
messageReadDelay,
}