immich/mobile/lib/providers/backup/asset_upload_progress.provider.dart
Mert a05c8c6087
feat(mobile): use shared native client (#25942)
* use shared client in dart

fix android

* websocket integration

platform-side headers

update comment

consistent platform check

tweak websocket handling

support streaming

* redundant logging

* fix proguard

* formatting

* handle onProgress

* support videos on ios

* inline return

* improved ios impl

* cleanup

* sync stopForegroundBackup

* voidify

* future already completed

* stream request on android

* outdated ios ws code

* use `choosePrivateKeyAlias`

* return result

* formatting

* update tests

* redundant check

* handle custom headers

* move completer outside of state

* persist auth

* dispose old socket

* use group id for cookies

* redundant headers

* cache global ref

* handle network switching

* handle basic auth

* apply custom headers immediately

* video player update

* fix

* persist url

* potential logout fix

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
2026-03-05 11:04:45 -06:00

35 lines
928 B
Dart

import 'dart:async';
import 'package:hooks_riverpod/hooks_riverpod.dart';
/// Tracks per-asset upload progress.
/// Key: local asset ID, Value: upload progress 0.0 to 1.0, or -1.0 for error
class AssetUploadProgressNotifier extends Notifier<Map<String, double>> {
static const double errorValue = -1.0;
@override
Map<String, double> build() => {};
void setProgress(String localAssetId, double progress) {
state = {...state, localAssetId: progress};
}
void setError(String localAssetId) {
state = {...state, localAssetId: errorValue};
}
void remove(String localAssetId) {
state = Map.from(state)..remove(localAssetId);
}
void clear() {
state = {};
}
}
final assetUploadProgressProvider = NotifierProvider<AssetUploadProgressNotifier, Map<String, double>>(
AssetUploadProgressNotifier.new,
);
final manualUploadCancelTokenProvider = StateProvider<Completer<void>?>((ref) => null);