don't require login for UP controller to finish init
This commit is contained in:
parent
f4142859ba
commit
f910d87a23
2 changed files with 47 additions and 56 deletions
|
|
@ -119,11 +119,8 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
||||||
Future<void> register([bool alreadyRegistered = false]) async {
|
Future<void> register([bool alreadyRegistered = false]) async {
|
||||||
state = .loading();
|
state = .loading();
|
||||||
try {
|
try {
|
||||||
final clientStateProvider = ClientStateController.provider;
|
final clientState = ref.watch(ClientStateController.provider);
|
||||||
while (ref.read(clientStateProvider)?.deviceId == null) {
|
if (clientState?.deviceId == null) return;
|
||||||
await Future.delayed(.new(milliseconds: 250));
|
|
||||||
}
|
|
||||||
final clientState = ref.read(clientStateProvider);
|
|
||||||
|
|
||||||
final capabilities = await ref
|
final capabilities = await ref
|
||||||
.read(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import "package:nexus/controllers/multi_provider.dart";
|
||||||
import "package:nexus/controllers/notification.dart";
|
import "package:nexus/controllers/notification.dart";
|
||||||
import "package:nexus/controllers/settings.dart";
|
import "package:nexus/controllers/settings.dart";
|
||||||
import "package:nexus/controllers/unified_push.dart";
|
import "package:nexus/controllers/unified_push.dart";
|
||||||
import "package:nexus/helpers/extensions/better_when.dart";
|
|
||||||
import "package:nexus/helpers/extensions/scheme_to_theme.dart";
|
import "package:nexus/helpers/extensions/scheme_to_theme.dart";
|
||||||
import "package:nexus/helpers/font_licenses.dart";
|
import "package:nexus/helpers/font_licenses.dart";
|
||||||
import "package:nexus/pages/chat.dart";
|
import "package:nexus/pages/chat.dart";
|
||||||
|
|
@ -150,60 +149,55 @@ class const App({super.key}) extends StatelessWidget {
|
||||||
),
|
),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Consumer(
|
body: Consumer(
|
||||||
builder: (_, ref, _) => ref
|
builder: (_, ref, _) => switch (ref.watch(
|
||||||
.watch(ClientController.provider)
|
MultiProviderController.provider(
|
||||||
.betterWhen(
|
.new([
|
||||||
data: (_) => switch (ref.watch(
|
ClientController.provider,
|
||||||
MultiProviderController.provider(
|
NotificationController.provider,
|
||||||
.new([
|
UnifiedPushController.provider,
|
||||||
NotificationController.provider,
|
MemberListOpenedController.provider,
|
||||||
UnifiedPushController.provider,
|
KeyController.provider(KeyController.roomKey),
|
||||||
MemberListOpenedController.provider,
|
KeyController.provider(KeyController.spaceKey),
|
||||||
KeyController.provider(KeyController.roomKey),
|
]),
|
||||||
KeyController.provider(KeyController.spaceKey),
|
),
|
||||||
]),
|
)) {
|
||||||
),
|
AsyncData(value: _) || AsyncLoading(value: _?) => Consumer(
|
||||||
)) {
|
builder: (_, ref, _) {
|
||||||
AsyncData(value: _) || AsyncLoading(value: _?) => Consumer(
|
final clientState = ref.watch(ClientStateController.provider);
|
||||||
builder: (_, ref, _) {
|
|
||||||
final clientState = ref.watch(
|
|
||||||
ClientStateController.provider,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (clientState == null || !clientState.isInitialized) {
|
if (clientState == null || !clientState.isInitialized) {
|
||||||
return Loading();
|
return Loading();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clientState.isLoggedIn) {
|
if (!clientState.isLoggedIn) {
|
||||||
return SelectServerPage();
|
return SelectServerPage();
|
||||||
} else if (!clientState.isVerified) {
|
} else if (!clientState.isVerified) {
|
||||||
return VerifyPage();
|
return VerifyPage();
|
||||||
} else {
|
} else {
|
||||||
return ChatPage();
|
return ChatPage();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
AsyncLoading _ => Scaffold(
|
AsyncLoading _ => Scaffold(
|
||||||
appBar: Appbar(
|
appBar: Appbar(
|
||||||
actions: .new([
|
actions: .new([
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => showDialog(
|
onPressed: () => showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => SettingsPage(),
|
builder: (_) => SettingsPage(),
|
||||||
),
|
|
||||||
icon: Icon(Icons.settings),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
body: Loading(),
|
icon: Icon(Icons.settings),
|
||||||
),
|
),
|
||||||
AsyncError(:final error, :final stackTrace) => ErrorDialog(
|
]),
|
||||||
error,
|
|
||||||
stackTrace,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
body: Loading(),
|
||||||
|
),
|
||||||
|
AsyncError(:final error, :final stackTrace) => ErrorDialog(
|
||||||
|
error,
|
||||||
|
stackTrace,
|
||||||
|
),
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue