Files
Momento/memento-note/lib/notes-view-preference.ts
Antigravity e2672cd2c2
Some checks failed
CI / Lint, Test & Build (push) Failing after 1m19s
CI / Deploy production (on server) (push) Has been skipped
feat(notes): liens internes, onglet Réseau, living blocks et consentement IA
Rend les liens entre notes visibles et persistants (sync NoteLink au save, auto-save, graphe réseau rafraîchi), ajoute living blocks, Memory Echo, recherche globale, consentement IA explicite et consolide les prototypes design en architectural-grid.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-24 14:27:29 +00:00

32 lines
1.4 KiB
TypeScript

import type { NotesLayoutMode, NotesViewType } from '@/components/notes-list-views'
export const NOTES_LAYOUT_COOKIE = 'memento-notes-layout'
export const NOTES_VIEW_TYPE_COOKIE = 'memento-notes-view-type'
export const NOTES_LAYOUT_STORAGE_KEY = 'memento-notes-layout'
export const NOTES_VIEW_TYPE_STORAGE_KEY = 'memento-notes-view-type'
const LAYOUT_VALUES: NotesLayoutMode[] = ['grid', 'list', 'table']
const VIEW_TYPE_VALUES: NotesViewType[] = ['notes', 'tasks']
export function parseNotesLayoutMode(value: string | undefined | null): NotesLayoutMode {
if (value && (LAYOUT_VALUES as string[]).includes(value)) return value as NotesLayoutMode
return 'list'
}
export function parseNotesViewType(value: string | undefined | null): NotesViewType {
if (value && (VIEW_TYPE_VALUES as string[]).includes(value)) return value as NotesViewType
return 'notes'
}
export function setNotesLayoutPreference(layout: NotesLayoutMode) {
if (typeof window === 'undefined') return
localStorage.setItem(NOTES_LAYOUT_STORAGE_KEY, layout)
document.cookie = `${NOTES_LAYOUT_COOKIE}=${layout}; path=/; max-age=31536000; SameSite=Lax`
}
export function setNotesViewTypePreference(viewType: NotesViewType) {
if (typeof window === 'undefined') return
localStorage.setItem(NOTES_VIEW_TYPE_STORAGE_KEY, viewType)
document.cookie = `${NOTES_VIEW_TYPE_COOKIE}=${viewType}; path=/; max-age=31536000; SameSite=Lax`
}