mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 06:25:15 +00:00
fix: Routing glitch when using SSO on desktop
This commit is contained in:
parent
9f0bcd5523
commit
2d7301ea50
3 changed files with 54 additions and 29 deletions
|
@ -50,6 +50,7 @@ class HomeserverAppBar extends StatelessWidget {
|
||||||
controller.checkHomeserverAction();
|
controller.checkHomeserverAction();
|
||||||
},
|
},
|
||||||
textFieldConfiguration: TextFieldConfiguration(
|
textFieldConfiguration: TextFieldConfiguration(
|
||||||
|
enabled: !controller.isLoggingIn,
|
||||||
controller: controller.homeserverController,
|
controller: controller.homeserverController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
prefixIcon: Navigator.of(context).canPop()
|
prefixIcon: Navigator.of(context).canPop()
|
||||||
|
|
|
@ -8,7 +8,6 @@ import 'package:collection/collection.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
|
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
|
||||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
@ -33,6 +32,8 @@ class HomeserverPicker extends StatefulWidget {
|
||||||
|
|
||||||
class HomeserverPickerController extends State<HomeserverPicker> {
|
class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
bool isLoggingIn = false;
|
||||||
|
|
||||||
final TextEditingController homeserverController = TextEditingController(
|
final TextEditingController homeserverController = TextEditingController(
|
||||||
text: AppConfig.defaultHomeserver,
|
text: AppConfig.defaultHomeserver,
|
||||||
);
|
);
|
||||||
|
@ -135,14 +136,27 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
final token = Uri.parse(result).queryParameters['loginToken'];
|
final token = Uri.parse(result).queryParameters['loginToken'];
|
||||||
if (token?.isEmpty ?? false) return;
|
if (token?.isEmpty ?? false) return;
|
||||||
|
|
||||||
await showFutureLoadingDialog(
|
setState(() {
|
||||||
context: context,
|
error = null;
|
||||||
future: () => Matrix.of(context).getLoginClient().login(
|
isLoading = isLoggingIn = true;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await Matrix.of(context).getLoginClient().login(
|
||||||
LoginType.mLoginToken,
|
LoginType.mLoginToken,
|
||||||
token: token,
|
token: token,
|
||||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||||
),
|
);
|
||||||
);
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
error = e.toLocalizedString(context);
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
isLoading = isLoggingIn = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IdentityProvider>? get identityProviders {
|
List<IdentityProvider>? get identityProviders {
|
||||||
|
@ -181,18 +195,25 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
);
|
);
|
||||||
final file = picked?.files.firstOrNull;
|
final file = picked?.files.firstOrNull;
|
||||||
if (file == null) return;
|
if (file == null) return;
|
||||||
await showFutureLoadingDialog(
|
setState(() {
|
||||||
context: context,
|
error = null;
|
||||||
future: () async {
|
isLoading = isLoggingIn = true;
|
||||||
try {
|
});
|
||||||
final client = Matrix.of(context).getLoginClient();
|
try {
|
||||||
await client.importDump(String.fromCharCodes(file.bytes!));
|
final client = Matrix.of(context).getLoginClient();
|
||||||
Matrix.of(context).initMatrix();
|
await client.importDump(String.fromCharCodes(file.bytes!));
|
||||||
} catch (e, s) {
|
Matrix.of(context).initMatrix();
|
||||||
Logs().e('Future error:', e, s);
|
} catch (e) {
|
||||||
}
|
setState(() {
|
||||||
},
|
error = e.toLocalizedString(context);
|
||||||
);
|
});
|
||||||
|
} finally {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
isLoading = isLoggingIn = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,15 +57,6 @@ class HomeserverPickerView extends StatelessWidget {
|
||||||
? const Center(child: CircularProgressIndicator.adaptive())
|
? const Center(child: CircularProgressIndicator.adaptive())
|
||||||
: ListView(
|
: ListView(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
||||||
child: FluffyThemes.isColumnMode(context)
|
|
||||||
? Image.asset(
|
|
||||||
'assets/info-logo.png',
|
|
||||||
height: 96,
|
|
||||||
)
|
|
||||||
: Image.asset('assets/banner_transparent.png'),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
if (errorText != null) ...[
|
if (errorText != null) ...[
|
||||||
const Center(
|
const Center(
|
||||||
|
@ -97,8 +88,18 @@ class HomeserverPickerView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 36),
|
||||||
],
|
] else
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
|
child: FluffyThemes.isColumnMode(context)
|
||||||
|
? Image.asset(
|
||||||
|
'assets/info-logo.png',
|
||||||
|
height: 96,
|
||||||
|
)
|
||||||
|
: Image.asset('assets/banner_transparent.png'),
|
||||||
|
),
|
||||||
if (identityProviders != null) ...[
|
if (identityProviders != null) ...[
|
||||||
...identityProviders.map(
|
...identityProviders.map(
|
||||||
(provider) => _LoginButton(
|
(provider) => _LoginButton(
|
||||||
|
@ -143,6 +144,8 @@ class HomeserverPickerView extends StatelessWidget {
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(vertical: 12),
|
const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
onPressed: controller.restoreBackup,
|
onPressed: controller.restoreBackup,
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|
Loading…
Reference in a new issue