refactor(react/collections/table): use class-based API

This commit is contained in:
Elian Doran
2025-09-11 19:14:54 +03:00
parent efcdac75e4
commit 2b452a18df
3 changed files with 49 additions and 32 deletions

View File

@@ -324,6 +324,11 @@ export function useNoteLabel(note: FNote | undefined | null, labelName: string):
] as const;
}
export function useNoteLabelWithDefault(note: FNote | undefined | null, labelName: string, defaultValue: string): [string, (newValue: string | null | undefined) => void] {
const [ labelValue, setLabelValue ] = useNoteLabel(note, labelName);
return [ labelValue ?? defaultValue, setLabelValue];
}
export function useNoteLabelBoolean(note: FNote | undefined | null, labelName: string): [ boolean, (newValue: boolean) => void] {
const [ labelValue, setLabelValue ] = useState<boolean>(!!note?.hasLabel(labelName));