Browse Source

fix: LocalStorage location on desktop

yiffed
Christian Pauly 6 months ago
parent
commit
81e32c5ee4
6 changed files with 19 additions and 11 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -3
      lib/components/matrix.dart
  3. +2
    -3
      lib/main.dart
  4. +10
    -0
      lib/utils/famedlysdk_store.dart
  5. +4
    -4
      lib/utils/sentry_controller.dart
  6. +1
    -1
      pubspec.lock

+ 1
- 0
.gitignore View File

@ -11,6 +11,7 @@
.svn/
lib/generated_plugin_registrant.dart
google-services.json
prime
# libolm package
/assets/js/package/*


+ 1
- 3
lib/components/matrix.dart View File

@ -11,7 +11,6 @@ import 'package:fluffychat/utils/user_status.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:localstorage/localstorage.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:url_launcher/url_launcher.dart';
@ -78,8 +77,7 @@ class MatrixState extends State<Matrix> {
void clean() async {
if (!kIsWeb) return;
final storage = LocalStorage('LocalStorage');
await storage.ready;
final storage = await getLocalStorage();
await storage.deleteItem(widget.clientName);
}


+ 2
- 3
lib/main.dart View File

@ -8,12 +8,12 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:localstorage/localstorage.dart';
import 'package:sentry/sentry.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'components/matrix.dart';
import 'components/theme_switcher.dart';
import 'utils/famedlysdk_store.dart';
import 'views/chat_list.dart';
final sentry = SentryClient(dsn: '8591d0d863b646feb4f3dda7e5dcab38');
@ -21,8 +21,7 @@ final sentry = SentryClient(dsn: '8591d0d863b646feb4f3dda7e5dcab38');
void captureException(error, stackTrace) async {
debugPrint(error.toString());
debugPrint(stackTrace.toString());
final storage = LocalStorage('LocalStorage');
await storage.ready;
final storage = await getLocalStorage();
if (storage.getItem('sentry') == true) {
await sentry.captureException(
exception: error,


+ 10
- 0
lib/utils/famedlysdk_store.dart View File

@ -6,12 +6,22 @@ import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:localstorage/localstorage.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:async';
import 'dart:core';
import './database/shared.dart';
import 'package:olm/olm.dart' as olm; // needed for migration
import 'package:random_string/random_string.dart';
Future<LocalStorage> getLocalStorage() async {
final directory = PlatformInfos.isBetaDesktop
? await getApplicationSupportDirectory()
: await getApplicationDocumentsDirectory();
final localStorage = LocalStorage('LocalStorage', directory.path);
await localStorage.ready;
return localStorage;
}
Future<Database> getDatabase(Client client) async {
while (_generateDatabaseLock) {
await Future.delayed(Duration(milliseconds: 50));


+ 4
- 4
lib/utils/sentry_controller.dart View File

@ -2,10 +2,10 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:localstorage/localstorage.dart';
import 'famedlysdk_store.dart';
abstract class SentryController {
static LocalStorage storage = LocalStorage('LocalStorage');
static Future<void> toggleSentryAction(BuildContext context) async {
final enableSentry = await SimpleDialogs(context).askConfirmation(
titleText: L10n.of(context).sendBugReports,
@ -13,14 +13,14 @@ abstract class SentryController {
confirmText: L10n.of(context).ok,
cancelText: L10n.of(context).no,
);
await storage.ready;
final storage = await getLocalStorage();
await storage.setItem('sentry', enableSentry);
BotToast.showText(text: L10n.of(context).changesHaveBeenSaved);
return;
}
static Future<bool> getSentryStatus() async {
await storage.ready;
final storage = await getLocalStorage();
return storage.getItem('sentry') as bool;
}
}

+ 1
- 1
pubspec.lock View File

@ -1074,5 +1074,5 @@ packages:
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.0-110 <=2.11.0-161.0.dev"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.20.0 <2.0.0"

Loading…
Cancel
Save