From ae5b6e2b402231b07cf0ad0930660c01888b2b22 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Wed, 5 Aug 2026 16:28:47 -0400 Subject: [PATCH] bump gomuks, fix profile issues caused by this --- .gitmodules | 2 +- gomuks | 2 +- lib/controllers/client.dart | 8 ++--- lib/controllers/profile.dart | 10 +++--- lib/controllers/user.dart | 7 ++-- lib/models/event.dart | 2 +- .../{profile.dart => profile_response.dart} | 36 ++++++++++++++----- lib/widgets/user_bottom_sheet.dart | 13 +++---- 8 files changed, 50 insertions(+), 30 deletions(-) rename lib/models/{profile.dart => profile_response.dart} (52%) diff --git a/.gitmodules b/.gitmodules index d7c8fca..145276a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "gomuks"] path = gomuks url = https://github.com/gomuks/gomuks - branch = timedoutuk/versions-rpc + branch = main diff --git a/gomuks b/gomuks index d382c66..2d566a2 160000 --- a/gomuks +++ b/gomuks @@ -1 +1 @@ -Subproject commit d382c664a04f3f202b86f859d1868fd4654a39e8 +Subproject commit 2d566a2b585e2dba882714f7ca741a52afb36237 diff --git a/lib/controllers/client.dart b/lib/controllers/client.dart index d0295ae..aa8c3ae 100644 --- a/lib/controllers/client.dart +++ b/lib/controllers/client.dart @@ -24,7 +24,7 @@ import "package:nexus/models/requests/get_event.dart"; import "package:nexus/models/requests/get_related_events.dart"; import "package:nexus/models/requests/get_room_state.dart"; import "package:nexus/models/requests/join_room.dart"; -import "package:nexus/models/profile.dart"; +import "package:nexus/models/profile_response.dart"; import "package:nexus/models/requests/oauth/exchange_token.dart"; import "package:nexus/models/requests/oauth/get_auth_url.dart"; import "package:nexus/models/requests/oauth/register_client.dart"; @@ -259,10 +259,8 @@ class ClientController extends AsyncNotifier { Future paginate(PaginateRequest request) async => .fromJson(await _sendCommand("paginate", request.toJson())); - Future getProfile(String userId) async { - final json = await _sendCommand("get_profile", {"user_id": userId}); - return .fromJsonWithCatch({...json, "id": userId}); - } + Future getProfile(String userId) async => + .fromJson(await _sendCommand("get_profile", {"user_id": userId})); Future reportEvent(ReportRequest request) => _sendCommand("report_event", request.toJson()); diff --git a/lib/controllers/profile.dart b/lib/controllers/profile.dart index 32525a3..58fa49d 100644 --- a/lib/controllers/profile.dart +++ b/lib/controllers/profile.dart @@ -1,17 +1,19 @@ import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:nexus/controllers/client.dart"; -import "package:nexus/models/profile.dart"; +import "package:nexus/models/profile_response.dart"; -class ProfileController extends AsyncNotifier { +class ProfileController extends AsyncNotifier { final String userId; ProfileController(this.userId); @override - Future build() { + Future build() { final client = ref.watch(ClientController.provider.notifier); return client.getProfile(userId); } static final provider = AsyncNotifierProvider.family - .autoDispose(ProfileController.new); + .autoDispose( + ProfileController.new, + ); } diff --git a/lib/controllers/user.dart b/lib/controllers/user.dart index b366c88..c69ebd0 100644 --- a/lib/controllers/user.dart +++ b/lib/controllers/user.dart @@ -27,14 +27,15 @@ class UserController extends AsyncNotifier { return content; } - final profile = await ref.watch( + final profileResponse = await ref.watch( ProfileController.provider(config.userId).future, ); return .new( status: .leave, - avatarUrl: profile.avatarUrl, - displayName: profile.displayName ?? config.userId.localpart, + avatarUrl: profileResponse.profile.avatarUrl, + displayName: + profileResponse.profile.displayName ?? config.userId.localpart, ); } diff --git a/lib/models/event.dart b/lib/models/event.dart index c54dbc5..a5913f7 100644 --- a/lib/models/event.dart +++ b/lib/models/event.dart @@ -2,7 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:freezed_annotation/freezed_annotation.dart"; import "package:nexus/models/content/content.dart"; import "package:nexus/models/epoch_date_time_converter.dart"; -import "package:nexus/models/profile.dart"; +import "package:nexus/models/profile_response.dart"; part "event.freezed.dart"; part "event.g.dart"; diff --git a/lib/models/profile.dart b/lib/models/profile_response.dart similarity index 52% rename from lib/models/profile.dart rename to lib/models/profile_response.dart index 6ae1e94..8b7b749 100644 --- a/lib/models/profile.dart +++ b/lib/models/profile_response.dart @@ -1,19 +1,37 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:freezed_annotation/freezed_annotation.dart"; import "package:nexus/models/content/membership.dart"; -part "profile.freezed.dart"; -part "profile.g.dart"; +part "profile_response.freezed.dart"; +part "profile_response.g.dart"; + +@freezed +abstract class ProfileResponse with _$ProfileResponse { + const factory ProfileResponse({ + @JsonKey(fromJson: Profile.fromJson) required Profile profile, + required Bio? bio, + }) = _ProfileResponse; + + factory ProfileResponse.fromJson(Map json) => + _$ProfileResponseFromJson(json); +} + +@freezed +abstract class Bio with _$Bio { + const factory Bio({required String html, String? editSource}) = _Bio; + + factory Bio.fromJson(Map json) => _$BioFromJson(json); +} @freezed abstract class Profile with _$Profile { - static Object? readPronouns(Map map, _) => - map["m.pronouns"] ?? map["io.fsky.nyx.pronouns"]; + static Object? readPronouns(Map map, String key) => + map[key] ?? map["io.fsky.nyx.pronouns"]; - static Object? readTimezone(Map map, _) => - map["m.tz"] ?? map["us.cloke.msc4175.tz"]; + static Object? readTimezone(Map map, String key) => + map[key] ?? map["us.cloke.msc4175.tz"]; const factory Profile({ - required String id, + String? id, String? parseError, Uri? avatarUrl, @@ -26,7 +44,7 @@ abstract class Profile with _$Profile { @JsonKey(readValue: Profile.readTimezone, name: "m.tz") String? timezone, @Default(IList.empty()) - @JsonKey(readValue: Profile.readPronouns, name: "io.fsky.nyx.pronouns") + @JsonKey(readValue: Profile.readPronouns, name: "m.pronouns") IList pronouns, }) = _Profile; @@ -37,7 +55,7 @@ abstract class Profile with _$Profile { try { return Profile.fromJson(json); } catch (error) { - return Profile(id: json["id"], parseError: error.toString()); + return Profile(parseError: error.toString()); } } } diff --git a/lib/widgets/user_bottom_sheet.dart b/lib/widgets/user_bottom_sheet.dart index 6f9f154..15a24a0 100644 --- a/lib/widgets/user_bottom_sheet.dart +++ b/lib/widgets/user_bottom_sheet.dart @@ -123,9 +123,10 @@ class UserBottomSheet extends ConsumerWidget { .watch(ProfileController.provider(userId)) .betterWhen( loading: () => Text(""), - data: (profile) => Column( + data: (profileResponse) => Column( children: [ - if (profile.timezone == null && profile.pronouns.isEmpty) + if (profileResponse.profile.timezone == null && + profileResponse.profile.pronouns.isEmpty) Text(""), Wrap( crossAxisAlignment: .center, @@ -133,7 +134,7 @@ class UserBottomSheet extends ConsumerWidget { spacing: 4, runSpacing: 4, children: [ - ...profile.pronouns + ...profileResponse.profile.pronouns .where( // TODO: Check system language (l10n) (pronoun) => pronoun.language == "en", @@ -157,8 +158,8 @@ class UserBottomSheet extends ConsumerWidget { ) .flattened, - if (profile.timezone != null) ...[ - if (profile.pronouns.isNotEmpty) + if (profileResponse.profile.timezone != null) ...[ + if (profileResponse.profile.pronouns.isNotEmpty) SizedBox( height: 16, child: VerticalDivider( @@ -168,7 +169,7 @@ class UserBottomSheet extends ConsumerWidget { ), ), Text( - profile.timezone!, + profileResponse.profile.timezone!, textAlign: .center, style: textTheme.titleSmall?.copyWith( color: theme.colorScheme.onSurfaceVariant,