mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
fix: removed bio limit
This commit is contained in:
1 parent
a64c28a7aa
commit
42e47cf558
2 files changed
+8
-24
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Removed the arbitrary bio limit from the bio editor.
|
||||
@@ -39,8 +39,6 @@ type BioEditorProps = {
|
||||
onSave: (htmlContent: string, plainText: string) => void;
|
||||
};
|
||||
|
||||
const BIO_LIMIT = 1024;
|
||||
|
||||
export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditorProps) {
|
||||
const editor = useEditor();
|
||||
const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
@@ -48,19 +46,12 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
const [autocompleteQuery, setAutocompleteQuery] =
|
||||
useState<AutocompleteQuery<AutocompletePrefix>>();
|
||||
const [hasChanged, setHasChanged] = useState(false);
|
||||
const [charCount, setCharCount] = useState(0);
|
||||
|
||||
const prevValue = useRef(value);
|
||||
const initialized = useRef(false);
|
||||
|
||||
const updateStats = useCallback(() => {
|
||||
const plainText = toPlainText(editor.children).trim();
|
||||
setCharCount(plainText.length);
|
||||
}, [editor]);
|
||||
|
||||
const handleSave = useCallback(() => {
|
||||
const plainText = toPlainText(editor.children).trim();
|
||||
if (plainText.length > BIO_LIMIT) return;
|
||||
|
||||
const customHtml = trimCustomHtml(toMatrixCustomHTML(editor.children, {}));
|
||||
|
||||
@@ -104,9 +95,8 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
|
||||
initialized.current = true;
|
||||
setHasChanged(false);
|
||||
updateStats();
|
||||
}
|
||||
}, [value, editor, updateStats]);
|
||||
}, [value, editor]);
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler = useCallback(
|
||||
(evt) => {
|
||||
@@ -142,11 +132,8 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
editor.insertNode(createEmoticonElement(key, shortcode));
|
||||
moveCursor(editor);
|
||||
setHasChanged(true);
|
||||
updateStats();
|
||||
};
|
||||
|
||||
const isOverLimit = charCount > BIO_LIMIT;
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
<SettingTile title="About You" focusId="about-you" description="Customize your bio." />
|
||||
@@ -164,7 +151,6 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
placeholder="Write a bio..."
|
||||
onChange={() => {
|
||||
if (!hasChanged) setHasChanged(true);
|
||||
updateStats();
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
onKeyUp={handleKeyUp}
|
||||
@@ -183,9 +169,9 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
{hasChanged && (
|
||||
<Chip
|
||||
onClick={handleSave}
|
||||
variant={isOverLimit ? 'Background' : 'Primary'}
|
||||
variant="Primary"
|
||||
radii="Pill"
|
||||
disabled={isSaving || isOverLimit}
|
||||
disabled={isSaving}
|
||||
outlined
|
||||
before={
|
||||
isSaving ? <Spinner variant="Primary" fill="Soft" size="100" /> : undefined
|
||||
@@ -194,13 +180,6 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
<Text size="B300">{isSaving ? 'Saving' : 'Save'}</Text>
|
||||
</Chip>
|
||||
)}
|
||||
<Text
|
||||
size="T200"
|
||||
priority={isOverLimit ? '500' : '300'}
|
||||
style={{ opacity: isOverLimit ? 1 : 0.6 }}
|
||||
>
|
||||
{charCount} / {BIO_LIMIT}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box gap="Inherit">
|
||||
<MarkdownFormattingToolbarToggle variant="Background" />
|
||||
|
||||
Reference in new issue
Block a user