Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings around missing awaits #733

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions auth/lib/core/logging/super_logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SuperLogging {
await setupLogDir();
}
if (sentryIsEnabled) {
setupSentry();
await setupSentry();
}

Logger.root.level = Level.ALL;
Expand Down Expand Up @@ -250,7 +250,7 @@ class SuperLogging {

// add error to sentry queue
if (sentryIsEnabled && rec.error != null) {
_sendErrorToSentry(rec.error!, null);
await _sendErrorToSentry(rec.error!, null);
}
}

Expand Down Expand Up @@ -289,7 +289,7 @@ class SuperLogging {
SuperLogging.setUserID(await _getOrCreateAnonymousUserID());
await for (final error in sentryQueueControl.stream.asBroadcastStream()) {
try {
Sentry.captureException(
await Sentry.captureException(
error,
);
} catch (e) {
Expand Down
5 changes: 3 additions & 2 deletions auth/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';

import 'package:adaptive_theme/adaptive_theme.dart';
Expand Down Expand Up @@ -46,7 +47,7 @@ Future<void> _runInForeground() async {
_logger.info("Starting app in foreground");
await _init(false, via: 'mainMethod');
final Locale locale = await getLocale();
UpdateService.instance.showUpdateNotification();
unawaited(UpdateService.instance.showUpdateNotification());
runApp(
AppLock(
builder: (args) => App(locale: locale),
Expand Down Expand Up @@ -83,7 +84,7 @@ Future _runWithLogs(Function() function, {String prefix = ""}) async {

Future<void> _init(bool bool, {String? via}) async {
// Start workers asynchronously. No need to wait for them to start
Computer.shared().turnOn(workersCount: 4, verbose: kDebugMode);
Computer.shared().turnOn(workersCount: 4, verbose: kDebugMode).ignore();
CryptoUtil.init();
await PreferenceService.instance.init();
await CodeStore.instance.init();
Expand Down
2 changes: 2 additions & 0 deletions auth/lib/onboarding/view/onboarding_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
),
onTap: () async {
final locale = await getLocale();
// ignore: unawaited_futures
routeToPage(
context,
LanguageSelectorPage(
Expand Down Expand Up @@ -228,6 +229,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
}
if (hasOptedBefore || result?.action == ButtonAction.first) {
await Configuration.instance.optForOfflineMode();
// ignore: unawaited_futures
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion auth/lib/services/authenticator_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class AuthenticatorService {
if (deletedIDs.isNotEmpty) {
await _db.deleteByIDs(ids: deletedIDs);
}
_prefs.setInt(_lastEntitySyncTime, maxSyncTime);
await _prefs.setInt(_lastEntitySyncTime, maxSyncTime);
_logger.info("Setting synctime to " + maxSyncTime.toString());
if (result.length == fetchLimit) {
_logger.info("Diff limit reached, pulling again");
Expand Down
1 change: 1 addition & 0 deletions auth/lib/services/local_authentication_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class LocalAuthenticationService {
.setEnabled(Configuration.instance.shouldShowLockScreen());
}
} else {
// ignore: unawaited_futures
showErrorDialog(
context,
errorDialogTitle,
Expand Down
1 change: 1 addition & 0 deletions auth/lib/services/notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class NotificationService {
_flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();
if (implementation != null) {
// ignore: unawaited_futures
implementation.requestPermission();
}
}
Expand Down
9 changes: 6 additions & 3 deletions auth/lib/services/update_service.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';

import 'package:ente_auth/core/constants.dart';
Expand Down Expand Up @@ -70,9 +71,11 @@ class UpdateService {
if (shouldUpdate &&
hasBeen3DaysSinceLastNotification &&
_latestVersion!.shouldNotify!) {
NotificationService.instance.showNotification(
"Update available",
"Click to install our best version yet",
unawaited(
NotificationService.instance.showNotification(
"Update available",
"Click to install our best version yet",
),
);
await _prefs.setInt(kUpdateAvailableShownTimeKey, now);
} else {
Expand Down
29 changes: 25 additions & 4 deletions auth/lib/services/user_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,18 @@ class UserService {
final userDetails = UserDetails.fromMap(response.data);
if (shouldCache) {
if (userDetails.profileData != null) {
_preferences.setBool(
await _preferences.setBool(
kIsEmailMFAEnabled,
userDetails.profileData!.isEmailMFAEnabled,
);
_preferences.setBool(
await _preferences.setBool(
kCanDisableEmailMFA,
userDetails.profileData!.canDisableEmailMFA,
);
}
// handle email change from different client
if (userDetails.email != _config.getEmail()) {
setEmail(userDetails.email);
await setEmail(userDetails.email);
}
}
return userDetails;
Expand Down Expand Up @@ -282,6 +282,7 @@ class UserService {
throw Exception("unexpected response during passkey verification");
}

// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand Down Expand Up @@ -331,6 +332,7 @@ class UserService {
);
}
}
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -354,6 +356,7 @@ class UserService {
);
Navigator.of(context).pop();
} else {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.incorrectCode,
Expand All @@ -363,6 +366,7 @@ class UserService {
} catch (e) {
await dialog.hide();
_logger.severe(e);
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand Down Expand Up @@ -399,6 +403,7 @@ class UserService {
Bus.instance.fire(UserDetailsChangedEvent());
return;
}
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand All @@ -407,12 +412,14 @@ class UserService {
} on DioError catch (e) {
await dialog.hide();
if (e.response != null && e.response!.statusCode == 403) {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
context.l10n.thisEmailIsAlreadyInUse,
);
} else {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.incorrectCode,
Expand All @@ -422,6 +429,7 @@ class UserService {
} catch (e) {
await dialog.hide();
_logger.severe(e);
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand Down Expand Up @@ -632,6 +640,7 @@ class UserService {
}
}
await dialog.hide();
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand Down Expand Up @@ -709,6 +718,7 @@ class UserService {
if (response.statusCode == 200) {
showShortToast(context, context.l10n.authenticationSuccessful);
await _saveConfiguration(response);
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -723,6 +733,7 @@ class UserService {
_logger.severe(e);
if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired");
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -732,6 +743,7 @@ class UserService {
(route) => route.isFirst,
);
} else {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.incorrectCode,
Expand All @@ -741,6 +753,7 @@ class UserService {
} catch (e) {
await dialog.hide();
_logger.severe(e);
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand All @@ -760,6 +773,7 @@ class UserService {
},
);
if (response.statusCode == 200) {
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -777,6 +791,7 @@ class UserService {
_logger.severe(e);
if (e.response != null && e.response!.statusCode == 404) {
showToast(context, context.l10n.sessionExpired);
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -786,6 +801,7 @@ class UserService {
(route) => route.isFirst,
);
} else {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand All @@ -794,6 +810,7 @@ class UserService {
}
} catch (e) {
_logger.severe(e);
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand Down Expand Up @@ -853,6 +870,7 @@ class UserService {
context.l10n.twofactorAuthenticationSuccessfullyReset,
);
await _saveConfiguration(response);
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -866,6 +884,7 @@ class UserService {
_logger.severe(e);
if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired");
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -875,6 +894,7 @@ class UserService {
(route) => route.isFirst,
);
} else {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand All @@ -883,6 +903,7 @@ class UserService {
}
} catch (e) {
_logger.severe(e);
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.oops,
Expand Down Expand Up @@ -925,7 +946,7 @@ class UserService {
"isEnabled": isEnabled,
},
);
_preferences.setBool(kIsEmailMFAEnabled, isEnabled);
await _preferences.setBool(kIsEmailMFAEnabled, isEnabled);
} catch (e) {
_logger.severe("Failed to update email mfa", e);
rethrow;
Expand Down
2 changes: 1 addition & 1 deletion auth/lib/ui/account/delete_account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class DeleteAccountPage extends StatelessWidget {
),
],
);

// ignore: unawaited_futures
showDialog(
context: context,
builder: (BuildContext context) {
Expand Down
3 changes: 2 additions & 1 deletion auth/lib/ui/account/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _LoginPageState extends State<LoginPage> {
isFormValid: _emailIsValid,
buttonText: context.l10n.logInLabel,
onPressedFunction: () async {
UserService.instance.setEmail(_email!);
await UserService.instance.setEmail(_email!);
Configuration.instance.resetVolatilePassword();
SrpAttributes? attr;
bool isEmailVerificationEnabled = true;
Expand All @@ -74,6 +74,7 @@ class _LoginPageState extends State<LoginPage> {
}
}
if (attr != null && !isEmailVerificationEnabled) {
// ignore: unawaited_futures
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
Expand Down
1 change: 1 addition & 0 deletions auth/lib/ui/account/logout_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Future<void> autoLogoutAlert(BuildContext context) async {
int pendingSyncCount =
await AuthenticatorDB.instance.getNeedSyncCount();
if (pendingSyncCount > 0) {
// ignore: unawaited_futures
showChoiceActionSheet(
context,
title: l10n.pendingSyncs,
Expand Down
7 changes: 6 additions & 1 deletion auth/lib/ui/account/password_entry_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
} catch (e, s) {
_logger.severe(e, s);
await dialog.hide();
// ignore: unawaited_futures
showGenericErrorDialog(context: context);
}
}
Expand Down Expand Up @@ -446,6 +447,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
await UserService.instance.setAttributes(result);
await dialog.hide();
Configuration.instance.resetVolatilePassword();
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
Expand All @@ -457,10 +459,11 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
} catch (e, s) {
_logger.severe(e, s);
await dialog.hide();
// ignore: unawaited_futures
showGenericErrorDialog(context: context);
}
}

// ignore: unawaited_futures
routeToPage(
context,
RecoveryKeyPage(
Expand All @@ -476,12 +479,14 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
_logger.severe(e);
await dialog.hide();
if (e is UnsupportedError) {
// ignore: unawaited_futures
showErrorDialog(
context,
context.l10n.insecureDevice,
context.l10n.sorryWeCouldNotGenerateSecureKeysOnThisDevicennplease,
);
} else {
// ignore: unawaited_futures
showGenericErrorDialog(context: context);
}
}
Expand Down
1 change: 1 addition & 0 deletions auth/lib/ui/account/password_reentry_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
firstButtonLabel: context.l10n.useRecoveryKey,
);
if (dialogChoice!.action == ButtonAction.first) {
// ignore: unawaited_futures
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
Expand Down
Loading