handle more interactions like uploading and single asset links
This commit is contained in:
@@ -1,14 +1,34 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:immich_mobile/domain/models/album/shared_album.model.dart';
|
||||
import 'package:immich_mobile/repositories/asset_api.repository.dart';
|
||||
import 'package:immich_mobile/repositories/drift_album_api_repository.dart';
|
||||
|
||||
class RemoteSharedAlbumService {
|
||||
final DriftAlbumApiRepository _albumApiRepository;
|
||||
final AssetApiRepository _assetApiRepository;
|
||||
|
||||
const RemoteSharedAlbumService(this._albumApiRepository);
|
||||
const RemoteSharedAlbumService(this._albumApiRepository, this._assetApiRepository);
|
||||
|
||||
Future<SharedRemoteAlbum?> getSharedAlbum(String albumId) {
|
||||
return _albumApiRepository.getShared(albumId);
|
||||
}
|
||||
|
||||
Future<int> uploadAssets(String albumId, List<XFile> files) async {
|
||||
// Start all uploads concurrently
|
||||
final uploadFutures = files.map((file) => _assetApiRepository.uploadAsset(file)).toList();
|
||||
|
||||
// Wait for all uploads to complete
|
||||
final assetIds = await Future.wait(uploadFutures);
|
||||
|
||||
// Filter out null assetIds
|
||||
final completedUploads = assetIds.whereType<String>().toList();
|
||||
|
||||
if (completedUploads.isNotEmpty) {
|
||||
await _albumApiRepository.addAssets(albumId, completedUploads);
|
||||
}
|
||||
|
||||
return completedUploads.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,6 @@ class TimelineService {
|
||||
BaseAsset getRandomAsset() => _buffer.elementAt(math.Random().nextInt(_buffer.length));
|
||||
|
||||
BaseAsset getAsset(int index) {
|
||||
print("buffer len: " + _buffer.length.toString());
|
||||
if (!hasRange(index, 1)) {
|
||||
throw RangeError(
|
||||
'TimelineService::getAsset Index $index not in buffer range [$_bufferOffset, ${_bufferOffset + _buffer.length})',
|
||||
|
||||
Reference in New Issue
Block a user