mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-11 18:22:49 +01:00
feat: Annoy user with dialog to add a recovery method
This commit is contained in:
parent
4a149c06b7
commit
d9ec9f66b4
@ -5,10 +5,13 @@ import 'dart:convert';
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:famedlysdk/encryption.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/firebase_controller.dart';
|
||||
import 'package:fluffychat/utils/matrix_locals.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/sentry_controller.dart';
|
||||
import 'package:fluffychat/views/settings_3pid.dart';
|
||||
import 'package:flushbar/flushbar.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
@ -87,6 +90,7 @@ class MatrixState extends State<Matrix> {
|
||||
var initLoginState = client.onLoginStateChanged.stream.first;
|
||||
try {
|
||||
client.init();
|
||||
|
||||
final firstLoginState = await initLoginState;
|
||||
if (firstLoginState == LoginState.logged) {
|
||||
if (PlatformInfos.isMobile) {
|
||||
@ -96,6 +100,39 @@ class MatrixState extends State<Matrix> {
|
||||
);
|
||||
}
|
||||
}
|
||||
final storeItem = null; //await store.getItem(SettingKeys.showNoPid);
|
||||
final configOptionMissing = storeItem == null || storeItem.isEmpty;
|
||||
if (configOptionMissing || (!configOptionMissing && storeItem == '1')) {
|
||||
if (configOptionMissing) {
|
||||
await store.setItem(SettingKeys.showNoPid, '0');
|
||||
}
|
||||
await Matrix.of(context)
|
||||
.client
|
||||
.requestThirdPartyIdentifiers()
|
||||
.then((l) {
|
||||
if (l.isEmpty) {
|
||||
Flushbar(
|
||||
title: L10n.of(context).warning,
|
||||
message: L10n.of(context).noPasswordRecoveryDescription,
|
||||
mainButton: RaisedButton(
|
||||
elevation: 7,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(L10n.of(context).passwordRecovery),
|
||||
onPressed: () => Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
Settings3PidView(),
|
||||
),
|
||||
),
|
||||
),
|
||||
flushbarStyle: FlushbarStyle.FLOATING,
|
||||
).show(context);
|
||||
}
|
||||
}).catchError((_) => null);
|
||||
}
|
||||
} catch (e, s) {
|
||||
client.onLoginStateChanged.sink.addError(e, s);
|
||||
SentryController.captureException(e, s);
|
||||
|
@ -9,5 +9,6 @@ abstract class SettingKeys {
|
||||
static const String amoledEnabled = 'amoled_enabled';
|
||||
static const String codeLanguage = 'code_language';
|
||||
static const String showNoGoogle = 'chat.fluffy.show_no_google';
|
||||
static const String showNoPid = 'chat.fluffy.show_no_pid';
|
||||
static const String databasePassword = 'database-password';
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/firebase_controller.dart';
|
||||
import 'package:fluffychat/utils/sentry_controller.dart';
|
||||
import 'package:flushbar/flushbar_helper.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
@ -57,19 +57,11 @@ class _LoginState extends State<Login> {
|
||||
setState(() => passwordError = exception.toString());
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
if (!kIsWeb) {
|
||||
try {
|
||||
await FirebaseController.setupFirebase(
|
||||
matrix,
|
||||
matrix.widget.clientName,
|
||||
);
|
||||
} catch (exception) {
|
||||
await matrix.client.logout();
|
||||
matrix.clean();
|
||||
setState(() => passwordError = exception.toString());
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
}
|
||||
await FirebaseController.setupFirebase(
|
||||
matrix,
|
||||
matrix.widget.clientName,
|
||||
).catchError(SentryController.captureException);
|
||||
|
||||
setState(() => loading = false);
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()), (r) => false);
|
||||
|
Loading…
Reference in New Issue
Block a user