From 82c892c1d1f60c09dc9a1e3739e929c0903c489f Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 31 Mar 2026 04:28:33 +0200 Subject: [PATCH 1/6] updated bio key to match MSC4440 --- .../profile/matrix_profile_component.dart | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart index cbc3eee62..2edfc1694 100644 --- a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart +++ b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart @@ -142,25 +142,47 @@ class MatrixProfile @override Widget buildBio(BuildContext context, ThemeData theme, {String? overrideText}) { - Map? content = fields[MatrixProfileComponent.bioKey]; - - if (overrideText != null) { - content = MatrixProfileComponent.textToContent(overrideText, client); + // to be compatible with both the MSC version and commet's own version + List>? content = fields[MatrixProfileComponent.msc4440BioKey]['m.text']; + Map? commetBioContent = fields[MatrixProfileComponent.bioKey]; + + Map? htmlPart; + Map? textPart; + if (content == null && commetBioContent != null) { + if (commetBioContent["formatted_body"] != null && commetBioContent["format"] == "org.matrix.custom.html"){ + htmlPart = { + "body" : commetBioContent["formatted_body"], + "mimetype" : "text/html", + }; + } + if (commetBioContent["body"] != null){ + textPart = { + "body" : commetBioContent["body"], + }; + } + } else if (content is List){ + for (final item in content!) { + if(item['mimetype'] == "text/html"){ + htmlPart = item; + } else if (item['body'] != null) { + textPart = item; + } + } } - if (content == null) return Container(); + if (htmlPart == null && textPart == null) return Container(); - if (content["format"] == "org.matrix.custom.html") { + if (htmlPart != null) { return Material( color: Colors.transparent, - child: MatrixHtmlParser.parse(content["formatted_body"], client, null), + child: MatrixHtmlParser.parse(htmlPart["body"], client, null), ); } return Material( color: Colors.transparent, child: Text( - content["body"], + textPart?["body"], style: theme.textTheme.bodyMedium ?.copyWith(color: theme.colorScheme.onSurface), ), @@ -331,6 +353,7 @@ class MatrixProfileComponent implements UserProfileComponent { static const String bannerKey = "chat.commet.profile_banner"; static const String colorSchemeKey = "chat.commet.profile_color_scheme"; static const String bioKey = "chat.commet.profile_bio"; + static const String msc4440BioKey = "gay.fomx.biography"; static const String badgeKey = "chat.commet.profile_badges"; static const String statusKey = "chat.commet.profile_status"; static const String pronounsKey = "io.fsky.nyx.pronouns"; From 3da9fa748653a7b9ba7cdac7acbbc6a10dc1b63e Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 31 Mar 2026 04:43:45 +0200 Subject: [PATCH 2/6] fix(matrix profile): added back a previously, by mistake, removed line of code --- .../profile/matrix_profile_component.dart | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart index 2edfc1694..88e3ffdc4 100644 --- a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart +++ b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart @@ -143,26 +143,33 @@ class MatrixProfile Widget buildBio(BuildContext context, ThemeData theme, {String? overrideText}) { // to be compatible with both the MSC version and commet's own version - List>? content = fields[MatrixProfileComponent.msc4440BioKey]['m.text']; - Map? commetBioContent = fields[MatrixProfileComponent.bioKey]; - + List>? content = + fields[MatrixProfileComponent.msc4440BioKey]['m.text']; + Map? commetBioContent = + fields[MatrixProfileComponent.bioKey]; + if (overrideText != null) { + commetBioContent = + MatrixProfileComponent.textToContent(overrideText, client); + } + Map? htmlPart; Map? textPart; if (content == null && commetBioContent != null) { - if (commetBioContent["formatted_body"] != null && commetBioContent["format"] == "org.matrix.custom.html"){ + if (commetBioContent["formatted_body"] != null && + commetBioContent["format"] == "org.matrix.custom.html") { htmlPart = { - "body" : commetBioContent["formatted_body"], - "mimetype" : "text/html", + "body": commetBioContent["formatted_body"], + "mimetype": "text/html", }; } - if (commetBioContent["body"] != null){ + if (commetBioContent["body"] != null) { textPart = { - "body" : commetBioContent["body"], + "body": commetBioContent["body"], }; } - } else if (content is List){ + } else if (content is List) { for (final item in content!) { - if(item['mimetype'] == "text/html"){ + if (item['mimetype'] == "text/html") { htmlPart = item; } else if (item['body'] != null) { textPart = item; From f16f4c218902185945600b0599a8ffa531636add Mon Sep 17 00:00:00 2001 From: Yu <102911659+yu-meow@users.noreply.github.com> Date: Wed, 1 Apr 2026 22:21:52 +0200 Subject: [PATCH 3/6] fix(msc4440 bio): writing to profile field Co-authored-by: Rye --- .../profile/matrix_profile_component.dart | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart index 88e3ffdc4..141a1ebd1 100644 --- a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart +++ b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart @@ -197,10 +197,23 @@ class MatrixProfile } @override - bool get hasBio => fields.containsKey(MatrixProfileComponent.bioKey); + bool get hasBio => + fields.containsKey(MatrixProfileComponent.bioKey) || + fields.containsKey(MatrixProfileComponent.msc4440BioKey); @override - String? get plaintextBio => fields[MatrixProfileComponent.bioKey]?["body"]; + String? get plaintextBio { + var plainTextBodyCommet = fields[MatrixProfileComponent.bioKey]?["body"]; + List>? content = + fields[MatrixProfileComponent.msc4440BioKey]['m.text']; + + for (final item in content!) { + if (item['body'] != null && item['mimetype'] == null) { + return item['body']; + } + } + return plainTextBodyCommet; + } @override Future> getBadges() async { @@ -461,6 +474,27 @@ class MatrixProfileComponent implements UserProfileComponent { @override Future setBio(String bio) async { Map content = textToContent(bio, client); + + if (content['formatted_body'] != null && content['body'] != null) { + await setField(msc4440BioKey, { + 'm.text': [ + {'body': content['formatted_body'], 'mimetype': 'text/html'}, + {'body': content['body']} + ] + }); + } else if (content['formatted_body'] == null && content['body'] != null) { + await setField(msc4440BioKey, { + 'm.text': [ + {'body': content['body']} + ] + }); + } else if (content['formatted_body'] != null && content['body'] == null) { + await setField(msc4440BioKey, { + 'm.text': [ + {'body': content['formatted_body'], 'mimetype': 'text/html'}, + ] + }); + } await setField(bioKey, content); } @@ -488,6 +522,7 @@ class MatrixProfileComponent implements UserProfileComponent { @override Future removeBio() { + removeField(msc4440BioKey); return removeField(bioKey); } From 9b6b1ebf6ee96bd1a0095066386bf5445971aaed Mon Sep 17 00:00:00 2001 From: rooot Date: Sun, 12 Apr 2026 17:33:24 +0200 Subject: [PATCH 4/6] fix: biography crashing/erroring Signed-off-by: rooot --- .../components/profile/matrix_profile_component.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart index 141a1ebd1..92c5b1d11 100644 --- a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart +++ b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart @@ -143,8 +143,8 @@ class MatrixProfile Widget buildBio(BuildContext context, ThemeData theme, {String? overrideText}) { // to be compatible with both the MSC version and commet's own version - List>? content = - fields[MatrixProfileComponent.msc4440BioKey]['m.text']; + List? content = + fields[MatrixProfileComponent.msc4440BioKey]?['m.text']; Map? commetBioContent = fields[MatrixProfileComponent.bioKey]; if (overrideText != null) { @@ -168,7 +168,7 @@ class MatrixProfile }; } } else if (content is List) { - for (final item in content!) { + for (final item in content) { if (item['mimetype'] == "text/html") { htmlPart = item; } else if (item['body'] != null) { @@ -205,9 +205,10 @@ class MatrixProfile String? get plaintextBio { var plainTextBodyCommet = fields[MatrixProfileComponent.bioKey]?["body"]; List>? content = - fields[MatrixProfileComponent.msc4440BioKey]['m.text']; + fields[MatrixProfileComponent.msc4440BioKey]?['m.text']; - for (final item in content!) { + if (content == null) return plainTextBodyCommet; + for (final item in content) { if (item['body'] != null && item['mimetype'] == null) { return item['body']; } From e34088705005d42ecffcfc832d6484cf183cde67 Mon Sep 17 00:00:00 2001 From: rooot Date: Sun, 12 Apr 2026 17:37:45 +0200 Subject: [PATCH 5/6] fix: editing bio Signed-off-by: rooot --- .../matrix/components/profile/matrix_profile_component.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart index 92c5b1d11..e854d2770 100644 --- a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart +++ b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart @@ -204,7 +204,7 @@ class MatrixProfile @override String? get plaintextBio { var plainTextBodyCommet = fields[MatrixProfileComponent.bioKey]?["body"]; - List>? content = + List? content = fields[MatrixProfileComponent.msc4440BioKey]?['m.text']; if (content == null) return plainTextBodyCommet; From bbbbbaafaa32df369e7528f4716c535c3581a2cd Mon Sep 17 00:00:00 2001 From: rooot Date: Sun, 12 Apr 2026 17:42:05 +0200 Subject: [PATCH 6/6] fix(quirk): sable blockquote trailing newline Signed-off-by: rooot --- .../matrix/components/profile/matrix_profile_component.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart index e854d2770..79e322786 100644 --- a/commet/lib/client/matrix/components/profile/matrix_profile_component.dart +++ b/commet/lib/client/matrix/components/profile/matrix_profile_component.dart @@ -182,7 +182,7 @@ class MatrixProfile if (htmlPart != null) { return Material( color: Colors.transparent, - child: MatrixHtmlParser.parse(htmlPart["body"], client, null), + child: MatrixHtmlParser.parse((htmlPart["body"] as String).replaceAll("
", ""), client, null), ); }