Make use of Storage sync instead of async

parent 927b3dd9
......@@ -76,7 +76,7 @@ class AppBloc {
}
Future<void> notifyLogin() async {
if (await getMayReportCrashes() && sentry == null) {
if (getMayReportCrashes() && sentry == null) {
sentry = await Sentry.create();
}
......@@ -91,16 +91,14 @@ class AppBloc {
String get build => DotEnv().env['BUILD_TYPE'];
bool _mayReportCrashes;
FutureOr<bool> getMayReportCrashes({bool lookInStorage = true}) {
bool getMayReportCrashes({bool lookInStorage = true}) {
if (_mayReportCrashes == null && !lookInStorage) {
setMayReportCrashes(build != 'fdroid');
return _mayReportCrashes;
} else if (_mayReportCrashes != null) {
return _mayReportCrashes;
} else {
return storage[_mayReportCrashesStorageKey]
.then((v) => v as bool)
.then((v) => _mayReportCrashes = v);
return storage[_mayReportCrashesStorageKey] as bool;
}
}
......
......@@ -26,7 +26,7 @@ class Storage {
return Storage(await SharedPreferences.getInstance());
}
dynamic operator [](String key) async => prefs.get(key);
dynamic operator [](String key) => prefs.get(key);
void operator []=(String key, dynamic value) {
if (value is String) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment