From fde09595791969ab1813dfa4fa7278bf4a2fd770 Mon Sep 17 00:00:00 2001
From: Peter Ombodi
Date: Wed, 22 Apr 2026 14:42:35 +0300
Subject: [PATCH] style(mobile): reformat code #2
---
mobile/lib/main.dart | 1 -
.../share_intent_upload.provider.dart | 196 +++++++++---------
2 files changed, 98 insertions(+), 99 deletions(-)
diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart
index ddc974ab6e..d9125e67fb 100644
--- a/mobile/lib/main.dart
+++ b/mobile/lib/main.dart
@@ -121,7 +121,6 @@ class ImmichApp extends ConsumerStatefulWidget {
}
class ImmichAppState extends ConsumerState with WidgetsBindingObserver {
-
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
diff --git a/mobile/lib/providers/asset_viewer/share_intent_upload.provider.dart b/mobile/lib/providers/asset_viewer/share_intent_upload.provider.dart
index cbe8a329b9..8bd0581061 100644
--- a/mobile/lib/providers/asset_viewer/share_intent_upload.provider.dart
+++ b/mobile/lib/providers/asset_viewer/share_intent_upload.provider.dart
@@ -1,101 +1,101 @@
-import 'dart:io';
-
-import 'package:hooks_riverpod/hooks_riverpod.dart';
-import 'package:immich_mobile/models/upload/share_intent_attachment.model.dart';
-import 'package:immich_mobile/routing/router.dart';
-import 'package:immich_mobile/services/share_intent_service.dart';
-import 'package:immich_mobile/services/foreground_upload.service.dart';
-import 'package:logging/logging.dart';
-import 'package:path/path.dart' as p;
-
-final shareIntentUploadProvider = StateNotifierProvider>(
- ((ref) => ShareIntentUploadStateNotifier(
- ref.watch(appRouterProvider),
- ref.read(foregroundUploadServiceProvider),
- ref.read(shareIntentServiceProvider),
- )),
-);
-
-class ShareIntentUploadStateNotifier extends StateNotifier> {
- final AppRouter router;
- final ForegroundUploadService _foregroundUploadService;
- final ShareIntentService _shareIntentService;
- final Logger _logger = Logger('ShareIntentUploadStateNotifier');
-
- ShareIntentUploadStateNotifier(this.router, this._foregroundUploadService, this._shareIntentService) : super([]);
-
- void init() {
- _shareIntentService.onSharedMedia = onSharedMedia;
- _shareIntentService.init();
- }
-
- void onSharedMedia(List attachments) {
- router.removeWhere((route) => route.name == "ShareIntentRoute");
- clearAttachments();
- addAttachments(attachments);
- router.push(ShareIntentRoute(attachments: attachments));
- }
-
- void addAttachments(List attachments) {
- if (attachments.isEmpty) {
- return;
- }
- state = [...state, ...attachments];
- }
-
- void removeAttachment(ShareIntentAttachment attachment) {
- final updatedState = state.where((element) => element != attachment).toList();
- if (updatedState.length != state.length) {
- state = updatedState;
- }
- }
-
- void clearAttachments() {
- if (state.isEmpty) {
- return;
- }
-
- state = [];
- }
-
- Future uploadAll(List files) async {
- for (final file in files) {
- final fileId = p.hash(file.path).toString();
- _updateStatus(fileId, UploadStatus.running);
- }
-
- await _foregroundUploadService.uploadShareIntent(
- files,
- onProgress: (fileId, bytes, totalBytes) {
- final progress = totalBytes > 0 ? bytes / totalBytes : 0.0;
- _updateProgress(fileId, progress);
- },
+import 'dart:io';
+
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:immich_mobile/models/upload/share_intent_attachment.model.dart';
+import 'package:immich_mobile/routing/router.dart';
+import 'package:immich_mobile/services/foreground_upload.service.dart';
+import 'package:immich_mobile/services/share_intent_service.dart';
+import 'package:logging/logging.dart';
+import 'package:path/path.dart' as p;
+
+final shareIntentUploadProvider = StateNotifierProvider>(
+ ((ref) => ShareIntentUploadStateNotifier(
+ ref.watch(appRouterProvider),
+ ref.read(foregroundUploadServiceProvider),
+ ref.read(shareIntentServiceProvider),
+ )),
+);
+
+class ShareIntentUploadStateNotifier extends StateNotifier> {
+ final AppRouter router;
+ final ForegroundUploadService _foregroundUploadService;
+ final ShareIntentService _shareIntentService;
+ final Logger _logger = Logger('ShareIntentUploadStateNotifier');
+
+ ShareIntentUploadStateNotifier(this.router, this._foregroundUploadService, this._shareIntentService) : super([]);
+
+ void init() {
+ _shareIntentService.onSharedMedia = onSharedMedia;
+ _shareIntentService.init();
+ }
+
+ void onSharedMedia(List attachments) {
+ router.removeWhere((route) => route.name == "ShareIntentRoute");
+ clearAttachments();
+ addAttachments(attachments);
+ router.push(ShareIntentRoute(attachments: attachments));
+ }
+
+ void addAttachments(List attachments) {
+ if (attachments.isEmpty) {
+ return;
+ }
+ state = [...state, ...attachments];
+ }
+
+ void removeAttachment(ShareIntentAttachment attachment) {
+ final updatedState = state.where((element) => element != attachment).toList();
+ if (updatedState.length != state.length) {
+ state = updatedState;
+ }
+ }
+
+ void clearAttachments() {
+ if (state.isEmpty) {
+ return;
+ }
+
+ state = [];
+ }
+
+ Future uploadAll(List files) async {
+ for (final file in files) {
+ final fileId = p.hash(file.path).toString();
+ _updateStatus(fileId, UploadStatus.running);
+ }
+
+ await _foregroundUploadService.uploadShareIntent(
+ files,
+ onProgress: (fileId, bytes, totalBytes) {
+ final progress = totalBytes > 0 ? bytes / totalBytes : 0.0;
+ _updateProgress(fileId, progress);
+ },
onSuccess: (fileId, _) {
_updateStatus(fileId, UploadStatus.complete, progress: 1.0);
},
- onError: (fileId, errorMessage) {
- _logger.warning("Upload failed for file: $fileId, error: $errorMessage");
- _updateStatus(fileId, UploadStatus.failed);
- },
- );
- }
-
- void _updateStatus(String fileId, UploadStatus status, {double? progress}) {
- final id = int.parse(fileId);
- state = [
- for (final attachment in state)
- if (attachment.id == id)
- attachment.copyWith(status: status, uploadProgress: progress ?? attachment.uploadProgress)
- else
- attachment,
- ];
- }
-
- void _updateProgress(String fileId, double progress) {
- final id = int.parse(fileId);
- state = [
- for (final attachment in state)
- if (attachment.id == id) attachment.copyWith(uploadProgress: progress) else attachment,
- ];
- }
-}
+ onError: (fileId, errorMessage) {
+ _logger.warning("Upload failed for file: $fileId, error: $errorMessage");
+ _updateStatus(fileId, UploadStatus.failed);
+ },
+ );
+ }
+
+ void _updateStatus(String fileId, UploadStatus status, {double? progress}) {
+ final id = int.parse(fileId);
+ state = [
+ for (final attachment in state)
+ if (attachment.id == id)
+ attachment.copyWith(status: status, uploadProgress: progress ?? attachment.uploadProgress)
+ else
+ attachment,
+ ];
+ }
+
+ void _updateProgress(String fileId, double progress) {
+ final id = int.parse(fileId);
+ state = [
+ for (final attachment in state)
+ if (attachment.id == id) attachment.copyWith(uploadProgress: progress) else attachment,
+ ];
+ }
+}