feat: configurable message list width
Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
@@ -6,11 +6,13 @@ 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 MESSAGE_LIST_WIDTH_KEY = 'mail.messageListWidth'
|
||||
|
||||
const DEFAULT_MESSAGE_READ_ENABLED = false
|
||||
const DEFAULT_MESSAGE_READ_DELAY = 5
|
||||
const DEFAULT_FOLDER_VIEW_MODE = 'tree'
|
||||
const DEFAULT_MESSAGE_LIST_DENSITY = 'cozy'
|
||||
const DEFAULT_MESSAGE_LIST_WIDTH = 35
|
||||
|
||||
export type FolderViewMode = 'tree' | 'page'
|
||||
|
||||
@@ -33,6 +35,16 @@ export const messageListDensityConfig: Record<MessageListDensity, {
|
||||
comfortable: { itemHeight: 96, lines: 'three', showSubjectLine: true, showThirdLine: true },
|
||||
}
|
||||
|
||||
// Width of the message list panel, as a percentage of the split area. Only applies to
|
||||
// the side-by-side (vertical reading pane) view; future layout views own their own sizing.
|
||||
export type MessageListWidth = 25 | 35 | 50
|
||||
|
||||
export const messageListWidthOptions = [
|
||||
{ value: 25, title: 'Narrow' },
|
||||
{ value: 35, title: 'Medium' },
|
||||
{ value: 50, title: 'Wide' },
|
||||
]
|
||||
|
||||
export const messageReadDelayOptions = [
|
||||
{ value: 2, title: '2 seconds' },
|
||||
{ value: 5, title: '5 seconds' },
|
||||
@@ -67,6 +79,10 @@ function normalizeMessageListDensity(value: unknown, fallback: MessageListDensit
|
||||
return value === 'compact' || value === 'cozy' || value === 'comfortable' ? value : fallback
|
||||
}
|
||||
|
||||
function normalizeMessageListWidth(value: unknown, fallback: MessageListWidth): MessageListWidth {
|
||||
return value === 25 || value === 35 || value === 50 ? value : fallback
|
||||
}
|
||||
|
||||
export const useMailSettingsStore = defineStore('mailSettingsStore', () => {
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -99,9 +115,18 @@ export const useMailSettingsStore = defineStore('mailSettingsStore', () => {
|
||||
),
|
||||
})
|
||||
|
||||
const messageListWidth = computed({
|
||||
get: () => normalizeMessageListWidth(userStore.getSetting(MESSAGE_LIST_WIDTH_KEY), DEFAULT_MESSAGE_LIST_WIDTH),
|
||||
set: (value: MessageListWidth) => userStore.setSetting(
|
||||
MESSAGE_LIST_WIDTH_KEY,
|
||||
normalizeMessageListWidth(value, DEFAULT_MESSAGE_LIST_WIDTH),
|
||||
),
|
||||
})
|
||||
|
||||
return {
|
||||
folderViewMode,
|
||||
messageListDensity,
|
||||
messageListWidth,
|
||||
messageReadEnabled,
|
||||
messageReadDelay,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user