chore: bump dart sdk to 3.8 (#20355)
* chore: bump dart sdk to 3.8 * chore: make build * make pigeon * chore: format files --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -19,12 +19,7 @@ class ActivityApiRepository extends ApiRepository {
|
||||
return response.map(_toActivity).toList();
|
||||
}
|
||||
|
||||
Future<Activity> create(
|
||||
String albumId,
|
||||
ActivityType type, {
|
||||
String? assetId,
|
||||
String? comment,
|
||||
}) async {
|
||||
Future<Activity> create(String albumId, ActivityType type, {String? assetId, String? comment}) async {
|
||||
final dto = ActivityCreateDto(
|
||||
albumId: albumId,
|
||||
type: type == ActivityType.comment ? ReactionType.comment : ReactionType.like,
|
||||
@@ -45,11 +40,11 @@ class ActivityApiRepository extends ApiRepository {
|
||||
}
|
||||
|
||||
static Activity _toActivity(ActivityResponseDto dto) => Activity(
|
||||
id: dto.id,
|
||||
createdAt: dto.createdAt,
|
||||
type: dto.type == ReactionType.comment ? ActivityType.comment : ActivityType.like,
|
||||
user: UserConverter.fromSimpleUserDto(dto.user),
|
||||
assetId: dto.assetId,
|
||||
comment: dto.comment,
|
||||
);
|
||||
id: dto.id,
|
||||
createdAt: dto.createdAt,
|
||||
type: dto.type == ReactionType.comment ? ActivityType.comment : ActivityType.like,
|
||||
user: UserConverter.fromSimpleUserDto(dto.user),
|
||||
assetId: dto.assetId,
|
||||
comment: dto.comment,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,12 +30,7 @@ class AlbumRepository extends DatabaseRepository {
|
||||
|
||||
Future<Album> create(Album album) => txn(() => db.albums.store(album));
|
||||
|
||||
Future<Album?> getByName(
|
||||
String name, {
|
||||
bool? shared,
|
||||
bool? remote,
|
||||
bool? owner,
|
||||
}) {
|
||||
Future<Album?> getByName(String name, {bool? shared, bool? remote, bool? owner}) {
|
||||
var query = db.albums.filter().nameEqualTo(name);
|
||||
if (shared != null) {
|
||||
query = query.sharedEqualTo(shared);
|
||||
@@ -58,12 +53,7 @@ class AlbumRepository extends DatabaseRepository {
|
||||
|
||||
Future<void> delete(int albumId) => txn(() => db.albums.delete(albumId));
|
||||
|
||||
Future<List<Album>> getAll({
|
||||
bool? shared,
|
||||
bool? remote,
|
||||
int? ownerId,
|
||||
AlbumSort? sortBy,
|
||||
}) {
|
||||
Future<List<Album>> getAll({bool? shared, bool? remote, int? ownerId, AlbumSort? sortBy}) {
|
||||
final baseQuery = db.albums.where();
|
||||
final QueryBuilder<Album, Album, QAfterWhereClause> afterWhere;
|
||||
if (remote == null) {
|
||||
@@ -94,9 +84,8 @@ class AlbumRepository extends DatabaseRepository {
|
||||
return db.albums.filter().remoteIdEqualTo(remoteId).findFirst();
|
||||
}
|
||||
|
||||
Future<void> removeUsers(Album album, List<UserDto> users) => txn(
|
||||
() => album.sharedUsers.update(unlink: users.map(entity.User.fromDto)),
|
||||
);
|
||||
Future<void> removeUsers(Album album, List<UserDto> users) =>
|
||||
txn(() => album.sharedUsers.update(unlink: users.map(entity.User.fromDto)));
|
||||
|
||||
Future<void> addAssets(Album album, List<Asset> assets) => txn(() => album.assets.update(link: assets));
|
||||
|
||||
@@ -114,10 +103,7 @@ class AlbumRepository extends DatabaseRepository {
|
||||
|
||||
Future<void> deleteAllLocal() => txn(() => db.albums.where().localIdIsNotNull().deleteAll());
|
||||
|
||||
Future<List<Album>> search(
|
||||
String searchTerm,
|
||||
QuickFilterMode filterMode,
|
||||
) async {
|
||||
Future<List<Album>> search(String searchTerm, QuickFilterMode filterMode) async {
|
||||
var query = db.albums.filter().nameContains(searchTerm, caseSensitive: false).remoteIdIsNotNull();
|
||||
final isarUserId = fastHash(Store.get(StoreKey.currentUser).id);
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ import 'package:immich_mobile/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/repositories/api.repository.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final albumApiRepositoryProvider = Provider(
|
||||
(ref) => AlbumApiRepository(ref.watch(apiServiceProvider).albumsApi),
|
||||
);
|
||||
final albumApiRepositoryProvider = Provider((ref) => AlbumApiRepository(ref.watch(apiServiceProvider).albumsApi));
|
||||
|
||||
class AlbumApiRepository extends ApiRepository {
|
||||
final AlbumsApi _api;
|
||||
@@ -34,9 +32,7 @@ class AlbumApiRepository extends ApiRepository {
|
||||
Iterable<String> sharedUserIds = const [],
|
||||
String? description,
|
||||
}) async {
|
||||
final users = sharedUserIds.map(
|
||||
(id) => AlbumUserCreateDto(userId: id, role: AlbumUserRole.editor),
|
||||
);
|
||||
final users = sharedUserIds.map((id) => AlbumUserCreateDto(userId: id, role: AlbumUserRole.editor));
|
||||
final responseDto = await checkNull(
|
||||
_api.createAlbum(
|
||||
CreateAlbumDto(
|
||||
@@ -51,19 +47,9 @@ class AlbumApiRepository extends ApiRepository {
|
||||
}
|
||||
|
||||
// TODO: Change name after removing old method
|
||||
Future<RemoteAlbum> createDriftAlbum(
|
||||
String name, {
|
||||
required Iterable<String> assetIds,
|
||||
String? description,
|
||||
}) async {
|
||||
Future<RemoteAlbum> createDriftAlbum(String name, {required Iterable<String> assetIds, String? description}) async {
|
||||
final responseDto = await checkNull(
|
||||
_api.createAlbum(
|
||||
CreateAlbumDto(
|
||||
albumName: name,
|
||||
description: description,
|
||||
assetIds: assetIds.toList(),
|
||||
),
|
||||
),
|
||||
_api.createAlbum(CreateAlbumDto(albumName: name, description: description, assetIds: assetIds.toList())),
|
||||
);
|
||||
|
||||
return _toRemoteAlbum(responseDto);
|
||||
@@ -102,16 +88,8 @@ class AlbumApiRepository extends ApiRepository {
|
||||
return _api.deleteAlbum(albumId);
|
||||
}
|
||||
|
||||
Future<({List<String> added, List<String> duplicates})> addAssets(
|
||||
String albumId,
|
||||
Iterable<String> assetIds,
|
||||
) async {
|
||||
final response = await checkNull(
|
||||
_api.addAssetsToAlbum(
|
||||
albumId,
|
||||
BulkIdsDto(ids: assetIds.toList()),
|
||||
),
|
||||
);
|
||||
Future<({List<String> added, List<String> duplicates})> addAssets(String albumId, Iterable<String> assetIds) async {
|
||||
final response = await checkNull(_api.addAssetsToAlbum(albumId, BulkIdsDto(ids: assetIds.toList())));
|
||||
|
||||
final List<String> added = [];
|
||||
final List<String> duplicates = [];
|
||||
@@ -126,16 +104,8 @@ class AlbumApiRepository extends ApiRepository {
|
||||
return (added: added, duplicates: duplicates);
|
||||
}
|
||||
|
||||
Future<({List<String> removed, List<String> failed})> removeAssets(
|
||||
String albumId,
|
||||
Iterable<String> assetIds,
|
||||
) async {
|
||||
final response = await checkNull(
|
||||
_api.removeAssetFromAlbum(
|
||||
albumId,
|
||||
BulkIdsDto(ids: assetIds.toList()),
|
||||
),
|
||||
);
|
||||
Future<({List<String> removed, List<String> failed})> removeAssets(String albumId, Iterable<String> assetIds) async {
|
||||
final response = await checkNull(_api.removeAssetFromAlbum(albumId, BulkIdsDto(ids: assetIds.toList())));
|
||||
final List<String> removed = [], failed = [];
|
||||
for (final dto in response) {
|
||||
if (dto.success) {
|
||||
@@ -149,12 +119,7 @@ class AlbumApiRepository extends ApiRepository {
|
||||
|
||||
Future<Album> addUsers(String albumId, Iterable<String> userIds) async {
|
||||
final albumUsers = userIds.map((userId) => AlbumUserAddDto(userId: userId)).toList();
|
||||
final response = await checkNull(
|
||||
_api.addUsersToAlbum(
|
||||
albumId,
|
||||
AddUsersDto(albumUsers: albumUsers),
|
||||
),
|
||||
);
|
||||
final response = await checkNull(_api.addUsersToAlbum(albumId, AddUsersDto(albumUsers: albumUsers)));
|
||||
return _toAlbum(response);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,32 +18,30 @@ class AlbumMediaRepository {
|
||||
DateTimeCond? updateTimeCond,
|
||||
bool? containsPathModified,
|
||||
List<OrderOption>? orderBy,
|
||||
}) =>
|
||||
useCustomFilter
|
||||
? FilterOptionGroup(
|
||||
imageOption: const FilterOption(
|
||||
needTitle: true,
|
||||
sizeConstraint: SizeConstraint(ignoreSize: true),
|
||||
),
|
||||
videoOption: const FilterOption(
|
||||
needTitle: true,
|
||||
sizeConstraint: SizeConstraint(ignoreSize: true),
|
||||
durationConstraint: DurationConstraint(allowNullable: true),
|
||||
),
|
||||
containsPathModified: containsPathModified ?? false,
|
||||
createTimeCond: DateTimeCond.def().copyWith(ignore: true),
|
||||
updateTimeCond: updateTimeCond ?? DateTimeCond.def().copyWith(ignore: true),
|
||||
orders: orderBy ?? [],
|
||||
)
|
||||
: null;
|
||||
}) => useCustomFilter
|
||||
? FilterOptionGroup(
|
||||
imageOption: const FilterOption(needTitle: true, sizeConstraint: SizeConstraint(ignoreSize: true)),
|
||||
videoOption: const FilterOption(
|
||||
needTitle: true,
|
||||
sizeConstraint: SizeConstraint(ignoreSize: true),
|
||||
durationConstraint: DurationConstraint(allowNullable: true),
|
||||
),
|
||||
containsPathModified: containsPathModified ?? false,
|
||||
createTimeCond: DateTimeCond.def().copyWith(ignore: true),
|
||||
updateTimeCond: updateTimeCond ?? DateTimeCond.def().copyWith(ignore: true),
|
||||
orders: orderBy ?? [],
|
||||
)
|
||||
: null;
|
||||
|
||||
Future<List<Album>> getAll() async {
|
||||
final filter = useCustomFilter
|
||||
? CustomFilter.sql(where: '${CustomColumns.base.width} > 0')
|
||||
: FilterOptionGroup(containsPathModified: true);
|
||||
|
||||
final List<AssetPathEntity> assetPathEntities =
|
||||
await PhotoManager.getAssetPathList(hasAll: true, filterOption: filter);
|
||||
final List<AssetPathEntity> assetPathEntities = await PhotoManager.getAssetPathList(
|
||||
hasAll: true,
|
||||
filterOption: filter,
|
||||
);
|
||||
return assetPathEntities.map(_toAlbum).toList();
|
||||
}
|
||||
|
||||
@@ -71,10 +69,7 @@ class AlbumMediaRepository {
|
||||
filterOption: _getAlbumFilter(
|
||||
updateTimeCond: modifiedFrom == null && modifiedUntil == null
|
||||
? null
|
||||
: DateTimeCond(
|
||||
min: modifiedFrom ?? DateTime.utc(-271820),
|
||||
max: modifiedUntil ?? DateTime.utc(275760),
|
||||
),
|
||||
: DateTimeCond(min: modifiedFrom ?? DateTime.utc(-271820), max: modifiedUntil ?? DateTime.utc(275760)),
|
||||
orderBy: orderByModificationDate ? [const OrderOption(type: OrderOptionType.updateDate)] : [],
|
||||
),
|
||||
);
|
||||
@@ -84,10 +79,7 @@ class AlbumMediaRepository {
|
||||
}
|
||||
|
||||
Future<Album> get(String id) async {
|
||||
final assetPathEntity = await AssetPathEntity.fromId(
|
||||
id,
|
||||
filterOption: _getAlbumFilter(containsPathModified: true),
|
||||
);
|
||||
final assetPathEntity = await AssetPathEntity.fromId(id, filterOption: _getAlbumFilter(containsPathModified: true));
|
||||
return _toAlbum(assetPathEntity);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,16 +52,13 @@ class AssetRepository extends DatabaseRepository {
|
||||
}
|
||||
|
||||
Future<void> deleteByIds(List<int> ids) => txn(() async {
|
||||
await db.assets.deleteAll(ids);
|
||||
await db.exifInfos.deleteAll(ids);
|
||||
});
|
||||
await db.assets.deleteAll(ids);
|
||||
await db.exifInfos.deleteAll(ids);
|
||||
});
|
||||
|
||||
Future<Asset?> getByRemoteId(String id) => db.assets.getByRemoteId(id);
|
||||
|
||||
Future<List<Asset>> getAllByRemoteId(
|
||||
Iterable<String> ids, {
|
||||
AssetState? state,
|
||||
}) async {
|
||||
Future<List<Asset>> getAllByRemoteId(Iterable<String> ids, {AssetState? state}) async {
|
||||
if (ids.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
@@ -69,10 +66,7 @@ class AssetRepository extends DatabaseRepository {
|
||||
return _getAllByRemoteIdImpl(ids, state).findAll();
|
||||
}
|
||||
|
||||
QueryBuilder<Asset, Asset, QAfterFilterCondition> _getAllByRemoteIdImpl(
|
||||
Iterable<String> ids,
|
||||
AssetState? state,
|
||||
) {
|
||||
QueryBuilder<Asset, Asset, QAfterFilterCondition> _getAllByRemoteIdImpl(Iterable<String> ids, AssetState? state) {
|
||||
final query = db.assets.remote(ids).filter();
|
||||
return switch (state) {
|
||||
null => query.noOp(),
|
||||
@@ -82,12 +76,7 @@ class AssetRepository extends DatabaseRepository {
|
||||
};
|
||||
}
|
||||
|
||||
Future<List<Asset>> getAll({
|
||||
required String ownerId,
|
||||
AssetState? state,
|
||||
AssetSort? sortBy,
|
||||
int? limit,
|
||||
}) {
|
||||
Future<List<Asset>> getAll({required String ownerId, AssetState? state, AssetSort? sortBy, int? limit}) {
|
||||
final baseQuery = db.assets.where();
|
||||
final isarUserIds = fastHash(ownerId);
|
||||
final QueryBuilder<Asset, Asset, QAfterFilterCondition> filteredQuery = switch (state) {
|
||||
@@ -133,19 +122,15 @@ class AssetRepository extends DatabaseRepository {
|
||||
return asset;
|
||||
}
|
||||
|
||||
Future<void> upsertDuplicatedAssets(Iterable<String> duplicatedAssets) => txn(
|
||||
() => db.duplicatedAssets.putAll(duplicatedAssets.map(DuplicatedAsset.new).toList()),
|
||||
);
|
||||
Future<void> upsertDuplicatedAssets(Iterable<String> duplicatedAssets) =>
|
||||
txn(() => db.duplicatedAssets.putAll(duplicatedAssets.map(DuplicatedAsset.new).toList()));
|
||||
|
||||
Future<List<String>> getAllDuplicatedAssetIds() => db.duplicatedAssets.where().idProperty().findAll();
|
||||
|
||||
Future<Asset?> getByOwnerIdChecksum(int ownerId, String checksum) =>
|
||||
db.assets.getByOwnerIdChecksum(ownerId, checksum);
|
||||
|
||||
Future<List<Asset?>> getAllByOwnerIdChecksum(
|
||||
List<int> ownerIds,
|
||||
List<String> checksums,
|
||||
) =>
|
||||
Future<List<Asset?>> getAllByOwnerIdChecksum(List<int> ownerIds, List<String> checksums) =>
|
||||
db.assets.getAllByOwnerIdChecksum(ownerIds, checksums);
|
||||
|
||||
Future<List<Asset>> getAllLocal() => db.assets.where().localIdIsNotNull().findAll();
|
||||
@@ -211,26 +196,25 @@ Future<List<Asset>> _getMatchesImpl(
|
||||
int ownerId,
|
||||
List<Asset> assets,
|
||||
int limit,
|
||||
) =>
|
||||
query
|
||||
.ownerIdEqualTo(ownerId)
|
||||
.anyOf(
|
||||
assets,
|
||||
(q, Asset a) => q
|
||||
.fileNameEqualTo(a.fileName)
|
||||
.and()
|
||||
.durationInSecondsEqualTo(a.durationInSeconds)
|
||||
.and()
|
||||
.fileCreatedAtBetween(
|
||||
a.fileCreatedAt.subtract(const Duration(hours: 12)),
|
||||
a.fileCreatedAt.add(const Duration(hours: 12)),
|
||||
)
|
||||
.and()
|
||||
.not()
|
||||
.checksumEqualTo(a.checksum),
|
||||
)
|
||||
.sortByFileName()
|
||||
.thenByFileCreatedAt()
|
||||
.thenByFileModifiedAt()
|
||||
.limit(limit)
|
||||
.findAll();
|
||||
) => query
|
||||
.ownerIdEqualTo(ownerId)
|
||||
.anyOf(
|
||||
assets,
|
||||
(q, Asset a) => q
|
||||
.fileNameEqualTo(a.fileName)
|
||||
.and()
|
||||
.durationInSecondsEqualTo(a.durationInSeconds)
|
||||
.and()
|
||||
.fileCreatedAtBetween(
|
||||
a.fileCreatedAt.subtract(const Duration(hours: 12)),
|
||||
a.fileCreatedAt.add(const Duration(hours: 12)),
|
||||
)
|
||||
.and()
|
||||
.not()
|
||||
.checksumEqualTo(a.checksum),
|
||||
)
|
||||
.sortByFileName()
|
||||
.thenByFileCreatedAt()
|
||||
.thenByFileModifiedAt()
|
||||
.limit(limit)
|
||||
.findAll();
|
||||
|
||||
@@ -23,17 +23,10 @@ class AssetApiRepository extends ApiRepository {
|
||||
final StacksApi _stacksApi;
|
||||
final TrashApi _trashApi;
|
||||
|
||||
AssetApiRepository(
|
||||
this._api,
|
||||
this._searchApi,
|
||||
this._stacksApi,
|
||||
this._trashApi,
|
||||
);
|
||||
AssetApiRepository(this._api, this._searchApi, this._stacksApi, this._trashApi);
|
||||
|
||||
Future<Asset> update(String id, {String? description}) async {
|
||||
final response = await checkNull(
|
||||
_api.updateAsset(id, UpdateAssetDto(description: description)),
|
||||
);
|
||||
final response = await checkNull(_api.updateAsset(id, UpdateAssetDto(description: description)));
|
||||
return Asset.remote(response);
|
||||
}
|
||||
|
||||
@@ -44,13 +37,7 @@ class AssetApiRepository extends ApiRepository {
|
||||
int currentPage = 1;
|
||||
while (hasNext) {
|
||||
final response = await checkNull(
|
||||
_searchApi.searchAssets(
|
||||
MetadataSearchDto(
|
||||
personIds: personIds,
|
||||
page: currentPage,
|
||||
size: 1000,
|
||||
),
|
||||
),
|
||||
_searchApi.searchAssets(MetadataSearchDto(personIds: personIds, page: currentPage, size: 1000)),
|
||||
);
|
||||
result.addAll(response.assets.items.map(Asset.remote));
|
||||
hasNext = response.assets.nextPage != null;
|
||||
@@ -67,35 +54,16 @@ class AssetApiRepository extends ApiRepository {
|
||||
await _trashApi.restoreAssets(BulkIdsDto(ids: ids));
|
||||
}
|
||||
|
||||
Future<void> updateVisibility(
|
||||
List<String> ids,
|
||||
AssetVisibilityEnum visibility,
|
||||
) async {
|
||||
return _api.updateAssets(
|
||||
AssetBulkUpdateDto(ids: ids, visibility: _mapVisibility(visibility)),
|
||||
);
|
||||
Future<void> updateVisibility(List<String> ids, AssetVisibilityEnum visibility) async {
|
||||
return _api.updateAssets(AssetBulkUpdateDto(ids: ids, visibility: _mapVisibility(visibility)));
|
||||
}
|
||||
|
||||
Future<void> updateFavorite(
|
||||
List<String> ids,
|
||||
bool isFavorite,
|
||||
) async {
|
||||
return _api.updateAssets(
|
||||
AssetBulkUpdateDto(ids: ids, isFavorite: isFavorite),
|
||||
);
|
||||
Future<void> updateFavorite(List<String> ids, bool isFavorite) async {
|
||||
return _api.updateAssets(AssetBulkUpdateDto(ids: ids, isFavorite: isFavorite));
|
||||
}
|
||||
|
||||
Future<void> updateLocation(
|
||||
List<String> ids,
|
||||
LatLng location,
|
||||
) async {
|
||||
return _api.updateAssets(
|
||||
AssetBulkUpdateDto(
|
||||
ids: ids,
|
||||
latitude: location.latitude,
|
||||
longitude: location.longitude,
|
||||
),
|
||||
);
|
||||
Future<void> updateLocation(List<String> ids, LatLng location) async {
|
||||
return _api.updateAssets(AssetBulkUpdateDto(ids: ids, latitude: location.latitude, longitude: location.longitude));
|
||||
}
|
||||
|
||||
Future<StackResponse> stack(List<String> ids) async {
|
||||
@@ -113,11 +81,11 @@ class AssetApiRepository extends ApiRepository {
|
||||
}
|
||||
|
||||
_mapVisibility(AssetVisibilityEnum visibility) => switch (visibility) {
|
||||
AssetVisibilityEnum.timeline => AssetVisibility.timeline,
|
||||
AssetVisibilityEnum.hidden => AssetVisibility.hidden,
|
||||
AssetVisibilityEnum.locked => AssetVisibility.locked,
|
||||
AssetVisibilityEnum.archive => AssetVisibility.archive,
|
||||
};
|
||||
AssetVisibilityEnum.timeline => AssetVisibility.timeline,
|
||||
AssetVisibilityEnum.hidden => AssetVisibility.hidden,
|
||||
AssetVisibilityEnum.locked => AssetVisibility.locked,
|
||||
AssetVisibilityEnum.archive => AssetVisibility.archive,
|
||||
};
|
||||
|
||||
Future<String?> getAssetMIMEType(String assetId) async {
|
||||
final response = await checkNull(_api.getAssetInfo(assetId));
|
||||
@@ -129,10 +97,6 @@ class AssetApiRepository extends ApiRepository {
|
||||
|
||||
extension on StackResponseDto {
|
||||
StackResponse toStack() {
|
||||
return StackResponse(
|
||||
id: id,
|
||||
primaryAssetId: primaryAssetId,
|
||||
assetIds: assets.map((asset) => asset.id).toList(),
|
||||
);
|
||||
return StackResponse(id: id, primaryAssetId: primaryAssetId, assetIds: assets.map((asset) => asset.id).toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/extensions/response_extensions.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
final assetMediaRepositoryProvider = Provider(
|
||||
(ref) => AssetMediaRepository(ref.watch(assetApiRepositoryProvider)),
|
||||
);
|
||||
final assetMediaRepositoryProvider = Provider((ref) => AssetMediaRepository(ref.watch(assetApiRepositoryProvider)));
|
||||
|
||||
class AssetMediaRepository {
|
||||
final AssetApiRepository _assetApiRepository;
|
||||
@@ -77,8 +75,8 @@ class AssetMediaRepository {
|
||||
final localId = (asset is LocalAsset)
|
||||
? asset.id
|
||||
: asset is RemoteAsset
|
||||
? asset.localId
|
||||
: null;
|
||||
? asset.localId
|
||||
: null;
|
||||
if (localId != null) {
|
||||
File? f = await AssetEntity(id: localId, width: 1, height: 1, typeInt: 0).originFile;
|
||||
downloadedXFiles.add(XFile(f!.path));
|
||||
|
||||
@@ -13,21 +13,12 @@ class AuthApiRepository extends ApiRepository {
|
||||
AuthApiRepository(this._apiService);
|
||||
|
||||
Future<void> changePassword(String newPassword) async {
|
||||
await _apiService.usersApi.updateMyUser(
|
||||
UserUpdateMeDto(
|
||||
password: newPassword,
|
||||
),
|
||||
);
|
||||
await _apiService.usersApi.updateMyUser(UserUpdateMeDto(password: newPassword));
|
||||
}
|
||||
|
||||
Future<LoginResponse> login(String email, String password) async {
|
||||
final loginResponseDto = await checkNull(
|
||||
_apiService.authenticationApi.login(
|
||||
LoginCredentialDto(
|
||||
email: email,
|
||||
password: password,
|
||||
),
|
||||
),
|
||||
_apiService.authenticationApi.login(LoginCredentialDto(email: email, password: password)),
|
||||
);
|
||||
|
||||
return _mapLoginReponse(loginResponseDto);
|
||||
|
||||
@@ -15,15 +15,10 @@ class BiometricRepository {
|
||||
final bool canAuthenticate = canAuthenticateWithBiometrics || await _localAuth.isDeviceSupported();
|
||||
final availableBiometric = await _localAuth.getAvailableBiometrics();
|
||||
|
||||
return BiometricStatus(
|
||||
canAuthenticate: canAuthenticate,
|
||||
availableBiometrics: availableBiometric,
|
||||
);
|
||||
return BiometricStatus(canAuthenticate: canAuthenticate, availableBiometrics: availableBiometric);
|
||||
}
|
||||
|
||||
Future<bool> authenticate(String? message) async {
|
||||
return _localAuth.authenticate(
|
||||
localizedReason: message ?? 'please_auth_to_access'.tr(),
|
||||
);
|
||||
return _localAuth.authenticate(localizedReason: message ?? 'please_auth_to_access'.tr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +64,7 @@ class DownloadRepository {
|
||||
}
|
||||
|
||||
Future<List<TaskRecord>> getLiveVideoTasks() {
|
||||
return _downloader.database.allRecordsWithStatus(
|
||||
TaskStatus.complete,
|
||||
group: kDownloadGroupLivePhoto,
|
||||
);
|
||||
return _downloader.database.allRecordsWithStatus(TaskStatus.complete, group: kDownloadGroupLivePhoto);
|
||||
}
|
||||
|
||||
Future<void> deleteRecordsWithIds(List<String> ids) {
|
||||
|
||||
@@ -14,34 +14,16 @@ class DriftAlbumApiRepository extends ApiRepository {
|
||||
|
||||
DriftAlbumApiRepository(this._api);
|
||||
|
||||
Future<RemoteAlbum> createDriftAlbum(
|
||||
String name, {
|
||||
required Iterable<String> assetIds,
|
||||
String? description,
|
||||
}) async {
|
||||
Future<RemoteAlbum> createDriftAlbum(String name, {required Iterable<String> assetIds, String? description}) async {
|
||||
final responseDto = await checkNull(
|
||||
_api.createAlbum(
|
||||
CreateAlbumDto(
|
||||
albumName: name,
|
||||
description: description,
|
||||
assetIds: assetIds.toList(),
|
||||
),
|
||||
),
|
||||
_api.createAlbum(CreateAlbumDto(albumName: name, description: description, assetIds: assetIds.toList())),
|
||||
);
|
||||
|
||||
return responseDto.toRemoteAlbum();
|
||||
}
|
||||
|
||||
Future<({List<String> removed, List<String> failed})> removeAssets(
|
||||
String albumId,
|
||||
Iterable<String> assetIds,
|
||||
) async {
|
||||
final response = await checkNull(
|
||||
_api.removeAssetFromAlbum(
|
||||
albumId,
|
||||
BulkIdsDto(ids: assetIds.toList()),
|
||||
),
|
||||
);
|
||||
Future<({List<String> removed, List<String> failed})> removeAssets(String albumId, Iterable<String> assetIds) async {
|
||||
final response = await checkNull(_api.removeAssetFromAlbum(albumId, BulkIdsDto(ids: assetIds.toList())));
|
||||
final List<String> removed = [], failed = [];
|
||||
for (final dto in response) {
|
||||
if (dto.success) {
|
||||
@@ -53,16 +35,8 @@ class DriftAlbumApiRepository extends ApiRepository {
|
||||
return (removed: removed, failed: failed);
|
||||
}
|
||||
|
||||
Future<({List<String> added, List<String> failed})> addAssets(
|
||||
String albumId,
|
||||
Iterable<String> assetIds,
|
||||
) async {
|
||||
final response = await checkNull(
|
||||
_api.addAssetsToAlbum(
|
||||
albumId,
|
||||
BulkIdsDto(ids: assetIds.toList()),
|
||||
),
|
||||
);
|
||||
Future<({List<String> added, List<String> failed})> addAssets(String albumId, Iterable<String> assetIds) async {
|
||||
final response = await checkNull(_api.addAssetsToAlbum(albumId, BulkIdsDto(ids: assetIds.toList())));
|
||||
final List<String> added = [], failed = [];
|
||||
for (final dto in response) {
|
||||
if (dto.success) {
|
||||
@@ -108,17 +82,9 @@ class DriftAlbumApiRepository extends ApiRepository {
|
||||
return _api.deleteAlbum(albumId);
|
||||
}
|
||||
|
||||
Future<RemoteAlbum> addUsers(
|
||||
String albumId,
|
||||
Iterable<String> userIds,
|
||||
) async {
|
||||
Future<RemoteAlbum> addUsers(String albumId, Iterable<String> userIds) async {
|
||||
final albumUsers = userIds.map((userId) => AlbumUserAddDto(userId: userId)).toList();
|
||||
final response = await checkNull(
|
||||
_api.addUsersToAlbum(
|
||||
albumId,
|
||||
AddUsersDto(albumUsers: albumUsers),
|
||||
),
|
||||
);
|
||||
final response = await checkNull(_api.addUsersToAlbum(albumId, AddUsersDto(albumUsers: albumUsers)));
|
||||
return response.toRemoteAlbum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,56 +10,23 @@ final fileMediaRepositoryProvider = Provider((ref) => const FileMediaRepository(
|
||||
|
||||
class FileMediaRepository {
|
||||
const FileMediaRepository();
|
||||
Future<Asset?> saveImage(
|
||||
Uint8List data, {
|
||||
required String title,
|
||||
String? relativePath,
|
||||
}) async {
|
||||
final entity = await PhotoManager.editor.saveImage(
|
||||
data,
|
||||
filename: title,
|
||||
title: title,
|
||||
relativePath: relativePath,
|
||||
);
|
||||
Future<Asset?> saveImage(Uint8List data, {required String title, String? relativePath}) async {
|
||||
final entity = await PhotoManager.editor.saveImage(data, filename: title, title: title, relativePath: relativePath);
|
||||
return AssetMediaRepository.toAsset(entity);
|
||||
}
|
||||
|
||||
Future<Asset?> saveImageWithFile(
|
||||
String filePath, {
|
||||
String? title,
|
||||
String? relativePath,
|
||||
}) async {
|
||||
final entity = await PhotoManager.editor.saveImageWithPath(
|
||||
filePath,
|
||||
title: title,
|
||||
relativePath: relativePath,
|
||||
);
|
||||
Future<Asset?> saveImageWithFile(String filePath, {String? title, String? relativePath}) async {
|
||||
final entity = await PhotoManager.editor.saveImageWithPath(filePath, title: title, relativePath: relativePath);
|
||||
return AssetMediaRepository.toAsset(entity);
|
||||
}
|
||||
|
||||
Future<Asset?> saveLivePhoto({
|
||||
required File image,
|
||||
required File video,
|
||||
required String title,
|
||||
}) async {
|
||||
final entity = await PhotoManager.editor.darwin.saveLivePhoto(
|
||||
imageFile: image,
|
||||
videoFile: video,
|
||||
title: title,
|
||||
);
|
||||
Future<Asset?> saveLivePhoto({required File image, required File video, required String title}) async {
|
||||
final entity = await PhotoManager.editor.darwin.saveLivePhoto(imageFile: image, videoFile: video, title: title);
|
||||
return AssetMediaRepository.toAsset(entity);
|
||||
}
|
||||
|
||||
Future<Asset?> saveVideo(
|
||||
File file, {
|
||||
required String title,
|
||||
String? relativePath,
|
||||
}) async {
|
||||
final entity = await PhotoManager.editor.saveVideo(
|
||||
file,
|
||||
title: title,
|
||||
relativePath: relativePath,
|
||||
);
|
||||
Future<Asset?> saveVideo(File file, {required String title, String? relativePath}) async {
|
||||
final entity = await PhotoManager.editor.saveVideo(file, title: title, relativePath: relativePath);
|
||||
return AssetMediaRepository.toAsset(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,7 @@ import 'package:immich_mobile/repositories/api.repository.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final folderApiRepositoryProvider = Provider(
|
||||
(ref) => FolderApiRepository(
|
||||
ref.watch(apiServiceProvider).viewApi,
|
||||
),
|
||||
);
|
||||
final folderApiRepositoryProvider = Provider((ref) => FolderApiRepository(ref.watch(apiServiceProvider).viewApi));
|
||||
|
||||
class FolderApiRepository extends ApiRepository {
|
||||
final ViewApi _api;
|
||||
|
||||
@@ -33,19 +33,13 @@ class GCastRepository {
|
||||
});
|
||||
|
||||
// open the default receiver
|
||||
sendMessage(CastSession.kNamespaceReceiver, {
|
||||
'type': 'LAUNCH',
|
||||
'appId': 'CC1AD845',
|
||||
});
|
||||
sendMessage(CastSession.kNamespaceReceiver, {'type': 'LAUNCH', 'appId': 'CC1AD845'});
|
||||
}
|
||||
|
||||
Future<void> disconnect() async {
|
||||
final sessionID = getSessionId();
|
||||
|
||||
sendMessage(CastSession.kNamespaceReceiver, {
|
||||
'type': "STOP",
|
||||
"sessionId": sessionID,
|
||||
});
|
||||
sendMessage(CastSession.kNamespaceReceiver, {'type': "STOP", "sessionId": sessionID});
|
||||
|
||||
// wait 500ms to ensure the stop command is processed
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
@@ -5,9 +5,7 @@ import 'package:immich_mobile/providers/db.provider.dart';
|
||||
import 'package:immich_mobile/repositories/database.repository.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
final partnerRepositoryProvider = Provider(
|
||||
(ref) => PartnerRepository(ref.watch(dbProvider)),
|
||||
);
|
||||
final partnerRepositoryProvider = Provider((ref) => PartnerRepository(ref.watch(dbProvider)));
|
||||
|
||||
class PartnerRepository extends DatabaseRepository {
|
||||
const PartnerRepository(super.db);
|
||||
@@ -23,12 +21,14 @@ class PartnerRepository extends DatabaseRepository {
|
||||
}
|
||||
|
||||
Stream<List<UserDto>> watchSharedBy() {
|
||||
return (db.users.filter().isPartnerSharedByEqualTo(true).sortById().watch())
|
||||
.map((users) => users.map((u) => u.toDto()).toList());
|
||||
return (db.users.filter().isPartnerSharedByEqualTo(true).sortById().watch()).map(
|
||||
(users) => users.map((u) => u.toDto()).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Stream<List<UserDto>> watchSharedWith() {
|
||||
return (db.users.filter().isPartnerSharedWithEqualTo(true).sortById().watch())
|
||||
.map((users) => users.map((u) => u.toDto()).toList());
|
||||
return (db.users.filter().isPartnerSharedWithEqualTo(true).sortById().watch()).map(
|
||||
(users) => users.map((u) => u.toDto()).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,9 @@ import 'package:immich_mobile/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/repositories/api.repository.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
enum Direction {
|
||||
sharedWithMe,
|
||||
sharedByMe,
|
||||
}
|
||||
enum Direction { sharedWithMe, sharedByMe }
|
||||
|
||||
final partnerApiRepositoryProvider = Provider(
|
||||
(ref) => PartnerApiRepository(
|
||||
ref.watch(apiServiceProvider).partnersApi,
|
||||
),
|
||||
);
|
||||
final partnerApiRepositoryProvider = Provider((ref) => PartnerApiRepository(ref.watch(apiServiceProvider).partnersApi));
|
||||
|
||||
class PartnerApiRepository extends ApiRepository {
|
||||
final PartnersApi _api;
|
||||
@@ -23,9 +16,7 @@ class PartnerApiRepository extends ApiRepository {
|
||||
|
||||
Future<List<UserDto>> getAll(Direction direction) async {
|
||||
final response = await checkNull(
|
||||
_api.getPartners(
|
||||
direction == Direction.sharedByMe ? PartnerDirection.by : PartnerDirection.with_,
|
||||
),
|
||||
_api.getPartners(direction == Direction.sharedByMe ? PartnerDirection.by : PartnerDirection.with_),
|
||||
);
|
||||
return response.map(UserConverter.fromPartnerDto).toList();
|
||||
}
|
||||
@@ -38,12 +29,7 @@ class PartnerApiRepository extends ApiRepository {
|
||||
Future<void> delete(String id) => _api.removePartner(id);
|
||||
|
||||
Future<UserDto> update(String id, {required bool inTimeline}) async {
|
||||
final dto = await checkNull(
|
||||
_api.updatePartner(
|
||||
id,
|
||||
UpdatePartnerDto(inTimeline: inTimeline),
|
||||
),
|
||||
);
|
||||
final dto = await checkNull(_api.updatePartner(id, UpdatePartnerDto(inTimeline: inTimeline)));
|
||||
return UserConverter.fromPartnerDto(dto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@ import 'package:immich_mobile/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/repositories/api.repository.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final personApiRepositoryProvider = Provider(
|
||||
(ref) => PersonApiRepository(ref.watch(apiServiceProvider).peopleApi),
|
||||
);
|
||||
final personApiRepositoryProvider = Provider((ref) => PersonApiRepository(ref.watch(apiServiceProvider).peopleApi));
|
||||
|
||||
class PersonApiRepository extends ApiRepository {
|
||||
final PeopleApi _api;
|
||||
@@ -19,17 +17,15 @@ class PersonApiRepository extends ApiRepository {
|
||||
}
|
||||
|
||||
Future<PersonDto> update(String id, {String? name}) async {
|
||||
final dto = await checkNull(
|
||||
_api.updatePerson(id, PersonUpdateDto(name: name)),
|
||||
);
|
||||
final dto = await checkNull(_api.updatePerson(id, PersonUpdateDto(name: name)));
|
||||
return _toPerson(dto);
|
||||
}
|
||||
|
||||
static PersonDto _toPerson(PersonResponseDto dto) => PersonDto(
|
||||
birthDate: dto.birthDate,
|
||||
id: dto.id,
|
||||
isHidden: dto.isHidden,
|
||||
name: dto.name,
|
||||
thumbnailPath: dto.thumbnailPath,
|
||||
);
|
||||
birthDate: dto.birthDate,
|
||||
id: dto.id,
|
||||
isHidden: dto.isHidden,
|
||||
name: dto.name,
|
||||
thumbnailPath: dto.thumbnailPath,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import 'package:immich_mobile/repositories/api.repository.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final sessionsAPIRepositoryProvider = Provider(
|
||||
(ref) => SessionsAPIRepository(
|
||||
ref.watch(apiServiceProvider).sessionsApi,
|
||||
),
|
||||
(ref) => SessionsAPIRepository(ref.watch(apiServiceProvider).sessionsApi),
|
||||
);
|
||||
|
||||
class SessionsAPIRepository extends ApiRepository {
|
||||
@@ -15,19 +13,9 @@ class SessionsAPIRepository extends ApiRepository {
|
||||
|
||||
SessionsAPIRepository(this._api);
|
||||
|
||||
Future<SessionCreateResponse> createSession(
|
||||
String deviceType,
|
||||
String deviceOS, {
|
||||
int? duration,
|
||||
}) async {
|
||||
Future<SessionCreateResponse> createSession(String deviceType, String deviceOS, {int? duration}) async {
|
||||
final dto = await checkNull(
|
||||
_api.createSession(
|
||||
SessionCreateDto(
|
||||
deviceType: deviceType,
|
||||
deviceOS: deviceOS,
|
||||
duration: duration,
|
||||
),
|
||||
),
|
||||
_api.createSession(SessionCreateDto(deviceType: deviceType, deviceOS: deviceOS, duration: duration)),
|
||||
);
|
||||
|
||||
return SessionCreateResponse(
|
||||
|
||||
@@ -4,9 +4,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/models/upload/share_intent_attachment.model.dart';
|
||||
import 'package:share_handler/share_handler.dart';
|
||||
|
||||
final shareHandlerRepositoryProvider = Provider(
|
||||
(ref) => ShareHandlerRepository(),
|
||||
);
|
||||
final shareHandlerRepositoryProvider = Provider((ref) => ShareHandlerRepository());
|
||||
|
||||
class ShareHandlerRepository {
|
||||
ShareHandlerRepository();
|
||||
@@ -28,9 +26,7 @@ class ShareHandlerRepository {
|
||||
});
|
||||
}
|
||||
|
||||
List<ShareIntentAttachment> _buildPayload(
|
||||
List<SharedAttachment?> attachments,
|
||||
) {
|
||||
List<ShareIntentAttachment> _buildPayload(List<SharedAttachment?> attachments) {
|
||||
final payload = <ShareIntentAttachment>[];
|
||||
|
||||
for (final attachment in attachments) {
|
||||
|
||||
@@ -48,10 +48,7 @@ class TimelineRepository extends DatabaseRepository {
|
||||
return _watchRenderList(query, GroupAssetsBy.none);
|
||||
}
|
||||
|
||||
Stream<RenderList> watchAlbumTimeline(
|
||||
Album album,
|
||||
GroupAssetsBy groupAssetByOption,
|
||||
) {
|
||||
Stream<RenderList> watchAlbumTimeline(Album album, GroupAssetsBy groupAssetByOption) {
|
||||
final query = album.assets.filter().isTrashedEqualTo(false).not().visibilityEqualTo(AssetVisibilityEnum.locked);
|
||||
|
||||
final withSortedOption = switch (album.sortOrder) {
|
||||
@@ -81,10 +78,7 @@ class TimelineRepository extends DatabaseRepository {
|
||||
return _watchRenderList(query, GroupAssetsBy.none);
|
||||
}
|
||||
|
||||
Stream<RenderList> watchHomeTimeline(
|
||||
String userId,
|
||||
GroupAssetsBy groupAssetByOption,
|
||||
) {
|
||||
Stream<RenderList> watchHomeTimeline(String userId, GroupAssetsBy groupAssetByOption) {
|
||||
final query = db.assets
|
||||
.where()
|
||||
.ownerIdEqualToAnyChecksum(fastHash(userId))
|
||||
@@ -97,10 +91,7 @@ class TimelineRepository extends DatabaseRepository {
|
||||
return _watchRenderList(query, groupAssetByOption);
|
||||
}
|
||||
|
||||
Stream<RenderList> watchMultiUsersTimeline(
|
||||
List<String> userIds,
|
||||
GroupAssetsBy groupAssetByOption,
|
||||
) {
|
||||
Stream<RenderList> watchMultiUsersTimeline(List<String> userIds, GroupAssetsBy groupAssetByOption) {
|
||||
final isarUserIds = userIds.map(fastHash).toList();
|
||||
final query = db.assets
|
||||
.where()
|
||||
@@ -113,10 +104,7 @@ class TimelineRepository extends DatabaseRepository {
|
||||
return _watchRenderList(query, groupAssetByOption);
|
||||
}
|
||||
|
||||
Future<RenderList> getTimelineFromAssets(
|
||||
List<Asset> assets,
|
||||
GroupAssetsBy getGroupByOption,
|
||||
) {
|
||||
Future<RenderList> getTimelineFromAssets(List<Asset> assets, GroupAssetsBy getGroupByOption) {
|
||||
return RenderList.fromAssets(assets, getGroupByOption);
|
||||
}
|
||||
|
||||
@@ -134,10 +122,7 @@ class TimelineRepository extends DatabaseRepository {
|
||||
return _watchRenderList(query, GroupAssetsBy.none);
|
||||
}
|
||||
|
||||
Stream<RenderList> watchLockedTimeline(
|
||||
String userId,
|
||||
GroupAssetsBy getGroupByOption,
|
||||
) {
|
||||
Stream<RenderList> watchLockedTimeline(String userId, GroupAssetsBy getGroupByOption) {
|
||||
final query = db.assets
|
||||
.where()
|
||||
.ownerIdEqualToAnyChecksum(fastHash(userId))
|
||||
|
||||
@@ -54,26 +54,11 @@ class UploadRepository {
|
||||
|
||||
Future<void> getUploadInfo() async {
|
||||
final [enqueuedTasks, runningTasks, canceledTasks, waitingTasks, pausedTasks] = await Future.wait([
|
||||
FileDownloader().database.allRecordsWithStatus(
|
||||
TaskStatus.enqueued,
|
||||
group: kBackupGroup,
|
||||
),
|
||||
FileDownloader().database.allRecordsWithStatus(
|
||||
TaskStatus.running,
|
||||
group: kBackupGroup,
|
||||
),
|
||||
FileDownloader().database.allRecordsWithStatus(
|
||||
TaskStatus.canceled,
|
||||
group: kBackupGroup,
|
||||
),
|
||||
FileDownloader().database.allRecordsWithStatus(
|
||||
TaskStatus.waitingToRetry,
|
||||
group: kBackupGroup,
|
||||
),
|
||||
FileDownloader().database.allRecordsWithStatus(
|
||||
TaskStatus.paused,
|
||||
group: kBackupGroup,
|
||||
),
|
||||
FileDownloader().database.allRecordsWithStatus(TaskStatus.enqueued, group: kBackupGroup),
|
||||
FileDownloader().database.allRecordsWithStatus(TaskStatus.running, group: kBackupGroup),
|
||||
FileDownloader().database.allRecordsWithStatus(TaskStatus.canceled, group: kBackupGroup),
|
||||
FileDownloader().database.allRecordsWithStatus(TaskStatus.waitingToRetry, group: kBackupGroup),
|
||||
FileDownloader().database.allRecordsWithStatus(TaskStatus.paused, group: kBackupGroup),
|
||||
]);
|
||||
|
||||
debugPrint("""
|
||||
|
||||
@@ -11,10 +11,7 @@ class WidgetRepository {
|
||||
}
|
||||
|
||||
Future<void> refresh(String iosName, String androidName) async {
|
||||
await HomeWidget.updateWidget(
|
||||
iOSName: iosName,
|
||||
qualifiedAndroidName: androidName,
|
||||
);
|
||||
await HomeWidget.updateWidget(iOSName: iosName, qualifiedAndroidName: androidName);
|
||||
}
|
||||
|
||||
Future<void> setAppGroupId(String appGroupId) async {
|
||||
|
||||
Reference in New Issue
Block a user