Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(mobile): entities and models #9182

Merged
merged 6 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mobile/integration_test/test_utils/general_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/shared/providers/db.provider.dart';
import 'package:integration_test/integration_test.dart';
import 'package:isar/isar.dart';
Expand Down
1 change: 1 addition & 0 deletions mobile/lib/entities/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory contains entity that is stored in the local storage.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/shared/models/user.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/entities/user.entity.dart';
import 'package:immich_mobile/utils/datetime_comparison.dart';
import 'package:isar/isar.dart';
import 'package:openapi/api.dart';
import 'package:photo_manager/photo_manager.dart';

part 'album.g.dart';
part 'album.entity.g.dart';

@Collection(inheritance: false)
class Album {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:immich_mobile/shared/models/device_asset.dart';
import 'package:immich_mobile/entities/device_asset.entity.dart';
import 'package:isar/isar.dart';

part 'android_device_asset.g.dart';
part 'android_device_asset.entity.g.dart';

@Collection()
class AndroidDeviceAsset extends DeviceAsset {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'dart:convert';

import 'package:immich_mobile/shared/models/exif_info.dart';
import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/entities/exif_info.entity.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';
import 'package:openapi/api.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:immich_mobile/extensions/string_extensions.dart';
import 'package:path/path.dart' as p;

part 'asset.g.dart';
part 'asset.entity.g.dart';

/// Asset (online or local)
@Collection(inheritance: false)
Expand Down Expand Up @@ -432,7 +432,10 @@ class Asset {
return compareByChecksum(a, b);
}

static int compareByOwnerChecksumCreatedModified(Asset a, Asset b) {
static int compareByOwnerChecksumCreatedModified(
Asset a,
Asset b,
) {
final int ownerIdOrder = a.ownerId.compareTo(b.ownerId);
if (ownerIdOrder != 0) return ownerIdOrder;
final int checksumOrder = compareByChecksum(a, b);
Expand Down Expand Up @@ -517,9 +520,13 @@ extension AssetsHelper on IsarCollection<Asset> {
Future<Asset?> getByRemoteId(String id) =>
where().remoteIdEqualTo(id).findFirst();

QueryBuilder<Asset, Asset, QAfterWhereClause> remote(Iterable<String> ids) =>
QueryBuilder<Asset, Asset, QAfterWhereClause> remote(
Iterable<String> ids,
) =>
where().anyOf(ids, (q, String e) => q.remoteIdEqualTo(e));
QueryBuilder<Asset, Asset, QAfterWhereClause> local(Iterable<String> ids) {
QueryBuilder<Asset, Asset, QAfterWhereClause> local(
Iterable<String> ids,
) {
return where().anyOf(ids, (q, String e) => q.localIdEqualTo(e));
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';

part 'backup_album.model.g.dart';
part 'backup_album.entity.g.dart';

@Collection(inheritance: false)
class BackupAlbum {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';

part 'duplicated_asset.model.g.dart';
part 'duplicated_asset.entity.g.dart';

@Collection(inheritance: false)
class DuplicatedAsset {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';

part 'etag.g.dart';
part 'etag.entity.g.dart';

@Collection(inheritance: false)
class ETag {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:isar/isar.dart';
import 'package:openapi/api.dart';

part 'exif_info.g.dart';
part 'exif_info.entity.g.dart';

/// Exif information 1:1 relation with Asset
@Collection(inheritance: false)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:immich_mobile/shared/models/device_asset.dart';
import 'package:immich_mobile/entities/device_asset.entity.dart';
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';

part 'ios_device_asset.g.dart';
part 'ios_device_asset.entity.g.dart';

@Collection()
class IOSDeviceAsset extends DeviceAsset {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import 'package:isar/isar.dart';
import 'package:logging/logging.dart';

part 'logger_message.model.g.dart';
part 'logger_message.entity.g.dart';

@Collection(inheritance: false)
class LoggerMessage {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:collection/collection.dart';
import 'package:immich_mobile/shared/models/user.dart';
import 'package:immich_mobile/entities/user.entity.dart';
import 'package:isar/isar.dart';
import 'package:logging/logging.dart';

part 'store.g.dart';
part 'store.entity.g.dart';

/// Key-value store for individual items enumerated in StoreKey.
/// Supports String, int and JSON-serializable Objects
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:ui';

import 'package:immich_mobile/shared/models/album.dart';
import 'package:immich_mobile/entities/album.entity.dart';
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';
import 'package:openapi/api.dart';

part 'user.g.dart';
part 'user.entity.g.dart';

@Collection(inheritance: false)
class User {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mobile/lib/extensions/asset_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:timezone/timezone.dart';

extension TZExtension on Asset {
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/extensions/collection_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:typed_data';

import 'package:collection/collection.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/user.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:immich_mobile/entities/user.entity.dart';

extension ListExtension<E> on List<E> {
List<E> uniqueConsecutive({
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/extensions/maplibrecontroller_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';
import 'dart:math';

import 'package:flutter/services.dart';
import 'package:immich_mobile/modules/map/models/map_marker.dart';
import 'package:immich_mobile/models/map/map_marker.model.dart';
import 'package:immich_mobile/modules/map/utils/map_utils.dart';
import 'package:maplibre_gl/maplibre_gl.dart';

Expand Down
22 changes: 11 additions & 11 deletions mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:timezone/data/latest.dart';
import 'package:immich_mobile/constants/locales.dart';
import 'package:immich_mobile/modules/backup/background_service/background.service.dart';
import 'package:immich_mobile/modules/backup/models/backup_album.model.dart';
import 'package:immich_mobile/modules/backup/models/duplicated_asset.model.dart';
import 'package:immich_mobile/entities/backup_album.entity.dart';
import 'package:immich_mobile/entities/duplicated_asset.entity.dart';
import 'package:immich_mobile/routing/router.dart';
import 'package:immich_mobile/routing/tab_navigation_observer.dart';
import 'package:immich_mobile/shared/cache/widgets_binding.dart';
import 'package:immich_mobile/shared/models/album.dart';
import 'package:immich_mobile/shared/models/android_device_asset.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/etag.dart';
import 'package:immich_mobile/shared/models/exif_info.dart';
import 'package:immich_mobile/shared/models/ios_device_asset.dart';
import 'package:immich_mobile/shared/models/logger_message.model.dart';
import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/shared/models/user.dart';
import 'package:immich_mobile/entities/album.entity.dart';
import 'package:immich_mobile/entities/android_device_asset.entity.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:immich_mobile/entities/etag.entity.dart';
import 'package:immich_mobile/entities/exif_info.entity.dart';
import 'package:immich_mobile/entities/ios_device_asset.entity.dart';
import 'package:immich_mobile/entities/logger_message.entity.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/entities/user.entity.dart';
import 'package:immich_mobile/shared/providers/app_state.provider.dart';
import 'package:immich_mobile/shared/providers/db.provider.dart';
import 'package:immich_mobile/shared/services/immich_logger.service.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:immich_mobile/shared/models/user.dart';
import 'package:immich_mobile/entities/user.entity.dart';
import 'package:openapi/api.dart';

enum ActivityType { comment, like }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import 'dart:convert';

import 'package:collection/collection.dart';

class AddAssetsResponse {
class AlbumAddAssetsResponse {
List<String> alreadyInAlbum;
int successfullyAdded;

AddAssetsResponse({
AlbumAddAssetsResponse({
required this.alreadyInAlbum,
required this.successfullyAdded,
});

AddAssetsResponse copyWith({
AlbumAddAssetsResponse copyWith({
List<String>? alreadyInAlbum,
int? successfullyAdded,
}) {
return AddAssetsResponse(
return AlbumAddAssetsResponse(
alreadyInAlbum: alreadyInAlbum ?? this.alreadyInAlbum,
successfullyAdded: successfullyAdded ?? this.successfullyAdded,
);
Expand All @@ -36,7 +36,7 @@ class AddAssetsResponse {
'AddAssetsResponse(alreadyInAlbum: $alreadyInAlbum, successfullyAdded: $successfullyAdded)';

@override
bool operator ==(covariant AddAssetsResponse other) {
bool operator ==(covariant AlbumAddAssetsResponse other) {
if (identical(this, other)) return true;
final listEquals = const DeepCollectionEquality().equals;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:collection/collection.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/entities/asset.entity.dart';

class AssetSelectionPageResult {
final Set<Asset> selectedAssets;
Expand Down
Loading
Loading