it now uses extensible events to format the bio, as per msc4440
This commit is contained in:
5 files changed
+26
-14
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: note
|
||||
---
|
||||
|
||||
new/changed bios will now also be saved in the format MSC4440 expects
|
||||
@@ -44,7 +44,7 @@ type BioEditorProps = {
|
||||
value?: string | any;
|
||||
isSaving?: boolean;
|
||||
imagePackRooms?: any[];
|
||||
onSave: (htmlContent: string) => void;
|
||||
onSave: (htmlContent: string, plainText: string) => void;
|
||||
};
|
||||
|
||||
const BIO_LIMIT = 1024;
|
||||
@@ -81,7 +81,7 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor
|
||||
})
|
||||
);
|
||||
|
||||
onSave(customHtml || plainText);
|
||||
onSave(customHtml || plainText, plainText);
|
||||
setHasChanged(false);
|
||||
}, [editor, isMarkdown, onSave]);
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ import { useCapabilities } from '$hooks/useCapabilities';
|
||||
import { profilesCacheAtom } from '$state/userRoomProfile';
|
||||
import { SequenceCardStyle } from '$features/settings/styles.css';
|
||||
import { useUserPresence } from '$hooks/useUserPresence';
|
||||
import { MSC1767Text } from '$types/matrix/common';
|
||||
import { TimezoneEditor } from './TimezoneEditor';
|
||||
import { PronounEditor } from './PronounEditor';
|
||||
import { BioEditor } from './BioEditor';
|
||||
import { NameColorEditor } from './NameColorEditor';
|
||||
import { StatusEditor } from './StatusEditor';
|
||||
import { AnimalCosmetics } from './AnimalCosmetics';
|
||||
import { toPlainText } from '$components/editor';
|
||||
|
||||
type PronounSet = {
|
||||
summary: string;
|
||||
@@ -582,17 +582,20 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
|
||||
profile.extended?.['chat.commet.profile_bio'] ||
|
||||
profile.bio
|
||||
}
|
||||
onSave={(htmlBio) => {
|
||||
onSave={(htmlBio, plainTextBio) => {
|
||||
handleSaveField('moe.sable.app.bio', htmlBio);
|
||||
|
||||
// MSC4440
|
||||
handleSaveField('gay.fomx.biography', {
|
||||
body: htmlBio
|
||||
.replaceAll('<br>', '\n')
|
||||
.replaceAll('<li>', '\n- ')
|
||||
.replaceAll(/<[^>]*>/g, ''),
|
||||
format: 'org.matrix.custom.html',
|
||||
formatted_body: htmlBio,
|
||||
'm.text': [
|
||||
{
|
||||
body: htmlBio,
|
||||
mimetype: 'text/html',
|
||||
} satisfies MSC1767Text,
|
||||
{
|
||||
body: plainTextBio,
|
||||
} satisfies MSC1767Text,
|
||||
],
|
||||
} satisfies MSC4440Bio);
|
||||
|
||||
const cleanedHtml = htmlBio.replaceAll('<br/></blockquote>', '</blockquote>');
|
||||
|
||||
@@ -7,14 +7,13 @@ import colorMXID from '$utils/colorMXID';
|
||||
import { profilesCacheAtom } from '$state/userRoomProfile';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { MSC1767Text } from '$types/matrix/common';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
|
||||
const inFlightProfiles = new Map<string, Promise<any>>();
|
||||
|
||||
export type MSC4440Bio = {
|
||||
body: string;
|
||||
format: string;
|
||||
formatted_body: string;
|
||||
'm.text': Array<MSC1767Text>;
|
||||
};
|
||||
|
||||
export type UserProfile = {
|
||||
@@ -62,7 +61,7 @@ const normalizeInfo = (info: any): UserProfile => {
|
||||
pronouns: info['io.fsky.nyx.pronouns'],
|
||||
timezone: info['us.cloke.msc4175.tz'] || info['m.tz'],
|
||||
bio:
|
||||
(info['gay.fomx.biography'] satisfies MSC4440Bio).formatted_body ||
|
||||
(info['gay.fomx.biography'] satisfies MSC4440Bio)['m.text'][0].body ||
|
||||
info['moe.sable.app.bio'] ||
|
||||
info['chat.commet.profile_bio'],
|
||||
status: info['chat.commet.profile_status'],
|
||||
|
||||
@@ -14,6 +14,11 @@ export type IImageInfo = {
|
||||
[MATRIX_BLUR_HASH_PROPERTY_NAME]?: string;
|
||||
};
|
||||
|
||||
export type MSC1767Text = {
|
||||
body: string;
|
||||
mimetype?: string;
|
||||
};
|
||||
|
||||
export type IVideoInfo = {
|
||||
w?: number;
|
||||
h?: number;
|
||||
|
||||
Reference in new issue
Block a user