Fix unawaited future warnings
This commit is contained in:
parent
943c5edfb6
commit
4a060c4edd
7 changed files with 65 additions and 43 deletions
|
@ -61,7 +61,7 @@ analyzer:
|
|||
cancel_subscriptions: error
|
||||
|
||||
|
||||
unawaited_futures: info # convert to warning after fixing existing issues
|
||||
unawaited_futures: ignore # convert to warning after fixing existing issues
|
||||
invalid_dependency: info
|
||||
use_build_context_synchronously: ignore # experimental lint, requires many changes
|
||||
prefer_interpolation_to_compose_strings: ignore # later too many warnings
|
||||
|
|
|
@ -60,7 +60,7 @@ Future<void> _runInForeground() async {
|
|||
return await _runWithLogs(() async {
|
||||
_logger.info("Starting app in foreground");
|
||||
await _init(false, via: 'mainMethod');
|
||||
_scheduleFGSync('appStart in FG');
|
||||
unawaited(_scheduleFGSync('appStart in FG'));
|
||||
runApp(
|
||||
AppLock(
|
||||
builder: (args) => const EnteApp(_runBackgroundTask, _killBGTask),
|
||||
|
@ -203,7 +203,7 @@ Future<void> _scheduleHeartBeat(
|
|||
Future<void> _scheduleFGSync(String caller) async {
|
||||
await _sync(caller);
|
||||
Future.delayed(kFGSyncFrequency, () async {
|
||||
_scheduleFGSync('fgSyncCron');
|
||||
unawaited(_scheduleFGSync('fgSyncCron'));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -249,12 +249,12 @@ class CollectionsService {
|
|||
_collectionIDToCollections[collectionID]
|
||||
.sharees
|
||||
.removeWhere((user) => user.email == email);
|
||||
_db.insert([_collectionIDToCollections[collectionID]]);
|
||||
unawaited(_db.insert([_collectionIDToCollections[collectionID]]));
|
||||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
rethrow;
|
||||
}
|
||||
RemoteSyncService.instance.sync(silently: true);
|
||||
RemoteSyncService.instance.sync(silently: true).ignore();
|
||||
}
|
||||
|
||||
Future<void> trashCollection(Collection collection) async {
|
||||
|
@ -279,7 +279,7 @@ class CollectionsService {
|
|||
await _filesDB.deleteCollection(collection.id);
|
||||
final deletedCollection = collection.copyWith(isDeleted: true);
|
||||
_collectionIDToCollections[collection.id] = deletedCollection;
|
||||
_db.insert([deletedCollection]);
|
||||
unawaited(_db.insert([deletedCollection]));
|
||||
unawaited(LocalSyncService.instance.syncAll());
|
||||
} catch (e) {
|
||||
_logger.severe('failed to trash collection', e);
|
||||
|
@ -857,7 +857,7 @@ class CollectionsService {
|
|||
await _filesDB.removeFromCollection(collectionID, params["fileIDs"]);
|
||||
Bus.instance.fire(CollectionUpdatedEvent(collectionID, files));
|
||||
Bus.instance.fire(LocalPhotosUpdatedEvent(files));
|
||||
RemoteSyncService.instance.sync(silently: true);
|
||||
RemoteSyncService.instance.sync(silently: true).ignore();
|
||||
}
|
||||
|
||||
Future<Collection> createAndCacheCollection(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
@ -40,6 +41,7 @@ class UserService {
|
|||
ValueNotifier<String> emailValueNotifier;
|
||||
|
||||
UserService._privateConstructor();
|
||||
|
||||
static final UserService instance = UserService._privateConstructor();
|
||||
|
||||
Future<void> init() async {
|
||||
|
@ -62,32 +64,40 @@ class UserService {
|
|||
);
|
||||
await dialog.hide();
|
||||
if (response != null && response.statusCode == 200) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return OTTVerificationPage(
|
||||
email,
|
||||
isChangeEmail: isChangeEmail,
|
||||
isCreateAccountScreen: isCreateAccountScreen,
|
||||
);
|
||||
},
|
||||
unawaited(
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return OTTVerificationPage(
|
||||
email,
|
||||
isChangeEmail: isChangeEmail,
|
||||
isCreateAccountScreen: isCreateAccountScreen,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
showGenericErrorDialog(context);
|
||||
unawaited(showGenericErrorDialog(context));
|
||||
} on DioError catch (e) {
|
||||
await dialog.hide();
|
||||
_logger.info(e);
|
||||
if (e.response != null && e.response.statusCode == 403) {
|
||||
showErrorDialog(context, "Oops", "This email is already in use");
|
||||
unawaited(
|
||||
showErrorDialog(
|
||||
context,
|
||||
"Oops",
|
||||
"This email is already in use",
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showGenericErrorDialog(context);
|
||||
unawaited(showGenericErrorDialog(context));
|
||||
}
|
||||
} catch (e) {
|
||||
await dialog.hide();
|
||||
_logger.severe(e);
|
||||
showGenericErrorDialog(context);
|
||||
unawaited(showGenericErrorDialog(context));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,11 +605,13 @@ class UserService {
|
|||
try {
|
||||
final response = await _enteDio.post("/users/two-factor/setup");
|
||||
await dialog.hide();
|
||||
routeToPage(
|
||||
context,
|
||||
TwoFactorSetupPage(
|
||||
response.data["secretCode"],
|
||||
response.data["qrCode"],
|
||||
unawaited(
|
||||
routeToPage(
|
||||
context,
|
||||
TwoFactorSetupPage(
|
||||
response.data["secretCode"],
|
||||
response.data["qrCode"],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
|
@ -672,11 +684,16 @@ class UserService {
|
|||
);
|
||||
Bus.instance.fire(TwoFactorStatusChangeEvent(false));
|
||||
await dialog.hide();
|
||||
showToast(context, "Two-factor authentication has been disabled");
|
||||
unawaited(
|
||||
showToast(
|
||||
context,
|
||||
"Two-factor authentication has been disabled",
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
await dialog.hide();
|
||||
_logger.severe("Failed to disabled 2FA", e);
|
||||
showErrorDialog(
|
||||
await showErrorDialog(
|
||||
context,
|
||||
"Something went wrong",
|
||||
"Please contact support if the problem persists",
|
||||
|
|
|
@ -136,10 +136,10 @@ class ChildSubscriptionWidget extends StatelessWidget {
|
|||
await dialog.show();
|
||||
try {
|
||||
await UserService.instance.leaveFamilyPlan();
|
||||
dialog.hide();
|
||||
await dialog.hide();
|
||||
Navigator.of(context).pop('');
|
||||
} catch (e) {
|
||||
dialog.hide();
|
||||
await dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,8 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
|||
);
|
||||
if (hasAuthenticated) {
|
||||
if (!snapshot.data) {
|
||||
UserService.instance.setupTwoFactor(context);
|
||||
await UserService.instance
|
||||
.setupTwoFactor(context);
|
||||
} else {
|
||||
_disableTwoFactor();
|
||||
}
|
||||
|
@ -151,11 +152,13 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
|||
"Please authenticate to view your active sessions",
|
||||
);
|
||||
if (hasAuthenticated) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const SessionsPage();
|
||||
},
|
||||
unawaited(
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const SessionsPage();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -246,14 +246,16 @@ class _OverlayWidgetState extends State<OverlayWidget> {
|
|||
}
|
||||
|
||||
Future<void> _moveFiles() async {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageTransition(
|
||||
type: PageTransitionType.bottomToTop,
|
||||
child: CreateCollectionPage(
|
||||
widget.selectedFiles,
|
||||
null,
|
||||
actionType: CollectionActionType.moveFiles,
|
||||
unawaited(
|
||||
Navigator.push(
|
||||
context,
|
||||
PageTransition(
|
||||
type: PageTransitionType.bottomToTop,
|
||||
child: CreateCollectionPage(
|
||||
widget.selectedFiles,
|
||||
null,
|
||||
actionType: CollectionActionType.moveFiles,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue