refactor: sdk 1.0
This commit is contained in:
parent
ca4db07d83
commit
e548d8f895
23 changed files with 1775 additions and 175 deletions
|
|
@ -74,9 +74,6 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
BackgroundPush? backgroundPush;
|
||||
|
||||
Client get client {
|
||||
if (widget.clients.isEmpty) {
|
||||
widget.clients.add(getLoginClient());
|
||||
}
|
||||
if (_activeClient < 0 || _activeClient >= widget.clients.length) {
|
||||
return currentBundle!.first!;
|
||||
}
|
||||
|
|
@ -152,29 +149,31 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
AudioPlayer? audioPlayer;
|
||||
final ValueNotifier<String?> voiceMessageEventId = ValueNotifier(null);
|
||||
|
||||
Client getLoginClient() {
|
||||
Future<Client> getLoginClient() async {
|
||||
if (widget.clients.isNotEmpty && !client.isLogged()) {
|
||||
return client;
|
||||
}
|
||||
final candidate = _loginClientCandidate ??= ClientManager.createClient(
|
||||
final candidate =
|
||||
_loginClientCandidate ??= await ClientManager.createClient(
|
||||
'${AppConfig.applicationName}-${DateTime.now().millisecondsSinceEpoch}',
|
||||
store,
|
||||
)..onLoginStateChanged
|
||||
.stream
|
||||
.where((l) => l == LoginState.loggedIn)
|
||||
.first
|
||||
.then((_) {
|
||||
if (!widget.clients.contains(_loginClientCandidate)) {
|
||||
widget.clients.add(_loginClientCandidate!);
|
||||
}
|
||||
ClientManager.addClientNameToStore(
|
||||
_loginClientCandidate!.clientName,
|
||||
store,
|
||||
);
|
||||
_registerSubs(_loginClientCandidate!.clientName);
|
||||
_loginClientCandidate = null;
|
||||
FluffyChatApp.router.go('/rooms');
|
||||
});
|
||||
)
|
||||
..onLoginStateChanged
|
||||
.stream
|
||||
.where((l) => l == LoginState.loggedIn)
|
||||
.first
|
||||
.then((_) {
|
||||
if (!widget.clients.contains(_loginClientCandidate)) {
|
||||
widget.clients.add(_loginClientCandidate!);
|
||||
}
|
||||
ClientManager.addClientNameToStore(
|
||||
_loginClientCandidate!.clientName,
|
||||
store,
|
||||
);
|
||||
_registerSubs(_loginClientCandidate!.clientName);
|
||||
_loginClientCandidate = null;
|
||||
FluffyChatApp.router.go('/rooms');
|
||||
});
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue