Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-remove-bio-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Removed the arbitrary bio limit from the bio editor.
27 changes: 3 additions & 24 deletions src/app/features/settings/account/BioEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,19 @@ 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');

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, {}));

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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." />
Expand All @@ -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}
Expand All @@ -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
Expand All @@ -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" />
Expand Down
Loading