diff --git a/lib/controllers/settings_sections.dart b/lib/controllers/settings_sections.dart index 3c9a665..37e6284 100644 --- a/lib/controllers/settings_sections.dart +++ b/lib/controllers/settings_sections.dart @@ -130,7 +130,7 @@ class SettingsSectionsController .watch(ClientController.provider.notifier) .setAccountData( .new( - type: InvitePermissionConfig.key, + type: AccountData.invitePermissionConfigKey, content: InvitePermissionConfig( defaultAction: value, ), diff --git a/lib/models/account_data.dart b/lib/models/account_data.dart index 96ba6a7..7df7459 100644 --- a/lib/models/account_data.dart +++ b/lib/models/account_data.dart @@ -15,17 +15,21 @@ abstract class AccountData with _$AccountData { IList recentEmoji, ) => {"recent_emoji": recentEmoji.map((emoji) => emoji.toJson()).toList()}; + static const invitePermissionConfigKey = "m.invite_permission_config"; + static const directKey = "m.direct"; + static const recentEmojiKey = "m.recent_emoji"; + const factory AccountData({ - @JsonKey(name: InvitePermissionConfig.key) + @JsonKey(name: AccountData.invitePermissionConfigKey) @Default(InvitePermissionConfig()) InvitePermissionConfig invitePermissionConfig, - @JsonKey(name: "m.direct") + @JsonKey(name: AccountData.directKey) @Default(IMap.empty()) IMap> directMessages, @JsonKey( - name: "m.recent_emoji", + name: AccountData.recentEmojiKey, readValue: AccountData.readRecentEmojiValue, toJson: AccountData.recentEmojiToJson, ) @@ -39,8 +43,6 @@ abstract class AccountData with _$AccountData { @freezed abstract class InvitePermissionConfig with _$InvitePermissionConfig { - static const key = "m.invite_permission_config"; - const factory InvitePermissionConfig({ @JsonKey(unknownEnumValue: DefaultInviteAction.allow) @Default(DefaultInviteAction.allow) diff --git a/lib/pages/select_server.dart b/lib/pages/select_server.dart index f7cefb8..853e5fc 100644 --- a/lib/pages/select_server.dart +++ b/lib/pages/select_server.dart @@ -60,27 +60,32 @@ class SelectServerPage extends HookConsumerWidget { AppLinks().uriLinkStream.listen((encodedUri) async { final state = encodedUri.queryParameters["state"]; if (state != codeResponse.state) return; + isLoading.value = true; - final code = encodedUri.queryParameters["code"]; + try { + final code = encodedUri.queryParameters["code"]; - if (code != null) { - await ref - .watch(ClientController.provider.notifier) - .exchangeToken( - .new( - homeserverUrl: newUrl, - codeVerifier: codeResponse.codeVerifier, - redirectUri: .new( - scheme: "nexus.federated.nexus", - path: "/", + if (code != null) { + await ref + .watch(ClientController.provider.notifier) + .exchangeToken( + .new( + homeserverUrl: newUrl, + codeVerifier: codeResponse.codeVerifier, + redirectUri: .new( + scheme: "nexus.federated.nexus", + path: "/", + ), + code: code, + clientId: await ref.watch( + ClientIdController.provider(newUrl).future, + ), ), - code: code, - clientId: await ref.watch( - ClientIdController.provider(newUrl).future, - ), - ), - ) - .onError(showError); + ) + .onError(showError); + } + } finally { + isLoading.value = false; } }); } diff --git a/lib/widgets/room_appbar.dart b/lib/widgets/room_appbar.dart index 93eca85..69eafaa 100644 --- a/lib/widgets/room_appbar.dart +++ b/lib/widgets/room_appbar.dart @@ -40,48 +40,52 @@ class RoomAppbar extends ConsumerWidget implements PreferredSizeWidget { constraints: .loose(.fromWidth(400)), child: Padding( padding: .all(24), - child: Column( - mainAxisSize: .min, - crossAxisAlignment: .start, - spacing: 8, - children: [ - Row( - spacing: 12, - mainAxisSize: .min, - children: [ - if (room.metadata?.avatar != null) - ExpandableImage( - room.metadata?.avatar == null - ? null - : .new(mxc: room.metadata!.avatar!), - child: AvatarOrHash( - room.metadata?.avatar, + child: SingleChildScrollView( + child: Column( + mainAxisSize: .min, + crossAxisAlignment: .start, + spacing: 8, + children: [ + Row( + spacing: 12, + mainAxisSize: .min, + children: [ + if (room.metadata?.avatar != null) + ExpandableImage( + room.metadata?.avatar == null + ? null + : .new(mxc: room.metadata!.avatar!), + child: AvatarOrHash( + room.metadata?.avatar, + room.metadata?.name ?? "Unnamed Room", + height: 64, + fallback: Icon(Icons.numbers), + ), + ), + Expanded( + child: Text( room.metadata?.name ?? "Unnamed Room", - height: 64, - fallback: Icon(Icons.numbers), - ), - ), - Expanded( - child: Text( - room.metadata?.name ?? "Unnamed Room", - overflow: .ellipsis, - maxLines: 3, - style: Theme.of(context).textTheme.headlineSmall, - ), - ), - ], - ), - if (room.metadata?.topic?.isNotEmpty == true) - LinkifiedText( - room.metadata!.topic!, - style: Theme.of(context).textTheme.bodyLarge - ?.copyWith( - color: Theme.of( + overflow: .ellipsis, + maxLines: 3, + style: Theme.of( context, - ).colorScheme.onSurfaceVariant, + ).textTheme.headlineSmall, ), + ), + ], ), - ], + if (room.metadata?.topic?.isNotEmpty == true) + LinkifiedText( + room.metadata!.topic!, + style: Theme.of(context).textTheme.bodyLarge + ?.copyWith( + color: Theme.of( + context, + ).colorScheme.onSurfaceVariant, + ), + ), + ], + ), ), ), ),