- RTL: force dir=rtl on LabelFilter, NotesViewToggle, LabelManagementDialog - i18n: add missing keys (notifications, privacy, edit/preview, AI translate/undo) - Settings pages: convert to Server Components (general, appearance) + loading skeleton - AI menu: add Translate option (10 languages) + Undo AI button in toolbar - Fix: saveInline uses REST API instead of Server Action → eliminates all implicit refreshes in list mode - Fix: NotesTabsView notes sync effect preserves selected note on content changes - Fix: auto-tag suggestions now filter already-assigned labels - Fix: color change in card view uses local state (no refresh) - Fix: nav links use <Link> for prefetching (Settings, Admin) - Fix: suppress duplicate label suggestions already on note - Route: add /api/ai/translate endpoint
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
'use client'
|
||
|
||
import { createContext, useContext, useMemo, useState, type ReactNode } from 'react'
|
||
|
||
export type HomeUiControls = {
|
||
isTabsMode: boolean
|
||
openNoteComposer: () => void
|
||
}
|
||
|
||
type Ctx = {
|
||
controls: HomeUiControls | null
|
||
setControls: (c: HomeUiControls | null) => void
|
||
}
|
||
|
||
const HomeViewContext = createContext<Ctx | null>(null)
|
||
|
||
export function HomeViewProvider({ children }: { children: ReactNode }) {
|
||
const [controls, setControls] = useState<HomeUiControls | null>(null)
|
||
const value = useMemo(() => ({ controls, setControls }), [controls])
|
||
|
||
return <HomeViewContext.Provider value={value}>{children}</HomeViewContext.Provider>
|
||
}
|
||
|
||
/** Enregistré par la page d’accueil ; la sidebar lit `controls` */
|
||
export function useHomeView() {
|
||
const ctx = useContext(HomeViewContext)
|
||
if (!ctx) {
|
||
throw new Error('useHomeView must be used within HomeViewProvider')
|
||
}
|
||
return ctx
|
||
}
|
||
|
||
/** Sidebar / shells : ne pas planter si hors provider */
|
||
export function useHomeViewOptional(): Ctx | null {
|
||
return useContext(HomeViewContext)
|
||
}
|