fix: LocalStorage location on desktop
This commit is contained in:
parent
124e22b91e
commit
26b66fd9fb
6 changed files with 19 additions and 11 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue