Skip to content

Commit

Permalink
Merge pull request #122 from pangeachat/ios-login-fix
Browse files Browse the repository at this point in the history
Ios login fix
  • Loading branch information
ggurdin authored Mar 18, 2024
2 parents 1f08188 + 97fc7a1 commit 803804a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
5 changes: 3 additions & 2 deletions lib/utils/client_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:fluffychat/pangea/constants/pangea_event_types.dart';
import 'package:fluffychat/utils/custom_http_client.dart';
import 'package:fluffychat/utils/custom_image_resizer.dart';
import 'package:fluffychat/utils/init_with_restore.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
Expand Down Expand Up @@ -122,7 +121,9 @@ abstract class ClientManager {
},
logLevel: kReleaseMode ? Level.warning : Level.verbose,
databaseBuilder: flutterMatrixSdkDatabaseBuilder,
legacyDatabaseBuilder: FlutterHiveCollectionsDatabase.databaseBuilder,
// #Pangea
// legacyDatabaseBuilder: FlutterHiveCollectionsDatabase.databaseBuilder,
// Pangea#
supportedLoginTypes: {
AuthenticationTypes.password,
AuthenticationTypes.sso,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
import 'dart:convert';
import 'dart:math';

import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:matrix/matrix.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart' as ffi;
import 'package:sqflite_sqlcipher/sqflite.dart';
import 'package:universal_html/html.dart' as html;

import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/client_manager.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/flutter_hive_collections_database.dart';
import 'package:fluffychat/utils/platform_infos.dart';

Future<DatabaseApi> flutterMatrixSdkDatabaseBuilder(Client client) async {
MatrixSdkDatabase? database;
try {
database = await _constructDatabase(client);
// throw "error";
await database.open();
return database;
} catch (e) {
// #Pangea
ErrorHandler.logError(
e: e,
m: 'Unable to init database',
s: StackTrace.current,
);
// Try to delete database so that it can created again on next init:
database?.delete().catchError(
(e, s) => Logs().w(
'Unable to delete database, after failed construction',
e,
s,
),
);
// database?.delete().catchError(
// (e, s) => Logs().w(
// 'Unable to delete database, after failed construction',
// e,
// s,
// ),
// );

// Send error notification:
final l10n = lookupL10n(PlatformDispatcher.instance.locale);
ClientManager.sendInitNotification(
l10n.initAppError,
l10n.databaseBuildErrorBody(
AppConfig.newIssueUrl.toString(),
e.toString(),
),
);
// final l10n = lookupL10n(PlatformDispatcher.instance.locale);
// ClientManager.sendInitNotification(
// l10n.initAppError,
// l10n.databaseBuildErrorBody(
// AppConfig.newIssueUrl.toString(),
// e.toString(),
// ),
// );
// Pangea#

return FlutterHiveCollectionsDatabase.databaseBuilder(client);
}
Expand Down

0 comments on commit 803804a

Please sign in to comment.