various small fixups

This commit is contained in:
Henry Hiles 2026-09-22 15:53:37 -04:00
commit a2791a6717
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
4 changed files with 16 additions and 20 deletions

View file

@ -15,7 +15,6 @@ import "package:nexus/controllers/rooms.dart";
import "package:nexus/controllers/space_edges.dart";
import "package:nexus/controllers/sync_status.dart";
import "package:nexus/controllers/top_level_spaces.dart";
import "package:nexus/controllers/unified_push.dart";
import "package:nexus/helpers/extensions/gomuks_buffer.dart";
import "package:nexus/main.dart";
import "package:nexus/models/capabilities.dart";
@ -345,10 +344,7 @@ class ClientController extends AsyncNotifier<int> {
Future<File> downloadMedia(DownloadMediaRequest request) async =>
.new((await _sendCommand("download_media", request.toJson()))["path"]);
Future<void> logout() async {
await ref.watch(UnifiedPushController.provider.notifier).deregister();
await _sendCommand("logout");
}
Future<void> logout() => _sendCommand("logout");
Future<void> markRead(Room room) async {
final eventRowId = room.timeline[room.timeline.keys.reduce(max)];

View file

@ -252,16 +252,14 @@ class SettingsSectionsController
final colorScheme = Theme.of(context).colorScheme;
return M3EButton.icon(
onPressed: () async {
Navigator.of(context)
.popUntil((route) => route.isFirst);
Navigator.of(context)
.popUntil((route) => route.isFirst);
await WidgetsBinding.instance.endOfFrame;
await ref
.watch(UnifiedPushController.provider.notifier)
.deregister()
.onError(showError);
await ref
.watch(ClientController.provider.notifier)
.logout();
.logout()
.onError(showError);
},
label: Text(title),
icon: Icon(icon),

View file

@ -132,9 +132,8 @@ class UnifiedPushController extends AsyncNotifier<bool> {
);
}
if (!alreadyRegistered &&
!await UnifiedPush.tryUseCurrentOrDefaultDistributor()) {
throw Exception("No UnifiedPush distributors found");
if (!await UnifiedPush.tryUseCurrentOrDefaultDistributor()) {
throw Exception("No UnifiedPush distributors found.");
}
await UnifiedPush.register(

View file

@ -78,9 +78,11 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
ClientIdController.provider(url).future,
),
),
)
.onError(showError);
);
}
} catch (error, stackTrace) {
showError(error, stackTrace);
rethrow;
} finally {
isLoading.value = false;
}
@ -95,7 +97,7 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
style: .new(color: theme.colorScheme.onErrorContainer),
),
action: SnackBarAction(
onPressed: () => tryLogin(newHomeserver!),
onPressed: () => tryLogin(newHomeserver!).onError(showError),
label: "Attempt log in anyways",
textColor: theme.colorScheme.onErrorContainer,
),
@ -103,11 +105,12 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
),
);
} else {
tryLogin(newUrl);
await tryLogin(newUrl);
}
}
} catch (error, stackTrace) {
showError(error, stackTrace);
rethrow;
} finally {
isLoading.value = false;
}