various small fixups
This commit is contained in:
parent
f910d87a23
commit
a2791a6717
4 changed files with 16 additions and 20 deletions
|
|
@ -15,7 +15,6 @@ import "package:nexus/controllers/rooms.dart";
|
||||||
import "package:nexus/controllers/space_edges.dart";
|
import "package:nexus/controllers/space_edges.dart";
|
||||||
import "package:nexus/controllers/sync_status.dart";
|
import "package:nexus/controllers/sync_status.dart";
|
||||||
import "package:nexus/controllers/top_level_spaces.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/helpers/extensions/gomuks_buffer.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
import "package:nexus/models/capabilities.dart";
|
import "package:nexus/models/capabilities.dart";
|
||||||
|
|
@ -345,10 +344,7 @@ class ClientController extends AsyncNotifier<int> {
|
||||||
Future<File> downloadMedia(DownloadMediaRequest request) async =>
|
Future<File> downloadMedia(DownloadMediaRequest request) async =>
|
||||||
.new((await _sendCommand("download_media", request.toJson()))["path"]);
|
.new((await _sendCommand("download_media", request.toJson()))["path"]);
|
||||||
|
|
||||||
Future<void> logout() async {
|
Future<void> logout() => _sendCommand("logout");
|
||||||
await ref.watch(UnifiedPushController.provider.notifier).deregister();
|
|
||||||
await _sendCommand("logout");
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> markRead(Room room) async {
|
Future<void> markRead(Room room) async {
|
||||||
final eventRowId = room.timeline[room.timeline.keys.reduce(max)];
|
final eventRowId = room.timeline[room.timeline.keys.reduce(max)];
|
||||||
|
|
|
||||||
|
|
@ -252,16 +252,14 @@ class SettingsSectionsController
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
return M3EButton.icon(
|
return M3EButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context)
|
await ref
|
||||||
.popUntil((route) => route.isFirst);
|
.watch(UnifiedPushController.provider.notifier)
|
||||||
Navigator.of(context)
|
.deregister()
|
||||||
.popUntil((route) => route.isFirst);
|
.onError(showError);
|
||||||
|
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
|
||||||
|
|
||||||
await ref
|
await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.watch(ClientController.provider.notifier)
|
||||||
.logout();
|
.logout()
|
||||||
|
.onError(showError);
|
||||||
},
|
},
|
||||||
label: Text(title),
|
label: Text(title),
|
||||||
icon: Icon(icon),
|
icon: Icon(icon),
|
||||||
|
|
|
||||||
|
|
@ -132,9 +132,8 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadyRegistered &&
|
if (!await UnifiedPush.tryUseCurrentOrDefaultDistributor()) {
|
||||||
!await UnifiedPush.tryUseCurrentOrDefaultDistributor()) {
|
throw Exception("No UnifiedPush distributors found.");
|
||||||
throw Exception("No UnifiedPush distributors found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await UnifiedPush.register(
|
await UnifiedPush.register(
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,11 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
|
||||||
ClientIdController.provider(url).future,
|
ClientIdController.provider(url).future,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
.onError(showError);
|
|
||||||
}
|
}
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
showError(error, stackTrace);
|
||||||
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +97,7 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
|
||||||
style: .new(color: theme.colorScheme.onErrorContainer),
|
style: .new(color: theme.colorScheme.onErrorContainer),
|
||||||
),
|
),
|
||||||
action: SnackBarAction(
|
action: SnackBarAction(
|
||||||
onPressed: () => tryLogin(newHomeserver!),
|
onPressed: () => tryLogin(newHomeserver!).onError(showError),
|
||||||
label: "Attempt log in anyways",
|
label: "Attempt log in anyways",
|
||||||
textColor: theme.colorScheme.onErrorContainer,
|
textColor: theme.colorScheme.onErrorContainer,
|
||||||
),
|
),
|
||||||
|
|
@ -103,11 +105,12 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
tryLogin(newUrl);
|
await tryLogin(newUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
showError(error, stackTrace);
|
showError(error, stackTrace);
|
||||||
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue