Merge branch 'fix_await_warnings' into onnx

This commit is contained in:
vishnukvmd 2023-12-17 02:51:15 +05:30
commit 411ac66a91
47 changed files with 133 additions and 116 deletions

View file

@ -106,9 +106,11 @@ Future<void> _runBackgroundTask(String taskId, {String mode = 'normal'}) async {
await _sync('bgTaskActiveProcess'); await _sync('bgTaskActiveProcess');
BackgroundFetch.finish(taskId); BackgroundFetch.finish(taskId);
} else { } else {
// ignore: unawaited_futures
_runWithLogs( _runWithLogs(
() async { () async {
_logger.info("Starting background task in $mode mode"); _logger.info("Starting background task in $mode mode");
// ignore: unawaited_futures
_runInBackground(taskId); _runInBackground(taskId);
}, },
prefix: "[bg]", prefix: "[bg]",
@ -152,7 +154,7 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
_logger.info("Initializing... inBG =$isBackground via: $via"); _logger.info("Initializing... inBG =$isBackground via: $via");
final SharedPreferences preferences = await SharedPreferences.getInstance(); final SharedPreferences preferences = await SharedPreferences.getInstance();
await _logFGHeartBeatInfo(); await _logFGHeartBeatInfo();
_scheduleHeartBeat(preferences, isBackground); unawaited(_scheduleHeartBeat(preferences, isBackground));
AppLifecycleService.instance.init(preferences); AppLifecycleService.instance.init(preferences);
if (isBackground) { if (isBackground) {
AppLifecycleService.instance.onAppInBackground('init via: $via'); AppLifecycleService.instance.onAppInBackground('init via: $via');
@ -185,15 +187,15 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
SearchService.instance.init(); SearchService.instance.init();
StorageBonusService.instance.init(preferences); StorageBonusService.instance.init(preferences);
if (Platform.isIOS) { if (Platform.isIOS) {
// ignore: unawaited_futures
PushService.instance.init().then((_) { PushService.instance.init().then((_) {
FirebaseMessaging.onBackgroundMessage( FirebaseMessaging.onBackgroundMessage(
_firebaseMessagingBackgroundHandler, _firebaseMessagingBackgroundHandler,
); );
}); });
} }
FeatureFlagService.instance.init(); unawaited(FeatureFlagService.instance.init());
SemanticSearchService.instance.init(preferences); unawaited(SemanticSearchService.instance.init(preferences));
// Can not including existing tf/ml binaries as they are not being built // Can not including existing tf/ml binaries as they are not being built
// from source. // from source.
// See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12671#note_1294346819 // See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12671#note_1294346819
@ -242,6 +244,7 @@ Future<void> _scheduleHeartBeat(
DateTime.now().microsecondsSinceEpoch, DateTime.now().microsecondsSinceEpoch,
); );
Future.delayed(kHeartBeatFrequency, () async { Future.delayed(kHeartBeatFrequency, () async {
// ignore: unawaited_futures
_scheduleHeartBeat(prefs, isBackground); _scheduleHeartBeat(prefs, isBackground);
}); });
} }
@ -281,7 +284,7 @@ Future<void> _killBGTask([String? taskId]) async {
DateTime.now().microsecondsSinceEpoch, DateTime.now().microsecondsSinceEpoch,
); );
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
prefs.remove(kLastBGTaskHeartBeatTime); await prefs.remove(kLastBGTaskHeartBeatTime);
if (taskId != null) { if (taskId != null) {
BackgroundFetch.finish(taskId); BackgroundFetch.finish(taskId);
} }
@ -299,6 +302,7 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
} }
} else { } else {
// App is dead // App is dead
// ignore: unawaited_futures
_runWithLogs( _runWithLogs(
() async { () async {
_logger.info("Background push received"); _logger.info("Background push received");

View file

@ -147,7 +147,7 @@ class CollectionsService {
); );
} }
await _updateDB(updatedCollections); await _updateDB(updatedCollections);
_prefs.setInt(_collectionsSyncTimeKey, maxUpdationTime); await _prefs.setInt(_collectionsSyncTimeKey, maxUpdationTime);
watch.logAndReset("till DB insertion ${updatedCollections.length}"); watch.logAndReset("till DB insertion ${updatedCollections.length}");
for (final collection in fetchedCollections) { for (final collection in fetchedCollections) {
_cacheLocalPathAndCollection(collection); _cacheLocalPathAndCollection(collection);

View file

@ -142,7 +142,7 @@ class EntityService {
await _db.upsertEntities(entities); await _db.upsertEntities(entities);
} }
} }
_prefs.setInt(_getEntityLastSyncTimePrefix(type), maxSyncTime); await _prefs.setInt(_getEntityLastSyncTimePrefix(type), maxSyncTime);
if (hasMoreItems) { if (hasMoreItems) {
_logger.info("Diff limit reached, pulling again"); _logger.info("Diff limit reached, pulling again");
await _remoteToLocalSync(type); await _remoteToLocalSync(type);

View file

@ -83,7 +83,7 @@ class FeatureFlagService {
.getDio() .getDio()
.get("https://static.ente.io/feature_flags.json"); .get("https://static.ente.io/feature_flags.json");
final flagsResponse = FeatureFlags.fromMap(response.data); final flagsResponse = FeatureFlags.fromMap(response.data);
_prefs.setString(_featureFlagsKey, flagsResponse.toJson()); await _prefs.setString(_featureFlagsKey, flagsResponse.toJson());
_featureFlags = flagsResponse; _featureFlags = flagsResponse;
} catch (e) { } catch (e) {
_logger.severe("Failed to sync feature flags ", e); _logger.severe("Failed to sync feature flags ", e);

View file

@ -1,3 +1,4 @@
import "dart:async";
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
@ -149,7 +150,7 @@ extension HiddenService on CollectionsService {
await dialog.hide(); await dialog.hide();
} on AssertionError catch (e) { } on AssertionError catch (e) {
await dialog.hide(); await dialog.hide();
showErrorDialog(context, "Oops", e.message as String); unawaited(showErrorDialog(context, "Oops", e.message as String));
return false; return false;
} catch (e, s) { } catch (e, s) {
_logger.severe("Could not hide", e, s); _logger.severe("Could not hide", e, s);

View file

@ -24,7 +24,7 @@ class LocalAuthenticationService {
Configuration.instance.shouldShowLockScreen(), Configuration.instance.shouldShowLockScreen(),
); );
if (!result) { if (!result) {
unawaited(showToast(context, infoMessage)); showToast(context, infoMessage);
return false; return false;
} else { } else {
return true; return true;

View file

@ -352,7 +352,7 @@ class LocalSyncService {
PhotoManager.addChangeCallback((value) async { PhotoManager.addChangeCallback((value) async {
_logger.info("Something changed on disk"); _logger.info("Something changed on disk");
_changeCallbackDebouncer.run(() async { _changeCallbackDebouncer.run(() async {
checkAndSync(); unawaited(checkAndSync());
}); });
}); });
PhotoManager.startChangeNotify(); PhotoManager.startChangeNotify();
@ -363,9 +363,9 @@ class LocalSyncService {
await _existingSync!.future; await _existingSync!.future;
} }
if (hasGrantedLimitedPermissions()) { if (hasGrantedLimitedPermissions()) {
syncAll(); unawaited(syncAll());
} else { } else {
sync().then((value) => _refreshDeviceFolderCountAndCover()); unawaited(sync().then((value) => _refreshDeviceFolderCountAndCover()));
} }
} }
} }

View file

@ -75,7 +75,7 @@ class NotificationService {
?.requestPermission(); ?.requestPermission();
} }
if (result != null) { if (result != null) {
_preferences.setBool(keyGrantedNotificationPermission, result); await _preferences.setBool(keyGrantedNotificationPermission, result);
} }
} }

View file

@ -35,6 +35,7 @@ class PushService {
await _configurePushToken(); await _configurePushToken();
} else { } else {
Bus.instance.on<SignedInEvent>().listen((_) async { Bus.instance.on<SignedInEvent>().listen((_) async {
// ignore: unawaited_futures
_configurePushToken(); _configurePushToken();
}); });
} }

View file

@ -74,6 +74,7 @@ class RemoteSyncService {
Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) async { Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) async {
if (event.type == EventType.addedOrUpdated) { if (event.type == EventType.addedOrUpdated) {
if (_existingSync == null) { if (_existingSync == null) {
// ignore: unawaited_futures
sync(); sync();
} }
} }
@ -141,6 +142,7 @@ class RemoteSyncService {
if (hasMoreFilesToBackup && !_shouldThrottleSync()) { if (hasMoreFilesToBackup && !_shouldThrottleSync()) {
// Skipping a resync to ensure that files that were ignored in this // Skipping a resync to ensure that files that were ignored in this
// session are not processed now // session are not processed now
// ignore: unawaited_futures
sync(); sync();
} else { } else {
_logger.info("Fire backup completed event"); _logger.info("Fire backup completed event");
@ -959,6 +961,7 @@ class RemoteSyncService {
'creating notification for ${collection?.displayName} ' 'creating notification for ${collection?.displayName} '
'shared: $sharedFilesIDs, collected: $collectedFilesIDs files', 'shared: $sharedFilesIDs, collected: $collectedFilesIDs files',
); );
// ignore: unawaited_futures
NotificationService.instance.showNotification( NotificationService.instance.showNotification(
collection!.displayName, collection!.displayName,
totalCount.toString() + " new 📸", totalCount.toString() + " new 📸",

View file

@ -240,6 +240,7 @@ class SyncService {
final now = DateTime.now().microsecondsSinceEpoch; final now = DateTime.now().microsecondsSinceEpoch;
if ((now - lastNotificationShownTime) > microSecondsInDay) { if ((now - lastNotificationShownTime) > microSecondsInDay) {
await _prefs.setInt(kLastStorageLimitExceededNotificationPushTime, now); await _prefs.setInt(kLastStorageLimitExceededNotificationPushTime, now);
// ignore: unawaited_futures
NotificationService.instance.showNotification( NotificationService.instance.showNotification(
"Storage limit exceeded", "Storage limit exceeded",
"Sorry, we had to pause your backups", "Sorry, we had to pause your backups",

View file

@ -86,6 +86,7 @@ class UpdateService {
if (shouldUpdate && if (shouldUpdate &&
hasBeen3DaysSinceLastNotification && hasBeen3DaysSinceLastNotification &&
_latestVersion!.shouldNotify) { _latestVersion!.shouldNotify) {
// ignore: unawaited_futures
NotificationService.instance.showNotification( NotificationService.instance.showNotification(
"Update available", "Update available",
"Click to install our best version yet", "Click to install our best version yet",

View file

@ -740,8 +740,7 @@ class UserService {
); );
await dialog.hide(); await dialog.hide();
if (response.statusCode == 200) { if (response.statusCode == 200) {
showShortToast(context, S.of(context).authenticationSuccessful) showShortToast(context, S.of(context).authenticationSuccessful);
.ignore();
await _saveConfiguration(response); await _saveConfiguration(response);
await Navigator.of(context).pushAndRemoveUntil( await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(
@ -756,7 +755,7 @@ class UserService {
await dialog.hide(); await dialog.hide();
_logger.severe(e); _logger.severe(e);
if (e.response != null && e.response!.statusCode == 404) { if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired").ignore(); showToast(context, "Session expired");
await Navigator.of(context).pushAndRemoveUntil( await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -810,7 +809,7 @@ class UserService {
} on DioError catch (e) { } on DioError catch (e) {
_logger.severe(e); _logger.severe(e);
if (e.response != null && e.response!.statusCode == 404) { if (e.response != null && e.response!.statusCode == 404) {
showToast(context, S.of(context).sessionExpired).ignore(); showToast(context, S.of(context).sessionExpired);
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -1016,11 +1015,9 @@ class UserService {
); );
await dialog.hide(); await dialog.hide();
Bus.instance.fire(TwoFactorStatusChangeEvent(false)); Bus.instance.fire(TwoFactorStatusChangeEvent(false));
unawaited(
showShortToast( showShortToast(
context, context,
S.of(context).twofactorAuthenticationHasBeenDisabled, S.of(context).twofactorAuthenticationHasBeenDisabled,
),
); );
} catch (e) { } catch (e) {
await dialog.hide(); await dialog.hide();

View file

@ -1,3 +1,4 @@
import "dart:async";
import 'dart:convert'; import 'dart:convert';
import "package:dropdown_button2/dropdown_button2.dart"; import "package:dropdown_button2/dropdown_button2.dart";
@ -344,6 +345,7 @@ class _DeleteAccountPageState extends State<DeleteAccountPage> {
], ],
); );
// ignore: unawaited_futures
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {

View file

@ -68,7 +68,7 @@ class _LoginPageState extends State<LoginPage> {
isFormValid: _emailIsValid, isFormValid: _emailIsValid,
buttonText: S.of(context).logInLabel, buttonText: S.of(context).logInLabel,
onPressedFunction: () async { onPressedFunction: () async {
UserService.instance.setEmail(_email!); await UserService.instance.setEmail(_email!);
SrpAttributes? attr; SrpAttributes? attr;
bool isEmailVerificationEnabled = true; bool isEmailVerificationEnabled = true;
try { try {
@ -80,6 +80,7 @@ class _LoginPageState extends State<LoginPage> {
} }
} }
if (attr != null && !isEmailVerificationEnabled) { if (attr != null && !isEmailVerificationEnabled) {
// ignore: unawaited_futures
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {

View file

@ -1,3 +1,5 @@
import "dart:async";
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
@ -445,6 +447,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
await dialog.hide(); await dialog.hide();
Configuration.instance.setVolatilePassword(null); Configuration.instance.setVolatilePassword(null);
Bus.instance.fire(AccountConfiguredEvent()); Bus.instance.fire(AccountConfiguredEvent());
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -460,6 +463,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
} }
} }
// ignore: unawaited_futures
routeToPage( routeToPage(
context, context,
RecoveryKeyPage( RecoveryKeyPage(
@ -475,6 +479,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
_logger.severe(e); _logger.severe(e);
await dialog.hide(); await dialog.hide();
if (e is UnsupportedError) { if (e is UnsupportedError) {
// ignore: unawaited_futures
showErrorDialog( showErrorDialog(
context, context,
S.of(context).insecureDevice, S.of(context).insecureDevice,

View file

@ -120,6 +120,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
firstButtonLabel: S.of(context).useRecoveryKey, firstButtonLabel: S.of(context).useRecoveryKey,
); );
if (dialogChoice!.action == ButtonAction.first) { if (dialogChoice!.action == ButtonAction.first) {
// ignore: unawaited_futures
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {

View file

@ -1,3 +1,4 @@
import "dart:async";
import 'dart:io'; import 'dart:io';
import 'package:bip39/bip39.dart' as bip39; import 'package:bip39/bip39.dart' as bip39;

View file

@ -54,6 +54,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
await Configuration.instance.recover(_recoveryKey.text.trim()); await Configuration.instance.recover(_recoveryKey.text.trim());
await dialog.hide(); await dialog.hide();
showShortToast(context, S.of(context).recoverySuccessful); showShortToast(context, S.of(context).recoverySuccessful);
// ignore: unawaited_futures
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -72,6 +73,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
if (e is AssertionError) { if (e is AssertionError) {
errMessage = '$errMessage : ${e.message}'; errMessage = '$errMessage : ${e.message}';
} }
// ignore: unawaited_futures
showErrorDialog( showErrorDialog(
context, context,
S.of(context).incorrectRecoveryKeyTitle, S.of(context).incorrectRecoveryKeyTitle,

View file

@ -84,7 +84,7 @@ class _RequestPasswordVerificationPageState
onPressedFunction: () async { onPressedFunction: () async {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
final dialog = createProgressDialog(context, context.l10n.pleaseWait); final dialog = createProgressDialog(context, context.l10n.pleaseWait);
dialog.show(); await dialog.show();
try { try {
final attributes = Configuration.instance.getKeyAttributes()!; final attributes = Configuration.instance.getKeyAttributes()!;
final Uint8List keyEncryptionKey = await CryptoUtil.deriveKey( final Uint8List keyEncryptionKey = await CryptoUtil.deriveKey(
@ -98,17 +98,18 @@ class _RequestPasswordVerificationPageState
keyEncryptionKey, keyEncryptionKey,
CryptoUtil.base642bin(attributes.keyDecryptionNonce), CryptoUtil.base642bin(attributes.keyDecryptionNonce),
); );
dialog.show(); await dialog.show();
// pop // pop
await widget.onPasswordVerified(keyEncryptionKey); await widget.onPasswordVerified(keyEncryptionKey);
dialog.hide(); await dialog.hide();
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
} catch (e, s) { } catch (e, s) {
_logger.severe("Error while verifying password", e, s); _logger.severe("Error while verifying password", e, s);
dialog.hide(); await dialog.hide();
if (widget.onPasswordError != null) { if (widget.onPasswordError != null) {
widget.onPasswordError!(); widget.onPasswordError!();
} else { } else {
// ignore: unawaited_futures
showErrorDialog( showErrorDialog(
context, context,
context.l10n.incorrectPasswordTitle, context.l10n.incorrectPasswordTitle,

View file

@ -121,6 +121,7 @@ class _SessionsPageState extends State<SessionsPage> {
} catch (e) { } catch (e) {
await dialog.hide(); await dialog.hide();
_logger.severe('failed to terminate'); _logger.severe('failed to terminate');
// ignore: unawaited_futures
showErrorDialog( showErrorDialog(
context, context,
S.of(context).oops, S.of(context).oops,
@ -184,7 +185,7 @@ class _SessionsPageState extends State<SessionsPage> {
if (isLoggingOutFromThisDevice) { if (isLoggingOutFromThisDevice) {
await UserService.instance.logout(context); await UserService.instance.logout(context);
} else { } else {
_terminateSession(session); await _terminateSession(session);
} }
}, },
), ),

View file

@ -114,7 +114,7 @@ class _TwoFactorAuthenticationPageState
child: OutlinedButton( child: OutlinedButton(
onPressed: _code.length == 6 onPressed: _code.length == 6
? () async { ? () async {
_verifyTwoFactorCode(_code); await _verifyTwoFactorCode(_code);
} }
: null, : null,
child: Text(S.of(context).verify), child: Text(S.of(context).verify),

View file

@ -251,7 +251,7 @@ class _TwoFactorSetupPageState extends State<TwoFactorSetupPage>
OutlinedButton( OutlinedButton(
onPressed: _code.length == 6 onPressed: _code.length == 6
? () async { ? () async {
_enableTwoFactor(_code); await _enableTwoFactor(_code);
} }
: null, : null,
child: Text(S.of(context).confirm), child: Text(S.of(context).confirm),

View file

@ -97,6 +97,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
recoveryKey = CryptoUtil.bin2hex( recoveryKey = CryptoUtil.bin2hex(
await UserService.instance.getOrCreateRecoveryKey(context), await UserService.instance.getOrCreateRecoveryKey(context),
); );
// ignore: unawaited_futures
routeToPage( routeToPage(
context, context,
RecoveryKeyPage( RecoveryKeyPage(

View file

@ -1,3 +1,5 @@
import "dart:async";
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import "package:photo_manager/photo_manager.dart"; import "package:photo_manager/photo_manager.dart";
import "package:photos/core/configuration.dart"; import "package:photos/core/configuration.dart";
@ -184,7 +186,7 @@ extension CollectionFileActions on CollectionActions {
if (files.isNotEmpty) { if (files.isNotEmpty) {
await CollectionsService.instance.addToCollection(collectionID, files); await CollectionsService.instance.addToCollection(collectionID, files);
} }
RemoteSyncService.instance.sync(silently: true); unawaited(RemoteSyncService.instance.sync(silently: true));
await dialog?.hide(); await dialog?.hide();
return true; return true;
} catch (e, s) { } catch (e, s) {

View file

@ -115,7 +115,7 @@ class CollectionActions {
S.of(context).creatingLink, S.of(context).creatingLink,
isDismissible: true, isDismissible: true,
); );
dialog.show(); await dialog.show();
try { try {
// create album with emptyName, use collectionCreationTime on UI to // create album with emptyName, use collectionCreationTime on UI to
// show name // show name
@ -143,10 +143,10 @@ class CollectionActions {
await collectionsService.addToCollection(collection.id, files); await collectionsService.addToCollection(collection.id, files);
logger.finest("creating public link for the newly created album"); logger.finest("creating public link for the newly created album");
await CollectionsService.instance.createShareUrl(collection); await CollectionsService.instance.createShareUrl(collection);
dialog.hide(); await dialog.hide();
return collection; return collection;
} catch (e, s) { } catch (e, s) {
dialog.hide(); await dialog.hide();
await showGenericErrorDialog(context: context, error: e); await showGenericErrorDialog(context: context, error: e);
logger.severe("Failing to create link for selected files", e, s); logger.severe("Failing to create link for selected files", e, s);
} }
@ -467,9 +467,7 @@ class CollectionActions {
} }
if (!isCollectionOwner && split.ownedByOtherUsers.isNotEmpty) { if (!isCollectionOwner && split.ownedByOtherUsers.isNotEmpty) {
unawaited( showShortToast(context, S.of(context).canOnlyRemoveFilesOwnedByYou);
showShortToast(context, S.of(context).canOnlyRemoveFilesOwnedByYou),
);
return; return;
} }

View file

@ -1,3 +1,5 @@
import "dart:async";
import "package:flutter/cupertino.dart"; import "package:flutter/cupertino.dart";
import "package:modal_bottom_sheet/modal_bottom_sheet.dart"; import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
import "package:photos/generated/l10n.dart"; import "package:photos/generated/l10n.dart";

View file

@ -189,6 +189,7 @@ class AlbumRowItemWidget extends StatelessWidget {
), ),
onTap: () async { onTap: () async {
final thumbnail = await CollectionsService.instance.getCover(c); final thumbnail = await CollectionsService.instance.getCover(c);
// ignore: unawaited_futures
routeToPage( routeToPage(
context, context,
CollectionPage( CollectionPage(

View file

@ -120,7 +120,7 @@ class AlbumVerticalListWidget extends StatelessWidget {
} }
} else { } else {
Navigator.pop(context); Navigator.pop(context);
await showToast( showToast(
context, context,
S.of(context).createAlbumActionHint, S.of(context).createAlbumActionHint,
); );

View file

@ -400,13 +400,11 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
: await _billingService.cancelStripeSubscription(); : await _billingService.cancelStripeSubscription();
await _fetchSub(); await _fetchSub();
} catch (e) { } catch (e) {
unawaited(
showShortToast( showShortToast(
context, context,
isAutoRenewDisabled isAutoRenewDisabled
? S.of(context).failedToRenew ? S.of(context).failedToRenew
: S.of(context).failedToCancel, : S.of(context).failedToCancel,
),
); );
} }
await _dialog.hide(); await _dialog.hide();

View file

@ -225,7 +225,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
showShortToast( showShortToast(
context, context,
S.of(context).remindToEmptyEnteTrash, S.of(context).remindToEmptyEnteTrash,
).ignore(); );
}, },
); );
} }

View file

@ -50,7 +50,7 @@ class DebugSectionWidget extends StatelessWidget {
trailingIconIsMuted: true, trailingIconIsMuted: true,
onTap: () async { onTap: () async {
await LocalSyncService.instance.resetLocalSync(); await LocalSyncService.instance.resetLocalSync();
showShortToast(context, "Done").ignore(); showShortToast(context, "Done");
}, },
), ),
sectionOptionSpacing, sectionOptionSpacing,
@ -64,7 +64,7 @@ class DebugSectionWidget extends StatelessWidget {
onTap: () async { onTap: () async {
await IgnoredFilesService.instance.reset(); await IgnoredFilesService.instance.reset();
SyncService.instance.sync().ignore(); SyncService.instance.sync().ignore();
showShortToast(context, "Done").ignore(); showShortToast(context, "Done");
}, },
), ),
sectionOptionSpacing, sectionOptionSpacing,

View file

@ -279,7 +279,7 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
} }
await UserService.instance.updateEmailMFA(isEnabled); await UserService.instance.updateEmailMFA(isEnabled);
} catch (e) { } catch (e) {
showToast(context, S.of(context).somethingWentWrong).ignore(); showToast(context, S.of(context).somethingWentWrong);
} }
} }
} }

View file

@ -139,7 +139,7 @@ class OutgoingAlbumEmptyState extends StatelessWidget {
labelText: S.of(context).shareYourFirstAlbum, labelText: S.of(context).shareYourFirstAlbum,
icon: Icons.add, icon: Icons.add,
onTap: () async { onTap: () async {
await showToast( showToast(
context, context,
S.of(context).shareAlbumHint, S.of(context).shareAlbumHint,
); );

View file

@ -502,11 +502,9 @@ class _FileSelectionActionsWidgetState
Future<void> _onCreatedSharedLinkClicked() async { Future<void> _onCreatedSharedLinkClicked() async {
if (split.ownedByCurrentUser.isEmpty) { if (split.ownedByCurrentUser.isEmpty) {
unawaited(
showShortToast( showShortToast(
context, context,
S.of(context).canOnlyCreateLinkForFilesOwnedByYou, S.of(context).canOnlyCreateLinkForFilesOwnedByYou,
),
); );
return; return;
} }
@ -570,7 +568,7 @@ class _FileSelectionActionsWidgetState
final String url = final String url =
"${_cachedCollectionForSharedLink!.publicURLs?.first?.url}#$collectionKey"; "${_cachedCollectionForSharedLink!.publicURLs?.first?.url}#$collectionKey";
await Clipboard.setData(ClipboardData(text: url)); await Clipboard.setData(ClipboardData(text: url));
unawaited(showShortToast(context, S.of(context).linkCopiedToClipboard)); showShortToast(context, S.of(context).linkCopiedToClipboard);
} }
} }

View file

@ -22,7 +22,6 @@ import 'package:photos/ui/common/loading_widget.dart';
import 'package:photos/utils/file_util.dart'; import 'package:photos/utils/file_util.dart';
import 'package:photos/utils/image_util.dart'; import 'package:photos/utils/image_util.dart';
import 'package:photos/utils/thumbnail_util.dart'; import 'package:photos/utils/thumbnail_util.dart';
import "package:photos/utils/toast_util.dart";
class ZoomableImage extends StatefulWidget { class ZoomableImage extends StatefulWidget {
final EnteFile photo; final EnteFile photo;
@ -262,12 +261,6 @@ class _ZoomableImageState extends State<ZoomableImage>
final bool shouldFixPosition = previewImageProvider != null && _isZooming; final bool shouldFixPosition = previewImageProvider != null && _isZooming;
ImageInfo? finalImageInfo; ImageInfo? finalImageInfo;
if (shouldFixPosition) { if (shouldFixPosition) {
if (kDebugMode) {
showToast(
context,
'Updating photo scale zooming and scale: ${_photoViewController.scale}',
).ignore();
}
final prevImageInfo = await getImageInfo(previewImageProvider); final prevImageInfo = await getImageInfo(previewImageProvider);
finalImageInfo = await getImageInfo(finalImageProvider); finalImageInfo = await getImageInfo(finalImageProvider);
final scale = _photoViewController.scale! / final scale = _photoViewController.scale! /
@ -303,9 +296,6 @@ class _ZoomableImageState extends State<ZoomableImage>
if (h != enteFile.height || w != enteFile.width) { if (h != enteFile.height || w != enteFile.width) {
final logMessage = final logMessage =
'Updating aspect ratio for from ${enteFile.height}x${enteFile.width} to ${h}x$w'; 'Updating aspect ratio for from ${enteFile.height}x${enteFile.width} to ${h}x$w';
if (kDebugMode && (enteFile.height != 0 || enteFile.width != 0)) {
showToast(context, logMessage).ignore();
}
_logger.info(logMessage); _logger.info(logMessage);
await FileMagicService.instance.updatePublicMagicMetadata([ await FileMagicService.instance.updatePublicMagicMetadata([
enteFile, enteFile,

View file

@ -79,11 +79,9 @@ class _FavoriteWidgetState extends State<FavoriteWidget> {
} catch (e, s) { } catch (e, s) {
_logger.severe(e, s); _logger.severe(e, s);
hasError = true; hasError = true;
unawaited(
showToast( showToast(
context, context,
S.of(context).sorryCouldNotRemoveFromFavorites, S.of(context).sorryCouldNotRemoveFromFavorites,
),
); );
} }
} }

View file

@ -141,7 +141,7 @@ class GalleryState extends State<Gallery> {
// todo: Assign ID to Gallery and fire generic event with ID & // todo: Assign ID to Gallery and fire generic event with ID &
// target index/date // target index/date
if (mounted && event.selectedIndex == 0) { if (mounted && event.selectedIndex == 0) {
_itemScroller.scrollTo( await _itemScroller.scrollTo(
index: 0, index: 0,
duration: const Duration(milliseconds: 150), duration: const Duration(milliseconds: 150),
); );

View file

@ -131,12 +131,10 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
if (galleryType != GalleryType.ownedCollection && if (galleryType != GalleryType.ownedCollection &&
galleryType != GalleryType.hiddenOwnedCollection && galleryType != GalleryType.hiddenOwnedCollection &&
galleryType != GalleryType.quickLink) { galleryType != GalleryType.quickLink) {
unawaited(
showToast( showToast(
context, context,
'Type of galler $galleryType is not supported for ' 'Type of galler $galleryType is not supported for '
'rename', 'rename',
),
); );
return; return;
@ -269,7 +267,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
showToast( showToast(
context, context,
S.of(context).remindToEmptyDeviceTrash, S.of(context).remindToEmptyDeviceTrash,
).ignore(); );
} }
}, },
); );
@ -614,7 +612,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
context, context,
); );
} else { } else {
unawaited(showToast(context, S.of(context).somethingWentWrong)); showToast(context, S.of(context).somethingWentWrong);
} }
}, },
), ),

View file

@ -216,7 +216,7 @@ class AddPhotosPhotoWidget extends StatelessWidget {
}, },
); );
} else { } else {
showErrorDialog( await showErrorDialog(
context, context,
context.l10n.oops, context.l10n.oops,
context.l10n.somethingWentWrong + (kDebugMode ? "\n$e" : ""), context.l10n.somethingWentWrong + (kDebugMode ? "\n$e" : ""),

View file

@ -22,6 +22,7 @@ class GoToMapWidget extends StatelessWidget {
onTap: () async { onTap: () async {
final bool result = await requestForMapEnable(context); final bool result = await requestForMapEnable(context);
if (result) { if (result) {
// ignore: unawaited_futures
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => MapScreen( builder: (context) => MapScreen(

View file

@ -35,6 +35,7 @@ class SearchTabEmptyState extends StatelessWidget {
labelText: S.of(context).addYourPhotosNow, labelText: S.of(context).addYourPhotosNow,
icon: Icons.arrow_forward_outlined, icon: Icons.arrow_forward_outlined,
onTap: () async { onTap: () async {
// ignore: unawaited_futures
routeToPage( routeToPage(
context, context,
BackupFolderSelectionPage( BackupFolderSelectionPage(

View file

@ -127,9 +127,9 @@ Future<void> deleteFilesFromEverywhere(
), ),
); );
if (hasLocalOnlyFiles && Platform.isAndroid) { if (hasLocalOnlyFiles && Platform.isAndroid) {
await showShortToast(context, S.of(context).filesDeleted); showShortToast(context, S.of(context).filesDeleted);
} else { } else {
await showShortToast(context, S.of(context).movedToTrash); showShortToast(context, S.of(context).movedToTrash);
} }
} }
if (uploadedFilesToBeTrashed.isNotEmpty) { if (uploadedFilesToBeTrashed.isNotEmpty) {

View file

@ -106,6 +106,7 @@ class FileUploader {
); );
_logger.info("BG task was found dead, cleared all locks"); _logger.info("BG task was found dead, cleared all locks");
} }
// ignore: unawaited_futures
_pollBackgroundUploadStatus(); _pollBackgroundUploadStatus();
} }
Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) { Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) {

View file

@ -165,9 +165,10 @@ Future<File?> getFileFromServer(
}, },
); );
} }
downloadFuture.then((downloadedFile) { // ignore: unawaited_futures
downloadFuture.then((downloadedFile) async {
completer.complete(downloadedFile); completer.complete(downloadedFile);
_fileDownloadsInProgress.remove(downloadID); await _fileDownloadsInProgress.remove(downloadID);
_progressCallbacks.remove(downloadID); _progressCallbacks.remove(downloadID);
}); });
} }
@ -197,7 +198,7 @@ Future<File?> _getLivePhotoFromServer(
_downloadLivePhoto(file, progressCallback: progressCallback); _downloadLivePhoto(file, progressCallback: progressCallback);
} }
final livePhoto = await _livePhotoDownloadsTracker[file.uploadedFileID]; final livePhoto = await _livePhotoDownloadsTracker[file.uploadedFileID];
_livePhotoDownloadsTracker.remove(downloadID); await _livePhotoDownloadsTracker.remove(downloadID);
if (livePhoto == null) { if (livePhoto == null) {
return null; return null;
} }

View file

@ -116,7 +116,7 @@ Future<void> changeSortOrder(
); );
} catch (e, s) { } catch (e, s) {
_logger.severe("failed to update collection visibility", e, s); _logger.severe("failed to update collection visibility", e, s);
unawaited(showShortToast(context, S.of(context).somethingWentWrong)); showShortToast(context, S.of(context).somethingWentWrong);
rethrow; rethrow;
} }
} }
@ -136,7 +136,7 @@ Future<void> updateOrder(
); );
} catch (e, s) { } catch (e, s) {
_logger.severe("failed to update order", e, s); _logger.severe("failed to update order", e, s);
unawaited(showShortToast(context, S.of(context).somethingWentWrong)); showShortToast(context, S.of(context).somethingWentWrong);
rethrow; rethrow;
} }
} }
@ -162,7 +162,7 @@ Future<void> changeCoverPhoto(
); );
} catch (e, s) { } catch (e, s) {
_logger.severe("failed to update cover", e, s); _logger.severe("failed to update cover", e, s);
unawaited(showShortToast(context, S.of(context).somethingWentWrong)); showShortToast(context, S.of(context).somethingWentWrong);
rethrow; rethrow;
} }
} }
@ -181,7 +181,7 @@ Future<bool> editTime(
); );
return true; return true;
} catch (e) { } catch (e) {
showShortToast(context, S.of(context).somethingWentWrong).ignore(); showShortToast(context, S.of(context).somethingWentWrong);
return false; return false;
} }
} }
@ -240,7 +240,7 @@ Future<bool> editFileCaption(
return true; return true;
} catch (e) { } catch (e) {
if (context != null) { if (context != null) {
unawaited(showShortToast(context, S.of(context).somethingWentWrong)); showShortToast(context, S.of(context).somethingWentWrong);
} }
return false; return false;
} }
@ -267,7 +267,7 @@ Future<void> _updatePublicMetadata(
await FileMagicService.instance.updatePublicMagicMetadata(files, update); await FileMagicService.instance.updatePublicMagicMetadata(files, update);
if (context != null) { if (context != null) {
if (showDoneToast) { if (showDoneToast) {
await showShortToast(context, S.of(context).done); showShortToast(context, S.of(context).done);
} }
await dialog?.hide(); await dialog?.hide();
} }

View file

@ -1,3 +1,4 @@
import "dart:async";
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -5,7 +6,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:photos/ente_theme_data.dart'; import 'package:photos/ente_theme_data.dart';
Future showToast( void showToast(
BuildContext context, BuildContext context,
String message, { String message, {
toastLength = Toast.LENGTH_LONG, toastLength = Toast.LENGTH_LONG,
@ -13,7 +14,8 @@ Future showToast(
}) async { }) async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
await Fluttertoast.cancel(); await Fluttertoast.cancel();
return Fluttertoast.showToast( unawaited(
Fluttertoast.showToast(
msg: message, msg: message,
toastLength: toastLength, toastLength: toastLength,
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
@ -21,6 +23,7 @@ Future showToast(
backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor, backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor,
textColor: Theme.of(context).colorScheme.toastTextColor, textColor: Theme.of(context).colorScheme.toastTextColor,
fontSize: 16.0, fontSize: 16.0,
),
); );
} else { } else {
EasyLoading.instance EasyLoading.instance
@ -29,7 +32,8 @@ Future showToast(
..textColor = Theme.of(context).colorScheme.toastTextColor ..textColor = Theme.of(context).colorScheme.toastTextColor
..userInteractions = true ..userInteractions = true
..loadingStyle = EasyLoadingStyle.custom; ..loadingStyle = EasyLoadingStyle.custom;
return EasyLoading.showToast( unawaited(
EasyLoading.showToast(
message, message,
duration: Duration( duration: Duration(
seconds: seconds:
@ -37,10 +41,11 @@ Future showToast(
), ),
toastPosition: EasyLoadingToastPosition.bottom, toastPosition: EasyLoadingToastPosition.bottom,
dismissOnTap: false, dismissOnTap: false,
),
); );
} }
} }
Future<void> showShortToast(context, String message) { void showShortToast(context, String message) {
return showToast(context, message, toastLength: Toast.LENGTH_SHORT); showToast(context, message, toastLength: Toast.LENGTH_SHORT);
} }