mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-16 17:09:31 +01:00
fix: LocalStorage location on desktop
This commit is contained in:
parent
441aca1331
commit
81e32c5ee4
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
.svn/
|
||||
lib/generated_plugin_registrant.dart
|
||||
google-services.json
|
||||
prime
|
||||
|
||||
# libolm package
|
||||
/assets/js/package/*
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user