mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-28 02:18:01 -04:00
* more translation keys * added i18n keys for future ObjectKindEnum translation * more keys * added more keys * synced all new translation keys with all languages, translated keys on Belarusian and Russian * added translation for objectkinds in overview * added translation function for objectkinds * added more keys to german locale * renamed 'asc' and 'desc' keys * rolled back changes * added missed key * there are much more keys, than you can imagine * fixed misspelling * removed console.log * removed function "pluralize", added required plural words keys for each language * fixed condition, which could've lead to undefined value * hide filter description for boolean filters
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { useEffect, useRef, useState } from 'react';
|
|
import { useDebouncedCallback } from 'use-debounce';
|
|
import { Object as SDObject, useLibraryMutation } from '@sd/client';
|
|
import { Divider, TextArea } from '@sd/ui';
|
|
import { useLocale } from '~/hooks';
|
|
|
|
import { MetaContainer, MetaTitle } from '../Inspector';
|
|
|
|
interface Props {
|
|
data: SDObject;
|
|
}
|
|
|
|
export default function Note(props: Props) {
|
|
const setNote = useLibraryMutation('files.setNote');
|
|
|
|
const flush = useRef<() => void>();
|
|
const debouncedSetNote = useDebouncedCallback((note: string) => {
|
|
setNote.mutate({
|
|
id: props.data.id,
|
|
note
|
|
});
|
|
}, 500);
|
|
|
|
// Don't need to wrap in a arrow func because flush is not a method
|
|
flush.current = debouncedSetNote.flush;
|
|
|
|
// Force update when component unmounts
|
|
useEffect(() => () => flush.current?.(), []);
|
|
|
|
const [cachedNote, setCachedNote] = useState(props.data.note);
|
|
const { t } = useLocale();
|
|
|
|
return (
|
|
<>
|
|
<Divider />
|
|
<MetaContainer>
|
|
<MetaTitle>{t('note')}</MetaTitle>
|
|
<TextArea
|
|
className="mb-1 mt-2 !py-2 text-xs leading-snug"
|
|
value={cachedNote ?? ''}
|
|
onChange={(e) => {
|
|
setCachedNote(e.target.value);
|
|
debouncedSetNote(e.target.value);
|
|
}}
|
|
/>
|
|
</MetaContainer>
|
|
</>
|
|
);
|
|
}
|