Compare commits

...

19 Commits

Author SHA1 Message Date
wuzihao051119
4677ceb03c drift(mobile): drift auth user sync 2025-07-25 12:28:02 +08:00
shenlong
ad65e9011a chore: bump line length to 120 (#20191) 2025-07-25 02:37:22 +00:00
Zack Pollard
977c9b96ba fix: geodata_places pkey migration failing for certain upgrade paths (#20177) 2025-07-24 22:50:36 +01:00
John Stef
aa2828ab33 fix(mobile): hide video thumbnail when video is ready (#19328) 2025-07-24 22:38:08 +01:00
Daimolean
a36840d7cc fix(web): multi-select in ascending asset order (#19461) 2025-07-24 22:37:44 +01:00
Pablo Lluch
e34f46fa0d fix: send correct includeArchived parameter to API when showing markers in map (#20117)
Co-authored-by: Pablo Lluch <pablo.lluch@gmail.com>
Co-authored-by: Zack Pollard <zackpollard@ymail.com>
2025-07-24 22:34:06 +02:00
Alex
6170a3843c chore: remove build flavor Android (#20161) 2025-07-24 14:55:49 -05:00
shenlong
563e2ab503 fix: update trash action i18n keys (#20164)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2025-07-24 14:55:35 -05:00
shenlong
79157e1043 fix: fallback auto grouping to day grouping (#20156)
fallback auto grouping to day grouping

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2025-07-24 19:28:40 +00:00
shenlong
02688a2a03 fix: override SSL options inside isolates (#20142)
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2025-07-24 14:26:00 -05:00
Brandon Wees
3b9bfceef0 fix: album deleted toast message (#20121)
* fix: album deleted toast message

* Update mobile/lib/presentation/pages/drift_remote_album.page.dart

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>

* Fix lint

---------

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>
2025-07-24 14:09:17 -05:00
github-actions
089085fcdb chore: version v1.136.0 2025-07-24 14:24:38 +00:00
Jason Rasmussen
fc68cf4f32 chore: remove migration (#20129) 2025-07-24 14:11:53 +00:00
Alex
0051a9bba5 fix(web): Revert prevent flashing white background in dark mode on page load/reload (#19934) (#20122)
Revert "fix(web): prevent flashing white background in dark mode on page load/reload (#19934)"

This reverts commit 32f23b8d38.
2025-07-24 09:45:38 +02:00
Daniel Dietzler
f27bdf7523 chore: migrate to UI modal manager (#20116) 2025-07-23 17:27:09 -04:00
Daniel Dietzler
c1c9f30ea4 chore: migrate to immich/ui confirm modal (#20114) 2025-07-23 22:56:56 +02:00
Jason Rasmussen
bc8cb9b671 fix: default route permission (#20113) 2025-07-23 16:56:38 -04:00
Jason Rasmussen
a675922172 fix: unset prewarn param (#20109) 2025-07-23 16:52:59 -04:00
Jason Rasmussen
2bead445bd docs: remove outdated note (#20110) 2025-07-23 16:00:19 -04:00
631 changed files with 13099 additions and 10355 deletions

View File

@@ -122,17 +122,17 @@ jobs:
IS_MAIN: ${{ github.ref == 'refs/heads/main' }}
run: |
if [[ $IS_MAIN == 'true' ]]; then
flutter build apk --release --flavor production
flutter build apk --release --flavor production --split-per-abi --target-platform android-arm,android-arm64,android-x64
flutter build apk --release
flutter build apk --release --split-per-abi --target-platform android-arm,android-arm64,android-x64
else
flutter build apk --debug --flavor production --split-per-abi --target-platform android-arm64
flutter build apk --debug --split-per-abi --target-platform android-arm64
fi
- name: Publish Android Artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-apk-signed
path: mobile/build/app/outputs/flutter-apk/**/*.apk
path: mobile/build/app/outputs/flutter-apk/*.apk
- name: Save Gradle Cache
id: cache-gradle-save

View File

@@ -98,7 +98,8 @@ jobs:
run: dart analyze --fatal-infos
- name: Run dart format
run: dart format lib/ --set-exit-if-changed
# Ignore generated files manually until https://github.com/dart-lang/dart_style/issues/864 is resolved
run: dart format --set-exit-if-changed $(find lib -name '*.dart' -not \( -name 'generated_plugin_registrant.dart' -o -name '*.g.dart' -o -name '*.drift.dart' \))
- name: Run dart custom_lint
run: dart run custom_lint

19
.vscode/launch.json vendored
View File

@@ -18,25 +18,6 @@
"name": "Immich Workers",
"remoteRoot": "/usr/src/app",
"localRoot": "${workspaceFolder}/server"
},
{
"name": "Flavor - Production",
"request": "launch",
"type": "dart",
"codeLens": {
"for": [
"run-test",
"run-test-file",
"run-file",
"debug-test",
"debug-test-file",
"debug-file",
],
"title": "${debugType}",
},
"args": [
"--flavor", "production"
],
}
]
}

6
cli/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@immich/cli",
"version": "2.2.72",
"version": "2.2.73",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@immich/cli",
"version": "2.2.72",
"version": "2.2.73",
"license": "GNU Affero General Public License version 3",
"dependencies": {
"chokidar": "^4.0.3",
@@ -54,7 +54,7 @@
},
"../open-api/typescript-sdk": {
"name": "@immich/sdk",
"version": "1.135.3",
"version": "1.136.0",
"dev": true,
"license": "GNU Affero General Public License version 3",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@immich/cli",
"version": "2.2.72",
"version": "2.2.73",
"description": "Command Line Interface (CLI) for Immich",
"type": "module",
"exports": "./dist/index.js",

View File

@@ -29,29 +29,26 @@ These environment variables are used by the `docker-compose.yml` file and do **N
## General
| Variable | Description | Default | Containers | Workers |
| :---------------------------------- | :---------------------------------------------------------------------------------------- | :---------------------------------: | :----------------------- | :----------------- |
| `TZ` | Timezone | <sup>\*1</sup> | server | microservices |
| `IMMICH_ENV` | Environment (production, development) | `production` | server, machine learning | api, microservices |
| `IMMICH_LOG_LEVEL` | Log level (verbose, debug, log, warn, error) | `log` | server, machine learning | api, microservices |
| `IMMICH_MEDIA_LOCATION` | Media location inside the container ⚠️**You probably shouldn't set this**<sup>\*2</sup>⚠️ | `/usr/src/app/upload`<sup>\*3</sup> | server | api, microservices |
| `IMMICH_CONFIG_FILE` | Path to config file | | server | api, microservices |
| `NO_COLOR` | Set to `true` to disable color-coded log output | `false` | server, machine learning | |
| `CPU_CORES` | Number of cores available to the Immich server | auto-detected CPU core count | server | |
| `IMMICH_API_METRICS_PORT` | Port for the OTEL metrics | `8081` | server | api |
| `IMMICH_MICROSERVICES_METRICS_PORT` | Port for the OTEL metrics | `8082` | server | microservices |
| `IMMICH_PROCESS_INVALID_IMAGES` | When `true`, generate thumbnails for invalid images | | server | microservices |
| `IMMICH_TRUSTED_PROXIES` | List of comma-separated IPs set as trusted proxies | | server | api |
| `IMMICH_IGNORE_MOUNT_CHECK_ERRORS` | See [System Integrity](/docs/administration/system-integrity) | | server | api, microservices |
| Variable | Description | Default | Containers | Workers |
| :---------------------------------- | :---------------------------------------------------------------------------------------- | :--------------------------: | :----------------------- | :----------------- |
| `TZ` | Timezone | <sup>\*1</sup> | server | microservices |
| `IMMICH_ENV` | Environment (production, development) | `production` | server, machine learning | api, microservices |
| `IMMICH_LOG_LEVEL` | Log level (verbose, debug, log, warn, error) | `log` | server, machine learning | api, microservices |
| `IMMICH_MEDIA_LOCATION` | Media location inside the container ⚠️**You probably shouldn't set this**<sup>\*2</sup>⚠️ | `/usr/src/app/upload` | server | api, microservices |
| `IMMICH_CONFIG_FILE` | Path to config file | | server | api, microservices |
| `NO_COLOR` | Set to `true` to disable color-coded log output | `false` | server, machine learning | |
| `CPU_CORES` | Number of cores available to the Immich server | auto-detected CPU core count | server | |
| `IMMICH_API_METRICS_PORT` | Port for the OTEL metrics | `8081` | server | api |
| `IMMICH_MICROSERVICES_METRICS_PORT` | Port for the OTEL metrics | `8082` | server | microservices |
| `IMMICH_PROCESS_INVALID_IMAGES` | When `true`, generate thumbnails for invalid images | | server | microservices |
| `IMMICH_TRUSTED_PROXIES` | List of comma-separated IPs set as trusted proxies | | server | api |
| `IMMICH_IGNORE_MOUNT_CHECK_ERRORS` | See [System Integrity](/docs/administration/system-integrity) | | server | api, microservices |
\*1: `TZ` should be set to a `TZ identifier` from [this list][tz-list]. For example, `TZ="Etc/UTC"`.
`TZ` is used by `exiftool` as a fallback in case the timezone cannot be determined from the image metadata. It is also used for logfile timestamps and cron job execution.
\*2: This path is where the Immich code looks for the files, which is internal to the docker container. Setting it to a path on your host will certainly break things, you should use the `UPLOAD_LOCATION` variable instead.
\*3: With the default `WORKDIR` of `/usr/src/app`, this path will resolve to `/usr/src/app/upload`.
It only needs to be set if the Immich deployment method is changing.
## Workers
| Variable | Description | Default | Containers |

View File

@@ -1,4 +1,8 @@
[
{
"label": "v1.136.0",
"url": "https://v1.136.0.archive.immich.app"
},
{
"label": "v1.135.3",
"url": "https://v1.135.3.archive.immich.app"

8
e2e/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "immich-e2e",
"version": "1.135.3",
"version": "1.136.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "immich-e2e",
"version": "1.135.3",
"version": "1.136.0",
"license": "GNU Affero General Public License version 3",
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
@@ -46,7 +46,7 @@
},
"../cli": {
"name": "@immich/cli",
"version": "2.2.72",
"version": "2.2.73",
"dev": true,
"license": "GNU Affero General Public License version 3",
"dependencies": {
@@ -95,7 +95,7 @@
},
"../open-api/typescript-sdk": {
"name": "@immich/sdk",
"version": "1.135.3",
"version": "1.136.0",
"dev": true,
"license": "GNU Affero General Public License version 3",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "immich-e2e",
"version": "1.135.3",
"version": "1.136.0",
"description": "",
"main": "index.js",
"type": "module",

View File

@@ -397,6 +397,7 @@
"album_cover_updated": "Album cover updated",
"album_delete_confirmation": "Are you sure you want to delete the album {album}?",
"album_delete_confirmation_description": "If this album is shared, other users will not be able to access it anymore.",
"album_deleted": "Album deleted",
"album_info_card_backup_album_excluded": "EXCLUDED",
"album_info_card_backup_album_included": "INCLUDED",
"album_info_updated": "Album info updated",

View File

@@ -1,5 +1,9 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.32.6",
"dart.lineLength": 120,
"[dart]": {
"editor.rulers": [120],
},
"search.exclude": {
"**/.fvm": true
},

View File

@@ -9,6 +9,9 @@
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
formatter:
page_width: 120
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`

View File

@@ -72,20 +72,6 @@ android {
}
}
flavorDimensions "default"
productFlavors {
production {
dimension "default"
applicationId "app.alextran.immich"
}
beta {
dimension "default"
applicationId "app.alextran.immich.beta"
versionNameSuffix "-BETA"
}
}
buildTypes {
debug {
applicationIdSuffix '.debug'

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application android:label="Immich Beta" tools:replace="android:label" />
</manifest>

View File

@@ -35,8 +35,8 @@ platform :android do
task: 'bundle',
build_type: 'Release',
properties: {
"android.injected.version.code" => 204,
"android.injected.version.name" => "1.135.3",
"android.injected.version.code" => 205,
"android.injected.version.name" => "1.136.0",
}
)
upload_to_play_store(skip_upload_apk: true, skip_upload_images: true, skip_upload_screenshots: true, aab: '../build/app/outputs/bundle/release/app-release.aab')

File diff suppressed because one or more lines are too long

View File

@@ -22,7 +22,7 @@ platform :ios do
path: "./Runner.xcodeproj",
)
increment_version_number(
version_number: "1.135.3"
version_number: "1.136.0"
)
increment_build_number(
build_number: latest_testflight_build_number + 1,

View File

@@ -10,7 +10,7 @@ enum ImmichColorPreset {
lime,
green,
cyan,
slateGray
slateGray,
}
const ImmichColorPreset defaultColorPreset = ImmichColorPreset.indigo;

View File

@@ -7,10 +7,8 @@ const Map<String, Locale> locales = {
'Arabic (ar)': Locale('ar'),
'Bulgarian (bg)': Locale('bg'),
'Catalan (ca)': Locale('ca'),
'Chinese Simplified (zh_CN)':
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'SIMPLIFIED'),
'Chinese Traditional (zh_TW)':
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'),
'Chinese Simplified (zh_CN)': Locale.fromSubtags(languageCode: 'zh', scriptCode: 'SIMPLIFIED'),
'Chinese Traditional (zh_TW)': Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'),
'Croatian (hr)': Locale('hr'),
'Czech (cs)': Locale('cs'),
'Danish (da)': Locale('da'),
@@ -37,10 +35,8 @@ const Map<String, Locale> locales = {
'Portuguese (pt)': Locale('pt'),
'Romanian (ro)': Locale('ro'),
'Russian (ru)': Locale('ru'),
'Serbian Cyrillic (sr_Cyrl)':
Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl'),
'Serbian Latin (sr_Latn)':
Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn'),
'Serbian Cyrillic (sr_Cyrl)': Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl'),
'Serbian Latin (sr_Latn)': Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn'),
'Slovak (sk)': Locale('sk'),
'Slovenian (sl)': Locale('sl'),
'Spanish (es)': Locale('es'),

View File

@@ -53,10 +53,8 @@ sealed class BaseAsset {
return const Duration();
}
bool get hasRemote =>
storage == AssetState.remote || storage == AssetState.merged;
bool get hasLocal =>
storage == AssetState.local || storage == AssetState.merged;
bool get hasRemote => storage == AssetState.remote || storage == AssetState.merged;
bool get hasLocal => storage == AssetState.local || storage == AssetState.merged;
bool get isLocalOnly => storage == AssetState.local;
bool get isRemoteOnly => storage == AssetState.remote;

View File

@@ -22,8 +22,7 @@ class LocalAsset extends BaseAsset {
});
@override
AssetState get storage =>
remoteId == null ? AssetState.local : AssetState.merged;
AssetState get storage => remoteId == null ? AssetState.local : AssetState.merged;
@override
String get heroTag => '${id}_${remoteId ?? checksum}';
@@ -54,8 +53,7 @@ class LocalAsset extends BaseAsset {
}
@override
int get hashCode =>
super.hashCode ^ id.hashCode ^ remoteId.hashCode ^ orientation.hashCode;
int get hashCode => super.hashCode ^ id.hashCode ^ remoteId.hashCode ^ orientation.hashCode;
LocalAsset copyWith({
String? id,

View File

@@ -36,8 +36,7 @@ class RemoteAsset extends BaseAsset {
});
@override
AssetState get storage =>
localId == null ? AssetState.remote : AssetState.merged;
AssetState get storage => localId == null ? AssetState.remote : AssetState.merged;
@override
String get heroTag => '${localId ?? checksum}_$id';

View File

@@ -15,9 +15,7 @@ class DeviceAsset {
bool operator ==(covariant DeviceAsset other) {
if (identical(this, other)) return true;
return other.assetId == assetId &&
other.hash == hash &&
other.modifiedTime == modifiedTime;
return other.assetId == assetId && other.hash == hash && other.modifiedTime == modifiedTime;
}
@override

View File

@@ -25,8 +25,7 @@ class ExifInfo {
final int? iso;
final double? exposureSeconds;
bool get hasCoordinates =>
latitude != null && longitude != null && latitude != 0 && longitude != 0;
bool get hasCoordinates => latitude != null && longitude != null && latitude != 0 && longitude != 0;
String get exposureTime {
if (exposureSeconds == null) {

View File

@@ -43,12 +43,7 @@ class LogMessage {
@override
int get hashCode {
return message.hashCode ^
level.hashCode ^
createdAt.hashCode ^
logger.hashCode ^
error.hashCode ^
stack.hashCode;
return message.hashCode ^ level.hashCode ^ createdAt.hashCode ^ logger.hashCode ^ error.hashCode ^ stack.hashCode;
}
@override

View File

@@ -39,8 +39,7 @@ class MemoryData {
String toJson() => json.encode(toMap());
factory MemoryData.fromJson(String source) =>
MemoryData.fromMap(json.decode(source) as Map<String, dynamic>);
factory MemoryData.fromJson(String source) => MemoryData.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() => 'MemoryData(year: $year)';

View File

@@ -55,22 +55,17 @@ class PersonDto {
factory PersonDto.fromMap(Map<String, dynamic> map) {
return PersonDto(
id: map['id'] as String,
birthDate: map['birthDate'] != null
? DateTime.fromMillisecondsSinceEpoch(map['birthDate'] as int)
: null,
birthDate: map['birthDate'] != null ? DateTime.fromMillisecondsSinceEpoch(map['birthDate'] as int) : null,
isHidden: map['isHidden'] as bool,
name: map['name'] as String,
thumbnailPath: map['thumbnailPath'] as String,
updatedAt: map['updatedAt'] != null
? DateTime.fromMillisecondsSinceEpoch(map['updatedAt'] as int)
: null,
updatedAt: map['updatedAt'] != null ? DateTime.fromMillisecondsSinceEpoch(map['updatedAt'] as int) : null,
);
}
String toJson() => json.encode(toMap());
factory PersonDto.fromJson(String source) =>
PersonDto.fromMap(json.decode(source) as Map<String, dynamic>);
factory PersonDto.fromJson(String source) => PersonDto.fromMap(json.decode(source) as Map<String, dynamic>);
@override
bool operator ==(covariant PersonDto other) {

View File

@@ -1,6 +1,9 @@
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
enum Setting<T> {
// TODO: Remove UserDto after new store in drift
currentUser<UserDto?>(StoreKey.currentUser, null),
tilesPerRow<int>(StoreKey.tilesPerRow, 4),
groupAssetsBy<int>(StoreKey.groupAssetsBy, 0),
showStorageIndicator<bool>(StoreKey.storageIndicator, true),

View File

@@ -54,11 +54,7 @@ class Stack {
@override
int get hashCode {
return id.hashCode ^
createdAt.hashCode ^
updatedAt.hashCode ^
ownerId.hashCode ^
primaryAssetId.hashCode;
return id.hashCode ^ createdAt.hashCode ^ updatedAt.hashCode ^ ownerId.hashCode ^ primaryAssetId.hashCode;
}
}
@@ -77,9 +73,7 @@ class StackResponse {
bool operator ==(covariant StackResponse other) {
if (identical(this, other)) return true;
return other.id == id &&
other.primaryAssetId == primaryAssetId &&
other.assetIds == assetIds;
return other.id == id && other.primaryAssetId == primaryAssetId && other.assetIds == assetIds;
}
@override

View File

@@ -3,6 +3,7 @@ import 'package:immich_mobile/domain/utils/event_stream.dart';
enum GroupAssetsBy {
day,
month,
auto,
none;
}

View File

@@ -1,9 +1,6 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
// TODO: Rename to User once Isar is removed
// TODO: Remove UserDto once Isar is removed
class UserDto {
final String id;
final String email;
@@ -44,19 +41,19 @@ class UserDto {
@override
String toString() {
return '''User: {
id: $id,
email: $email,
name: $name,
isAdmin: $isAdmin,
updatedAt: $updatedAt,
profileImagePath: ${profileImagePath ?? '<NA>'},
avatarColor: $avatarColor,
memoryEnabled: $memoryEnabled,
inTimeline: $inTimeline,
isPartnerSharedBy: $isPartnerSharedBy,
isPartnerSharedWith: $isPartnerSharedWith,
quotaUsageInBytes: $quotaUsageInBytes,
quotaSizeInBytes: $quotaSizeInBytes,
id: $id,
email: $email,
name: $name,
isAdmin: $isAdmin,
updatedAt: $updatedAt,
profileImagePath: ${profileImagePath ?? '<NA>'},
avatarColor: $avatarColor,
memoryEnabled: $memoryEnabled,
inTimeline: $inTimeline,
isPartnerSharedBy: $isPartnerSharedBy,
isPartnerSharedWith: $isPartnerSharedWith,
quotaUsageInBytes: $quotaUsageInBytes,
quotaSizeInBytes: $quotaSizeInBytes,
}''';
}
@@ -127,87 +124,229 @@ quotaSizeInBytes: $quotaSizeInBytes,
quotaSizeInBytes.hashCode;
}
class PartnerUserDto {
class User {
final String id;
final String email;
final String name;
final bool inTimeline;
final String email;
final DateTime? deletedAt;
final AvatarColor? avatarColor;
final String? profileImagePath;
const PartnerUserDto({
const User({
required this.id,
required this.email,
required this.name,
required this.inTimeline,
this.profileImagePath,
required this.email,
this.deletedAt,
this.avatarColor,
});
PartnerUserDto copyWith({
User copyWith({
String? id,
String? email,
String? name,
bool? inTimeline,
String? profileImagePath,
String? email,
DateTime? deletedAt,
AvatarColor? avatarColor,
}) {
return PartnerUserDto(
return User(
id: id ?? this.id,
email: email ?? this.email,
name: name ?? this.name,
inTimeline: inTimeline ?? this.inTimeline,
profileImagePath: profileImagePath ?? this.profileImagePath,
email: email ?? this.email,
deletedAt: deletedAt ?? this.deletedAt,
avatarColor: avatarColor ?? this.avatarColor,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'id': id,
'email': email,
'name': name,
'inTimeline': inTimeline,
'profileImagePath': profileImagePath,
};
}
factory PartnerUserDto.fromMap(Map<String, dynamic> map) {
return PartnerUserDto(
id: map['id'] as String,
email: map['email'] as String,
name: map['name'] as String,
inTimeline: map['inTimeline'] as bool,
profileImagePath: map['profileImagePath'] != null
? map['profileImagePath'] as String
: null,
);
}
String toJson() => json.encode(toMap());
factory PartnerUserDto.fromJson(String source) =>
PartnerUserDto.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() {
return 'PartnerUserDto(id: $id, email: $email, name: $name, inTimeline: $inTimeline, profileImagePath: $profileImagePath)';
return '''User {
id: $id,
name: $name,
email: $email,
deletedAt: ${deletedAt ?? "<NA>"},
avatarColor: ${avatarColor ?? "<NA>"},
}''';
}
@override
bool operator ==(covariant PartnerUserDto other) {
bool operator ==(covariant User other) {
if (identical(this, other)) return true;
return other.id == id &&
other.email == email &&
other.name == name &&
other.inTimeline == inTimeline &&
other.profileImagePath == profileImagePath;
other.email == email &&
other.deletedAt == deletedAt &&
other.avatarColor == avatarColor;
}
@override
int get hashCode {
return id.hashCode ^ name.hashCode ^ email.hashCode ^ deletedAt.hashCode ^ avatarColor.hashCode;
}
}
class AuthUser {
final String id;
final String name;
final String email;
final DateTime? deletedAt;
final AvatarColor? avatarColor;
final bool isAdmin;
final String oauthId;
final String? pinCode;
final bool hasProfileImage;
final DateTime profileChangedAt;
final int? quotaSizeInBytes;
final int quotaUsageInBytes;
final String? storageLabel;
const AuthUser({
required this.id,
required this.name,
required this.email,
this.deletedAt,
this.avatarColor,
required this.isAdmin,
required this.oauthId,
this.pinCode,
required this.hasProfileImage,
required this.profileChangedAt,
this.quotaSizeInBytes,
required this.quotaUsageInBytes,
this.storageLabel,
});
AuthUser copyWith({
String? id,
String? name,
String? email,
DateTime? deletedAt,
AvatarColor? avatarColor,
bool? isAdmin,
String? oauthId,
String? pinCode,
bool? hasProfileImage,
DateTime? profileChangedAt,
int? quotaSizeInBytes,
int? quotaUsageInBytes,
String? storageLabel,
}) {
return AuthUser(
id: id ?? this.id,
name: name ?? this.name,
email: email ?? this.email,
deletedAt: deletedAt ?? this.deletedAt,
avatarColor: avatarColor ?? this.avatarColor,
isAdmin: isAdmin ?? this.isAdmin,
oauthId: oauthId ?? this.oauthId,
pinCode: pinCode ?? this.pinCode,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
storageLabel: storageLabel ?? this.storageLabel,
);
}
@override
String toString() {
return '''AuthUser {
id: $id,
name: $name,
email: $email,
deletedAt: ${deletedAt ?? "<NA>"},
avatarColor: ${avatarColor ?? "<NA>"},
isAdmin: $isAdmin,
oauthId: $oauthId,
pinCode: ${pinCode ?? "<NA>"},
hasProfileImage: $hasProfileImage,
profileChangedAt: $profileChangedAt,
quotaSizeInBytes: ${quotaSizeInBytes ?? "<NA>"},
quotaUsageInBytes: $quotaUsageInBytes,
storageLabel: ${storageLabel ?? "<NA>"},
}''';
}
@override
bool operator ==(covariant AuthUser other) {
if (identical(this, other)) return true;
return other.id == id &&
other.name == name &&
other.email == email &&
other.deletedAt == deletedAt &&
other.avatarColor == avatarColor &&
other.isAdmin == isAdmin &&
other.oauthId == oauthId &&
other.pinCode == pinCode &&
other.hasProfileImage == hasProfileImage &&
other.profileChangedAt == profileChangedAt &&
other.quotaSizeInBytes == quotaSizeInBytes &&
other.quotaUsageInBytes == quotaUsageInBytes &&
other.storageLabel == storageLabel;
}
@override
int get hashCode {
return id.hashCode ^
email.hashCode ^
name.hashCode ^
inTimeline.hashCode ^
profileImagePath.hashCode;
email.hashCode ^
deletedAt.hashCode ^
avatarColor.hashCode ^
isAdmin.hashCode ^
oauthId.hashCode ^
pinCode.hashCode ^
hasProfileImage.hashCode ^
profileChangedAt.hashCode ^
quotaSizeInBytes.hashCode ^
quotaUsageInBytes.hashCode ^
storageLabel.hashCode;
}
}
class PartnerUser {
final String id;
final String email;
final String name;
final bool inTimeline;
const PartnerUser({
required this.id,
required this.email,
required this.name,
required this.inTimeline,
});
PartnerUser copyWith({
String? id,
String? email,
String? name,
bool? inTimeline,
}) {
return PartnerUser(
id: id ?? this.id,
email: email ?? this.email,
name: name ?? this.name,
inTimeline: inTimeline ?? this.inTimeline,
);
}
@override
String toString() {
return '''PartnerUser {
id: $id,
email: $email,
name: $name,
inTimeline: $inTimeline,
}''';
}
@override
bool operator ==(covariant PartnerUser other) {
if (identical(this, other)) return true;
return other.id == id && other.email == email && other.name == name && other.inTimeline == inTimeline;
}
@override
int get hashCode {
return id.hashCode ^ email.hashCode ^ name.hashCode ^ inTimeline.hashCode;
}
}

View File

@@ -24,8 +24,7 @@ enum AvatarColor {
const AvatarColor(this.value);
Color toColor({bool isDarkTheme = false}) => switch (this) {
AvatarColor.primary =>
isDarkTheme ? const Color(0xFFABCBFA) : const Color(0xFF4250AF),
AvatarColor.primary => isDarkTheme ? const Color(0xFFABCBFA) : const Color(0xFF4250AF),
AvatarColor.pink => const Color.fromARGB(255, 244, 114, 182),
AvatarColor.red => const Color.fromARGB(255, 239, 68, 68),
AvatarColor.yellow => const Color.fromARGB(255, 234, 179, 8),
@@ -241,14 +240,11 @@ licenseKey: $licenseKey,
bool operator ==(covariant License other) {
if (identical(this, other)) return true;
return activatedAt == other.activatedAt &&
activationKey == other.activationKey &&
licenseKey == other.licenseKey;
return activatedAt == other.activatedAt && activationKey == other.activationKey && licenseKey == other.licenseKey;
}
@override
int get hashCode =>
activatedAt.hashCode ^ activationKey.hashCode ^ licenseKey.hashCode;
int get hashCode => activatedAt.hashCode ^ activationKey.hashCode ^ licenseKey.hashCode;
}
// Model for a user metadata stored in the server
@@ -310,10 +306,6 @@ license: ${license ?? "<NA>"},
@override
int get hashCode {
return userId.hashCode ^
key.hashCode ^
onboarding.hashCode ^
preferences.hashCode ^
license.hashCode;
return userId.hashCode ^ key.hashCode ^ onboarding.hashCode ^ preferences.hashCode ^ license.hashCode;
}
}

View File

@@ -19,9 +19,7 @@ class AssetService {
Stream<BaseAsset?> watchAsset(BaseAsset asset) {
final id = asset is LocalAsset ? asset.id : (asset as RemoteAsset).id;
return asset is LocalAsset
? _localAssetRepository.watchAsset(id)
: _remoteAssetRepository.watchAsset(id);
return asset is LocalAsset ? _localAssetRepository.watchAsset(id) : _remoteAssetRepository.watchAsset(id);
}
Future<List<RemoteAsset>> getStack(RemoteAsset asset) async {
@@ -40,8 +38,7 @@ class AssetService {
return null;
}
final id =
asset is LocalAsset ? asset.remoteId! : (asset as RemoteAsset).id;
final id = asset is LocalAsset ? asset.remoteId! : (asset as RemoteAsset).id;
return _remoteAssetRepository.getExif(id);
}
@@ -56,8 +53,7 @@ class AssetService {
width = exif?.width ?? asset.width?.toDouble();
height = exif?.height ?? asset.height?.toDouble();
} else if (asset is LocalAsset) {
isFlipped = _platform.isAndroid &&
(asset.orientation == 90 || asset.orientation == 270);
isFlipped = _platform.isAndroid && (asset.orientation == 90 || asset.orientation == 270);
width = asset.width?.toDouble();
height = asset.height?.toDouble();
} else {
@@ -78,10 +74,7 @@ class AssetService {
}
Future<(int local, int remote)> getAssetCounts() async {
return (
await _localAssetRepository.getCount(),
await _remoteAssetRepository.getCount()
);
return (await _localAssetRepository.getCount(), await _remoteAssetRepository.getCount());
}
Future<int> getLocalHashedCount() {

View File

@@ -41,8 +41,7 @@ class HashService {
);
for (final album in localAlbums) {
final assetsToHash =
await _localAlbumRepository.getAssetsToHash(album.id);
final assetsToHash = await _localAlbumRepository.getAssetsToHash(album.id);
if (assetsToHash.isNotEmpty) {
await _hashAssets(assetsToHash);
}
@@ -88,8 +87,7 @@ class HashService {
_log.fine("Hashing ${toHash.length} files");
final hashed = <LocalAsset>[];
final hashes =
await _nativeSyncApi.hashPaths(toHash.map((e) => e.path).toList());
final hashes = await _nativeSyncApi.hashPaths(toHash.map((e) => e.path).toList());
assert(
hashes.length == toHash.length,
"Hashes length does not match toHash length: ${hashes.length} != ${toHash.length}",

View File

@@ -66,8 +66,7 @@ class LocalSyncService {
// On iOS, we need to full sync albums that are marked as cloud as the delta sync
// does not include changes for cloud albums. If ignoreIcloudAssets is enabled,
// remove the albums from the local database from the previous sync
final cloudAlbums =
deviceAlbums.where((a) => a.isCloud).toLocalAlbums();
final cloudAlbums = deviceAlbums.where((a) => a.isCloud).toLocalAlbums();
for (final album in cloudAlbums) {
final dbAlbum = dbAlbums.firstWhereOrNull((a) => a.id == album.id);
if (dbAlbum == null) {
@@ -95,8 +94,7 @@ class LocalSyncService {
final Stopwatch stopwatch = Stopwatch()..start();
final deviceAlbums = await _nativeSyncApi.getAlbums();
final dbAlbums =
await _localAlbumRepository.getAll(sortBy: {SortLocalAlbumsBy.id});
final dbAlbums = await _localAlbumRepository.getAll(sortBy: {SortLocalAlbumsBy.id});
await diffSortedLists(
dbAlbums,
@@ -120,9 +118,7 @@ class LocalSyncService {
try {
_log.fine("Adding device album ${album.name}");
final assets = album.assetCount > 0
? await _nativeSyncApi.getAssetsForAlbum(album.id)
: <PlatformAsset>[];
final assets = album.assetCount > 0 ? await _nativeSyncApi.getAssetsForAlbum(album.id) : <PlatformAsset>[];
await _localAlbumRepository.upsert(
album,
@@ -188,10 +184,8 @@ class LocalSyncService {
return false;
}
final updatedTime =
(dbAlbum.updatedAt.millisecondsSinceEpoch ~/ 1000) + 1;
final newAssetsCount =
await _nativeSyncApi.getAssetsCountSince(deviceAlbum.id, updatedTime);
final updatedTime = (dbAlbum.updatedAt.millisecondsSinceEpoch ~/ 1000) + 1;
final newAssetsCount = await _nativeSyncApi.getAssetsCountSince(deviceAlbum.id, updatedTime);
// Early return if no new assets were found
if (newAssetsCount == 0) {
@@ -230,13 +224,9 @@ class LocalSyncService {
Future<bool> fullDiff(LocalAlbum dbAlbum, LocalAlbum deviceAlbum) async {
try {
final assetsInDevice = deviceAlbum.assetCount > 0
? await _nativeSyncApi
.getAssetsForAlbum(deviceAlbum.id)
.then((a) => a.toLocalAssets())
: <LocalAsset>[];
final assetsInDb = dbAlbum.assetCount > 0
? await _localAlbumRepository.getAssets(dbAlbum.id)
? await _nativeSyncApi.getAssetsForAlbum(deviceAlbum.id).then((a) => a.toLocalAssets())
: <LocalAsset>[];
final assetsInDb = dbAlbum.assetCount > 0 ? await _localAlbumRepository.getAssets(dbAlbum.id) : <LocalAsset>[];
if (deviceAlbum.assetCount == 0) {
_log.fine(
@@ -321,9 +311,7 @@ class LocalSyncService {
}
bool _albumsEqual(LocalAlbum a, LocalAlbum b) {
return a.name == b.name &&
a.assetCount == b.assetCount &&
a.updatedAt.isAtSameMomentAs(b.updatedAt);
return a.name == b.name && a.assetCount == b.assetCount && a.updatedAt.isAtSameMomentAs(b.updatedAt);
}
}
@@ -333,9 +321,7 @@ extension on Iterable<PlatformAlbum> {
(e) => LocalAlbum(
id: e.id,
name: e.name,
updatedAt: e.updatedAt == null
? DateTime.now()
: DateTime.fromMillisecondsSinceEpoch(e.updatedAt! * 1000),
updatedAt: e.updatedAt == null ? DateTime.now() : DateTime.fromMillisecondsSinceEpoch(e.updatedAt! * 1000),
assetCount: e.assetCount,
),
).toList();
@@ -350,12 +336,8 @@ extension on Iterable<PlatformAsset> {
name: e.name,
checksum: null,
type: AssetType.values.elementAtOrNull(e.type) ?? AssetType.other,
createdAt: e.createdAt == null
? DateTime.now()
: DateTime.fromMillisecondsSinceEpoch(e.createdAt! * 1000),
updatedAt: e.updatedAt == null
? DateTime.now()
: DateTime.fromMillisecondsSinceEpoch(e.updatedAt! * 1000),
createdAt: e.createdAt == null ? DateTime.now() : DateTime.fromMillisecondsSinceEpoch(e.createdAt! * 1000),
updatedAt: e.updatedAt == null ? DateTime.now() : DateTime.fromMillisecondsSinceEpoch(e.updatedAt! * 1000),
width: e.width,
height: e.height,
durationInSeconds: e.durationInSeconds,

View File

@@ -56,8 +56,7 @@ class LogService {
}) async {
final instance = LogService._(logRepository, storeRepository, shouldBuffer);
await logRepository.truncate(limit: kLogTruncateLimit);
final level = await instance._storeRepository.tryGet(StoreKey.logLevel) ??
LogLevel.info.index;
final level = await instance._storeRepository.tryGet(StoreKey.logLevel) ?? LogLevel.info.index;
Logger.root.level = Level.LEVELS.elementAtOrNull(level) ?? Level.INFO;
return instance;
}
@@ -146,9 +145,7 @@ class LoggerUnInitializedException implements Exception {
/// Log levels according to dart logging [Level]
extension LevelDomainToInfraExtension on Level {
LogLevel toLogLevel() =>
LogLevel.values.elementAtOrNull(Level.LEVELS.indexOf(this)) ??
LogLevel.info;
LogLevel toLogLevel() => LogLevel.values.elementAtOrNull(Level.LEVELS.indexOf(this)) ?? LogLevel.info;
}
extension on LogLevel {

View File

@@ -12,21 +12,19 @@ class DriftPartnerService {
this._partnerApiRepository,
);
Future<List<PartnerUserDto>> getSharedWith(String userId) {
Future<List<PartnerUser>> getSharedWith(String userId) {
return _driftPartnerRepository.getSharedWith(userId);
}
Future<List<PartnerUserDto>> getSharedBy(String userId) {
Future<List<PartnerUser>> getSharedBy(String userId) {
return _driftPartnerRepository.getSharedBy(userId);
}
Future<List<PartnerUserDto>> getAvailablePartners(
Future<List<PartnerUser>> getAvailablePartners(
String currentUserId,
) async {
final otherUsers =
await _driftPartnerRepository.getAvailablePartners(currentUserId);
final currentPartners =
await _driftPartnerRepository.getSharedBy(currentUserId);
final otherUsers = await _driftPartnerRepository.getAvailablePartners(currentUserId);
final currentPartners = await _driftPartnerRepository.getSharedBy(currentUserId);
final available = otherUsers.where((user) {
return !currentPartners.any((partner) => partner.id == user.id);
}).toList();

View File

@@ -44,8 +44,7 @@ class RemoteAlbumService {
filtered = filtered
.where(
(album) =>
album.name.toLowerCase().contains(lowerQuery) ||
album.description.toLowerCase().contains(lowerQuery),
album.name.toLowerCase().contains(lowerQuery) || album.description.toLowerCase().contains(lowerQuery),
)
.toList();
}
@@ -53,12 +52,10 @@ class RemoteAlbumService {
if (userId != null) {
switch (filterMode) {
case QuickFilterMode.myAlbums:
filtered =
filtered.where((album) => album.ownerId == userId).toList();
filtered = filtered.where((album) => album.ownerId == userId).toList();
break;
case QuickFilterMode.sharedWithMe:
filtered =
filtered.where((album) => album.ownerId != userId).toList();
filtered = filtered.where((album) => album.ownerId != userId).toList();
break;
case QuickFilterMode.all:
break;
@@ -111,7 +108,7 @@ class RemoteAlbumService {
return _repository.getDateRange(albumId);
}
Future<List<UserDto>> getSharedUsers(String albumId) {
Future<List<User>> getSharedUsers(String albumId) {
return _repository.getSharedUsers(albumId);
}

View File

@@ -9,16 +9,11 @@ final AppSetting = SettingsService(storeService: StoreService.I);
class SettingsService {
final StoreService _storeService;
const SettingsService({required StoreService storeService})
: _storeService = storeService;
const SettingsService({required StoreService storeService}) : _storeService = storeService;
T get<T>(Setting<T> setting) =>
_storeService.get(setting.storeKey, setting.defaultValue);
T get<T>(Setting<T> setting) => _storeService.get(setting.storeKey, setting.defaultValue);
Future<void> set<T>(Setting<T> setting, T value) =>
_storeService.put(setting.storeKey, value);
Future<void> set<T>(Setting<T> setting, T value) => _storeService.put(setting.storeKey, value);
Stream<T> watch<T>(Setting<T> setting) => _storeService
.watch(setting.storeKey)
.map((v) => v ?? setting.defaultValue);
Stream<T> watch<T>(Setting<T> setting) => _storeService.watch(setting.storeKey).map((v) => v ?? setting.defaultValue);
}

View File

@@ -12,8 +12,7 @@ class StoreService {
final Map<int, Object?> _cache = {};
late final StreamSubscription<StoreDto> _storeUpdateSubscription;
StoreService._({required IsarStoreRepository storeRepository})
: _storeRepository = storeRepository;
StoreService._({required IsarStoreRepository storeRepository}) : _storeRepository = storeRepository;
// TODO: Temporary typedef to make minimal changes. Remove this and make the presentation layer access store through a provider
static StoreService? _instance;
@@ -48,8 +47,7 @@ class StoreService {
}
}
StreamSubscription<StoreDto> _listenForChange() =>
_storeRepository.watchAll().listen((event) {
StreamSubscription<StoreDto> _listenForChange() => _storeRepository.watchAll().listen((event) {
_cache[event.key.id] = event.value;
});

View File

@@ -25,7 +25,7 @@ class SyncStreamService {
bool get isCancelled => _cancelChecker?.call() ?? false;
Future<void> sync() {
_logger.info("Remote sync request for userr");
_logger.info("Remote sync request for user");
DLog.log("Remote sync request for user");
// Start the sync stream and handle events
return _syncApiRepository.streamChanges(_handleEvents);
@@ -120,6 +120,8 @@ class SyncStreamService {
) async {
_logger.fine("Processing sync data for $type of length ${data.length}");
switch (type) {
case SyncEntityType.authUserV1:
return _syncStreamRepository.updateAuthUsersV1(data.cast());
case SyncEntityType.userV1:
return _syncStreamRepository.updateUsersV1(data.cast());
case SyncEntityType.userDeleteV1:

View File

@@ -33,11 +33,13 @@ class TimelineFactory {
}) : _timelineRepository = timelineRepository,
_settingsService = settingsService;
GroupAssetsBy get groupBy =>
GroupAssetsBy.values[_settingsService.get(Setting.groupAssetsBy)];
GroupAssetsBy get groupBy {
final group = GroupAssetsBy.values[_settingsService.get(Setting.groupAssetsBy)];
// We do not support auto grouping in the new timeline yet, fallback to day grouping
return group == GroupAssetsBy.auto ? GroupAssetsBy.day : group;
}
TimelineService main(List<String> timelineUsers) =>
TimelineService(_timelineRepository.main(timelineUsers, groupBy));
TimelineService main(List<String> timelineUsers) => TimelineService(_timelineRepository.main(timelineUsers, groupBy));
TimelineService localAlbum({required String albumId}) =>
TimelineService(_timelineRepository.localAlbum(albumId, groupBy));
@@ -45,29 +47,21 @@ class TimelineFactory {
TimelineService remoteAlbum({required String albumId}) =>
TimelineService(_timelineRepository.remoteAlbum(albumId, groupBy));
TimelineService remoteAssets(String userId) =>
TimelineService(_timelineRepository.remote(userId, groupBy));
TimelineService remoteAssets(String userId) => TimelineService(_timelineRepository.remote(userId, groupBy));
TimelineService favorite(String userId) =>
TimelineService(_timelineRepository.favorite(userId, groupBy));
TimelineService favorite(String userId) => TimelineService(_timelineRepository.favorite(userId, groupBy));
TimelineService trash(String userId) =>
TimelineService(_timelineRepository.trash(userId, groupBy));
TimelineService trash(String userId) => TimelineService(_timelineRepository.trash(userId, groupBy));
TimelineService archive(String userId) =>
TimelineService(_timelineRepository.archived(userId, groupBy));
TimelineService archive(String userId) => TimelineService(_timelineRepository.archived(userId, groupBy));
TimelineService lockedFolder(String userId) =>
TimelineService(_timelineRepository.locked(userId, groupBy));
TimelineService lockedFolder(String userId) => TimelineService(_timelineRepository.locked(userId, groupBy));
TimelineService video(String userId) =>
TimelineService(_timelineRepository.video(userId, groupBy));
TimelineService video(String userId) => TimelineService(_timelineRepository.video(userId, groupBy));
TimelineService place(String place) =>
TimelineService(_timelineRepository.place(place, groupBy));
TimelineService place(String place) => TimelineService(_timelineRepository.place(place, groupBy));
TimelineService fromAssets(List<BaseAsset> assets) =>
TimelineService(_timelineRepository.fromAssets(assets));
TimelineService fromAssets(List<BaseAsset> assets) => TimelineService(_timelineRepository.fromAssets(assets));
}
class TimelineService {
@@ -94,8 +88,7 @@ class TimelineService {
_bucketSource = bucketSource {
_bucketSubscription = _bucketSource().listen((buckets) {
_mutex.run(() async {
final totalAssets =
buckets.fold<int>(0, (acc, bucket) => acc + bucket.assetCount);
final totalAssets = buckets.fold<int>(0, (acc, bucket) => acc + bucket.assetCount);
if (totalAssets == 0) {
_bufferOffset = 0;
@@ -128,8 +121,7 @@ class TimelineService {
Stream<List<Bucket>> Function() get watchBuckets => _bucketSource;
Future<List<BaseAsset>> loadAssets(int index, int count) =>
_mutex.run(() => _loadAssets(index, count));
Future<List<BaseAsset>> loadAssets(int index, int count) => _mutex.run(() => _loadAssets(index, count));
Future<List<BaseAsset>> _loadAssets(int index, int count) async {
if (hasRange(index, count)) {
@@ -178,11 +170,9 @@ class TimelineService {
}
// Pre-cache assets around the given index for asset viewer
Future<void> preCacheAssets(int index) =>
_mutex.run(() => _loadAssets(index, math.min(5, _totalAssets - index)));
Future<void> preCacheAssets(int index) => _mutex.run(() => _loadAssets(index, math.min(5, _totalAssets - index)));
BaseAsset getRandomAsset() =>
_buffer.elementAt(math.Random().nextInt(_buffer.length));
BaseAsset getRandomAsset() => _buffer.elementAt(math.Random().nextInt(_buffer.length));
BaseAsset getAsset(int index) {
if (!hasRange(index, 1)) {

View File

@@ -1,8 +1,10 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:immich_mobile/domain/models/setting.model.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/services/setting.service.dart';
import 'package:immich_mobile/domain/services/store.service.dart';
import 'package:immich_mobile/infrastructure/repositories/user.repository.dart';
import 'package:immich_mobile/infrastructure/repositories/user_api.repository.dart';
@@ -66,3 +68,28 @@ class UserService {
return _isarUserRepository.deleteAll();
}
}
class DriftUserService {
final DriftUserRepository _userRepository;
final SettingsService _settingsService;
const DriftUserService(
this._userRepository,
this._settingsService,
);
Future<User?> getMyUser() {
// TODO: Remove UserDto after new store
final isarCurrentUser = _settingsService.get(Setting.currentUser);
if (isarCurrentUser == null) {
throw Exception('User must be login');
}
return _userRepository.getById(isarCurrentUser.id);
}
Future<List<User>> getAll() {
return _userRepository.getAll();
}
}

View File

@@ -67,12 +67,10 @@ class BackgroundSyncManager {
// captured by the closure passed to [runInIsolateGentle].
_deviceAlbumSyncTask = full
? runInIsolateGentle(
computation: (ref) =>
ref.read(localSyncServiceProvider).sync(full: true),
computation: (ref) => ref.read(localSyncServiceProvider).sync(full: true),
)
: runInIsolateGentle(
computation: (ref) =>
ref.read(localSyncServiceProvider).sync(full: false),
computation: (ref) => ref.read(localSyncServiceProvider).sync(full: false),
);
return _deviceAlbumSyncTask!.whenComplete(() {
@@ -139,7 +137,5 @@ Cancelable<void> _handleWsAssetUploadReadyV1Batch(
List<dynamic> batchData,
) =>
runInIsolateGentle(
computation: (ref) => ref
.read(syncStreamServiceProvider)
.handleWsAssetUploadReadyV1Batch(batchData),
computation: (ref) => ref.read(syncStreamServiceProvider).handleWsAssetUploadReadyV1Batch(batchData),
);

View File

@@ -9,8 +9,7 @@ class EventStream {
static final EventStream shared = EventStream._();
final StreamController<Event> _controller =
StreamController<Event>.broadcast();
final StreamController<Event> _controller = StreamController<Event>.broadcast();
void emit(Event event) {
_controller.add(event);

View File

@@ -45,9 +45,9 @@ class Album {
bool activityEnabled;
@enumerated
SortOrder sortOrder;
final IsarLink<User> owner = IsarLink<User>();
final IsarLink<IsarUser> owner = IsarLink<IsarUser>();
final IsarLink<Asset> thumbnail = IsarLink<Asset>();
final IsarLinks<User> sharedUsers = IsarLinks<User>();
final IsarLinks<IsarUser> sharedUsers = IsarLinks<IsarUser>();
final IsarLinks<Asset> assets = IsarLinks<Asset>();
// transient fields
@@ -95,13 +95,11 @@ class Album {
// accessible in an object freshly created (not loaded from DB)
@ignore
Iterable<User> get remoteUsers => sharedUsers.isEmpty
? (sharedUsers as IsarLinksCommon<User>).addedObjects
: sharedUsers;
Iterable<IsarUser> get remoteUsers =>
sharedUsers.isEmpty ? (sharedUsers as IsarLinksCommon<IsarUser>).addedObjects : sharedUsers;
@ignore
Iterable<Asset> get remoteAssets =>
assets.isEmpty ? (assets as IsarLinksCommon<Asset>).addedObjects : assets;
Iterable<Asset> get remoteAssets => assets.isEmpty ? (assets as IsarLinksCommon<Asset>).addedObjects : assets;
@override
bool operator ==(other) {
@@ -162,35 +160,29 @@ class Album {
activityEnabled: dto.isActivityEnabled,
);
a.remoteAssetCount = dto.assetCount;
a.owner.value = await db.users.getById(dto.ownerId);
a.owner.value = await db.isarUsers.getById(dto.ownerId);
if (dto.order != null) {
a.sortOrder =
dto.order == AssetOrder.asc ? SortOrder.asc : SortOrder.desc;
a.sortOrder = dto.order == AssetOrder.asc ? SortOrder.asc : SortOrder.desc;
}
if (dto.albumThumbnailAssetId != null) {
a.thumbnail.value = await db.assets
.where()
.remoteIdEqualTo(dto.albumThumbnailAssetId)
.findFirst();
a.thumbnail.value = await db.assets.where().remoteIdEqualTo(dto.albumThumbnailAssetId).findFirst();
}
if (dto.albumUsers.isNotEmpty) {
final users = await db.users.getAllById(
final users = await db.isarUsers.getAllById(
dto.albumUsers.map((e) => e.user.id).toList(growable: false),
);
a.sharedUsers.addAll(users.cast());
}
if (dto.assets.isNotEmpty) {
final assets =
await db.assets.getAllByRemoteId(dto.assets.map((e) => e.id));
final assets = await db.assets.getAllByRemoteId(dto.assets.map((e) => e.id));
a.assets.addAll(assets);
}
return a;
}
@override
String toString() =>
'remoteId: $remoteId name: $name description: $description';
String toString() => 'remoteId: $remoteId name: $name description: $description';
}
extension AssetsHelper on IsarCollection<Album> {

View File

@@ -116,7 +116,7 @@ const AlbumSchema = CollectionSchema(
r'owner': LinkSchema(
id: 8272576585804958029,
name: r'owner',
target: r'User',
target: r'IsarUser',
single: true,
),
r'thumbnail': LinkSchema(
@@ -128,7 +128,7 @@ const AlbumSchema = CollectionSchema(
r'sharedUsers': LinkSchema(
id: 8972835302564625434,
name: r'sharedUsers',
target: r'User',
target: r'IsarUser',
single: false,
),
r'assets': LinkSchema(
@@ -275,10 +275,10 @@ List<IsarLinkBase<dynamic>> _albumGetLinks(Album object) {
void _albumAttach(IsarCollection<dynamic> col, Id id, Album object) {
object.id = id;
object.owner.attach(col, col.isar.collection<User>(), r'owner', id);
object.owner.attach(col, col.isar.collection<IsarUser>(), r'owner', id);
object.thumbnail.attach(col, col.isar.collection<Asset>(), r'thumbnail', id);
object.sharedUsers
.attach(col, col.isar.collection<User>(), r'sharedUsers', id);
.attach(col, col.isar.collection<IsarUser>(), r'sharedUsers', id);
object.assets.attach(col, col.isar.collection<Asset>(), r'assets', id);
}
@@ -1500,7 +1500,8 @@ extension AlbumQueryFilter on QueryBuilder<Album, Album, QFilterCondition> {
extension AlbumQueryObject on QueryBuilder<Album, Album, QFilterCondition> {}
extension AlbumQueryLinks on QueryBuilder<Album, Album, QFilterCondition> {
QueryBuilder<Album, Album, QAfterFilterCondition> owner(FilterQuery<User> q) {
QueryBuilder<Album, Album, QAfterFilterCondition> owner(
FilterQuery<IsarUser> q) {
return QueryBuilder.apply(this, (query) {
return query.link(q, r'owner');
});
@@ -1526,7 +1527,7 @@ extension AlbumQueryLinks on QueryBuilder<Album, Album, QFilterCondition> {
}
QueryBuilder<Album, Album, QAfterFilterCondition> sharedUsers(
FilterQuery<User> q) {
FilterQuery<IsarUser> q) {
return QueryBuilder.apply(this, (query) {
return query.link(q, r'sharedUsers');
});

View File

@@ -4,8 +4,7 @@ import 'dart:io';
import 'package:immich_mobile/constants/enums.dart';
import 'package:immich_mobile/domain/models/exif.model.dart';
import 'package:immich_mobile/extensions/string_extensions.dart';
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart'
as entity;
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' as entity;
import 'package:immich_mobile/infrastructure/utils/exif.converter.dart';
import 'package:immich_mobile/utils/diff.dart';
import 'package:immich_mobile/utils/hash.dart';
@@ -32,18 +31,14 @@ class Asset {
width = remote.exifInfo?.exifImageWidth?.toInt(),
livePhotoVideoId = remote.livePhotoVideoId,
ownerId = fastHash(remote.ownerId),
exifInfo = remote.exifInfo == null
? null
: ExifDtoConverter.fromDto(remote.exifInfo!),
exifInfo = remote.exifInfo == null ? null : ExifDtoConverter.fromDto(remote.exifInfo!),
isFavorite = remote.isFavorite,
isArchived = remote.isArchived,
isTrashed = remote.isTrashed,
isOffline = remote.isOffline,
// workaround to nullify stackPrimaryAssetId for the parent asset until we refactor the mobile app
// stack handling to properly handle it
stackPrimaryAssetId = remote.stack?.primaryAssetId == remote.id
? null
: remote.stack?.primaryAssetId,
stackPrimaryAssetId = remote.stack?.primaryAssetId == remote.id ? null : remote.stack?.primaryAssetId,
stackCount = remote.stack?.assetCount ?? 0,
stackId = remote.stack?.id,
thumbhash = remote.thumbhash,
@@ -108,8 +103,7 @@ class Asset {
throw Exception('Asset $fileName has no local data');
}
final updatedLocal =
_didUpdateLocal ? local : await local.obtainForNewProperties();
final updatedLocal = _didUpdateLocal ? local : await local.obtainForNewProperties();
if (updatedLocal == null) {
throw Exception('Could not fetch local data for $fileName');
}
@@ -185,10 +179,7 @@ class Asset {
final orientatedWidth = this.orientatedWidth;
final orientatedHeight = this.orientatedHeight;
if (orientatedWidth != null &&
orientatedHeight != null &&
orientatedWidth > 0 &&
orientatedHeight > 0) {
if (orientatedWidth != null && orientatedHeight != null && orientatedWidth > 0 && orientatedHeight > 0) {
return orientatedWidth.toDouble() / orientatedHeight.toDouble();
}
@@ -389,8 +380,7 @@ class Asset {
// workaround to nullify stackPrimaryAssetId for the parent asset until we refactor the mobile app
// stack handling to properly handle it
stackId: stackId,
stackPrimaryAssetId:
stackPrimaryAssetId == remoteId ? null : stackPrimaryAssetId,
stackPrimaryAssetId: stackPrimaryAssetId == remoteId ? null : stackPrimaryAssetId,
stackCount: stackCount,
isFavorite: isFavorite,
isArchived: isArchived,
@@ -410,9 +400,7 @@ class Asset {
// workaround to nullify stackPrimaryAssetId for the parent asset until we refactor the mobile app
// stack handling to properly handle it
stackId: a.stackId,
stackPrimaryAssetId: a.stackPrimaryAssetId == a.remoteId
? null
: a.stackPrimaryAssetId,
stackPrimaryAssetId: a.stackPrimaryAssetId == a.remoteId ? null : a.stackPrimaryAssetId,
stackCount: a.stackCount,
// isFavorite + isArchived are not set by device-only assets
isFavorite: a.isFavorite,
@@ -428,8 +416,7 @@ class Asset {
localId: localId ?? a.localId,
width: width ?? a.width,
height: height ?? a.height,
exifInfo: exifInfo ??
a.exifInfo?.copyWith(assetId: id), // updated to use assetId
exifInfo: exifInfo ?? a.exifInfo?.copyWith(assetId: id), // updated to use assetId
);
}
}
@@ -491,18 +478,15 @@ class Asset {
Future<void> put(Isar db) async {
await db.assets.put(this);
if (exifInfo != null) {
await db.exifInfos
.put(entity.ExifInfo.fromDto(exifInfo!.copyWith(assetId: id)));
await db.exifInfos.put(entity.ExifInfo.fromDto(exifInfo!.copyWith(assetId: id)));
}
}
static int compareById(Asset a, Asset b) => a.id.compareTo(b.id);
static int compareByLocalId(Asset a, Asset b) =>
compareToNullable(a.localId, b.localId);
static int compareByLocalId(Asset a, Asset b) => compareToNullable(a.localId, b.localId);
static int compareByChecksum(Asset a, Asset b) =>
a.checksum.compareTo(b.checksum);
static int compareByChecksum(Asset a, Asset b) => a.checksum.compareTo(b.checksum);
static int compareByOwnerChecksum(Asset a, Asset b) {
final int ownerIdOrder = a.ownerId.compareTo(b.ownerId);
@@ -589,16 +573,11 @@ enum AssetState {
}
extension AssetsHelper on IsarCollection<Asset> {
Future<int> deleteAllByRemoteId(Iterable<String> ids) =>
ids.isEmpty ? Future.value(0) : remote(ids).deleteAll();
Future<int> deleteAllByLocalId(Iterable<String> ids) =>
ids.isEmpty ? Future.value(0) : local(ids).deleteAll();
Future<List<Asset>> getAllByRemoteId(Iterable<String> ids) =>
ids.isEmpty ? Future.value([]) : remote(ids).findAll();
Future<List<Asset>> getAllByLocalId(Iterable<String> ids) =>
ids.isEmpty ? Future.value([]) : local(ids).findAll();
Future<Asset?> getByRemoteId(String id) =>
where().remoteIdEqualTo(id).findFirst();
Future<int> deleteAllByRemoteId(Iterable<String> ids) => ids.isEmpty ? Future.value(0) : remote(ids).deleteAll();
Future<int> deleteAllByLocalId(Iterable<String> ids) => ids.isEmpty ? Future.value(0) : local(ids).deleteAll();
Future<List<Asset>> getAllByRemoteId(Iterable<String> ids) => ids.isEmpty ? Future.value([]) : remote(ids).findAll();
Future<List<Asset>> getAllByLocalId(Iterable<String> ids) => ids.isEmpty ? Future.value([]) : local(ids).findAll();
Future<Asset?> getByRemoteId(String id) => where().remoteIdEqualTo(id).findFirst();
QueryBuilder<Asset, Asset, QAfterWhereClause> remote(
Iterable<String> ids,

View File

@@ -22,15 +22,13 @@ extension LogOnError<T> on AsyncValue<T> {
}
if (!skip) {
return onLoading?.call() ??
const Center(child: ImmichLoadingIndicator());
return onLoading?.call() ?? const Center(child: ImmichLoadingIndicator());
}
}
if (hasError && !hasValue) {
_asyncErrorLogger.severe('Could not load value', error, stackTrace);
return onError?.call(error, stackTrace) ??
ScaffoldErrorBody(errorMsg: error?.toString());
return onError?.call(error, stackTrace) ?? ScaffoldErrorBody(errorMsg: error?.toString());
}
return onData(requireValue);

View File

@@ -60,6 +60,5 @@ extension ContextHelper on BuildContext {
FocusScopeNode get focusScope => FocusScope.of(this);
// Show SnackBars from the current context
void showSnackBar(SnackBar snackBar) =>
ScaffoldMessenger.of(this).showSnackBar(snackBar);
void showSnackBar(SnackBar snackBar) => ScaffoldMessenger.of(this).showSnackBar(snackBar);
}

View File

@@ -57,9 +57,7 @@ extension DateRangeFormatting on DateTime {
final localeString = locale?.toString() ?? 'en_US';
// Check if it's a single date (same day)
if (startDate.year == endDate.year &&
startDate.month == endDate.month &&
startDate.day == endDate.day) {
if (startDate.year == endDate.year && startDate.month == endDate.month && startDate.day == endDate.day) {
if (startDate.year == currentYear) {
// Single date of this year: "Aug 28"
return DateFormat.MMMd(localeString).format(startDate);

View File

@@ -12,9 +12,7 @@ extension DurationExtension on String {
/// Parses and returns the string of format HH:MM:SS as a duration object else null
Duration? toDuration() {
try {
final parts = split(':')
.map((e) => double.parse(e).toInt())
.toList(growable: false);
final parts = split(':').map((e) => double.parse(e).toInt()).toList(growable: false);
return Duration(hours: parts[0], minutes: parts[1], seconds: parts[2]);
} catch (e) {
return null;

View File

@@ -2,9 +2,7 @@ import 'package:flutter/material.dart';
extension ImmichColorSchemeExtensions on ColorScheme {
bool get _isDarkMode => brightness == Brightness.dark;
Color get onSurfaceSecondary => _isDarkMode
? onSurface.darken(amount: .3)
: onSurface.lighten(amount: .3);
Color get onSurfaceSecondary => _isDarkMode ? onSurface.darken(amount: .3) : onSurface.lighten(amount: .3);
}
extension ColorExtensions on Color {

View File

@@ -40,8 +40,7 @@ String _translateHelper(
try {
final translatedMessage = key.tr(context: context);
return args != null
? MessageFormat(translatedMessage, locale: Intl.defaultLocale ?? 'en')
.format(args)
? MessageFormat(translatedMessage, locale: Intl.defaultLocale ?? 'en').format(args)
: translatedMessage;
} catch (e) {
debugPrint('Translation failed for key "$key". Error: $e');

View File

@@ -8,12 +8,9 @@ class AssetFaceEntity extends Table with DriftDefaultsMixin {
TextColumn get id => text()();
TextColumn get assetId =>
text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get assetId => text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get personId => text()
.nullable()
.references(PersonEntity, #id, onDelete: KeyAction.setNull)();
TextColumn get personId => text().nullable().references(PersonEntity, #id, onDelete: KeyAction.setNull)();
IntColumn get imageWidth => integer()();

View File

@@ -0,0 +1,56 @@
import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart';
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class AuthUserEntity extends Table with DriftDefaultsMixin {
const AuthUserEntity();
TextColumn get id => text()();
TextColumn get name => text()();
TextColumn get email => text()();
DateTimeColumn get deletedAt => dateTime().nullable()();
IntColumn get avatarColor => intEnum<AvatarColor>().nullable()();
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
TextColumn get oauthId => text().withDefault(const Constant(''))();
TextColumn get pinCode => text().nullable()();
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get quotaSizeInBytes => integer().nullable()();
IntColumn get quotaUsageInBytes => integer().withDefault(const Constant(0))();
TextColumn get storageLabel => text().nullable()();
@override
Set<Column> get primaryKey => {id};
}
extension AuthUserEntityDataDomainEx on AuthUserEntityData {
AuthUser toDto() => AuthUser(
id: id,
name: name,
email: email,
deletedAt: deletedAt,
avatarColor: avatarColor,
isAdmin: isAdmin,
oauthId: oauthId,
pinCode: pinCode,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
storageLabel: storageLabel,
);
}

View File

@@ -0,0 +1,951 @@
// dart format width=80
// ignore_for_file: type=lint
import 'package:drift/drift.dart' as i0;
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart'
as i1;
import 'package:immich_mobile/domain/models/user_metadata.model.dart' as i2;
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.dart'
as i3;
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i4;
typedef $$AuthUserEntityTableCreateCompanionBuilder = i1.AuthUserEntityCompanion
Function({
required String id,
required String name,
required String email,
i0.Value<DateTime?> deletedAt,
i0.Value<i2.AvatarColor?> avatarColor,
i0.Value<bool> isAdmin,
i0.Value<String> oauthId,
i0.Value<String?> pinCode,
i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt,
i0.Value<int?> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
i0.Value<String?> storageLabel,
});
typedef $$AuthUserEntityTableUpdateCompanionBuilder = i1.AuthUserEntityCompanion
Function({
i0.Value<String> id,
i0.Value<String> name,
i0.Value<String> email,
i0.Value<DateTime?> deletedAt,
i0.Value<i2.AvatarColor?> avatarColor,
i0.Value<bool> isAdmin,
i0.Value<String> oauthId,
i0.Value<String?> pinCode,
i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt,
i0.Value<int?> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
i0.Value<String?> storageLabel,
});
class $$AuthUserEntityTableFilterComposer
extends i0.Composer<i0.GeneratedDatabase, i1.$AuthUserEntityTable> {
$$AuthUserEntityTableFilterComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
i0.ColumnFilters<String> get id => $composableBuilder(
column: $table.id, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get name => $composableBuilder(
column: $table.name, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get email => $composableBuilder(
column: $table.email, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<DateTime> get deletedAt => $composableBuilder(
column: $table.deletedAt, builder: (column) => i0.ColumnFilters(column));
i0.ColumnWithTypeConverterFilters<i2.AvatarColor?, i2.AvatarColor, int>
get avatarColor => $composableBuilder(
column: $table.avatarColor,
builder: (column) => i0.ColumnWithTypeConverterFilters(column));
i0.ColumnFilters<bool> get isAdmin => $composableBuilder(
column: $table.isAdmin, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get oauthId => $composableBuilder(
column: $table.oauthId, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get pinCode => $composableBuilder(
column: $table.pinCode, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<bool> get hasProfileImage => $composableBuilder(
column: $table.hasProfileImage,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<DateTime> get profileChangedAt => $composableBuilder(
column: $table.profileChangedAt,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get storageLabel => $composableBuilder(
column: $table.storageLabel,
builder: (column) => i0.ColumnFilters(column));
}
class $$AuthUserEntityTableOrderingComposer
extends i0.Composer<i0.GeneratedDatabase, i1.$AuthUserEntityTable> {
$$AuthUserEntityTableOrderingComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
i0.ColumnOrderings<String> get id => $composableBuilder(
column: $table.id, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get name => $composableBuilder(
column: $table.name, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get email => $composableBuilder(
column: $table.email, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<DateTime> get deletedAt => $composableBuilder(
column: $table.deletedAt,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<int> get avatarColor => $composableBuilder(
column: $table.avatarColor,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<bool> get isAdmin => $composableBuilder(
column: $table.isAdmin, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get oauthId => $composableBuilder(
column: $table.oauthId, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get pinCode => $composableBuilder(
column: $table.pinCode, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<bool> get hasProfileImage => $composableBuilder(
column: $table.hasProfileImage,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<DateTime> get profileChangedAt => $composableBuilder(
column: $table.profileChangedAt,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get storageLabel => $composableBuilder(
column: $table.storageLabel,
builder: (column) => i0.ColumnOrderings(column));
}
class $$AuthUserEntityTableAnnotationComposer
extends i0.Composer<i0.GeneratedDatabase, i1.$AuthUserEntityTable> {
$$AuthUserEntityTableAnnotationComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
i0.GeneratedColumn<String> get id =>
$composableBuilder(column: $table.id, builder: (column) => column);
i0.GeneratedColumn<String> get name =>
$composableBuilder(column: $table.name, builder: (column) => column);
i0.GeneratedColumn<String> get email =>
$composableBuilder(column: $table.email, builder: (column) => column);
i0.GeneratedColumn<DateTime> get deletedAt =>
$composableBuilder(column: $table.deletedAt, builder: (column) => column);
i0.GeneratedColumnWithTypeConverter<i2.AvatarColor?, int> get avatarColor =>
$composableBuilder(
column: $table.avatarColor, builder: (column) => column);
i0.GeneratedColumn<bool> get isAdmin =>
$composableBuilder(column: $table.isAdmin, builder: (column) => column);
i0.GeneratedColumn<String> get oauthId =>
$composableBuilder(column: $table.oauthId, builder: (column) => column);
i0.GeneratedColumn<String> get pinCode =>
$composableBuilder(column: $table.pinCode, builder: (column) => column);
i0.GeneratedColumn<bool> get hasProfileImage => $composableBuilder(
column: $table.hasProfileImage, builder: (column) => column);
i0.GeneratedColumn<DateTime> get profileChangedAt => $composableBuilder(
column: $table.profileChangedAt, builder: (column) => column);
i0.GeneratedColumn<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes, builder: (column) => column);
i0.GeneratedColumn<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes, builder: (column) => column);
i0.GeneratedColumn<String> get storageLabel => $composableBuilder(
column: $table.storageLabel, builder: (column) => column);
}
class $$AuthUserEntityTableTableManager extends i0.RootTableManager<
i0.GeneratedDatabase,
i1.$AuthUserEntityTable,
i1.AuthUserEntityData,
i1.$$AuthUserEntityTableFilterComposer,
i1.$$AuthUserEntityTableOrderingComposer,
i1.$$AuthUserEntityTableAnnotationComposer,
$$AuthUserEntityTableCreateCompanionBuilder,
$$AuthUserEntityTableUpdateCompanionBuilder,
(
i1.AuthUserEntityData,
i0.BaseReferences<i0.GeneratedDatabase, i1.$AuthUserEntityTable,
i1.AuthUserEntityData>
),
i1.AuthUserEntityData,
i0.PrefetchHooks Function()> {
$$AuthUserEntityTableTableManager(
i0.GeneratedDatabase db, i1.$AuthUserEntityTable table)
: super(i0.TableManagerState(
db: db,
table: table,
createFilteringComposer: () =>
i1.$$AuthUserEntityTableFilterComposer($db: db, $table: table),
createOrderingComposer: () =>
i1.$$AuthUserEntityTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer: () => i1
.$$AuthUserEntityTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback: ({
i0.Value<String> id = const i0.Value.absent(),
i0.Value<String> name = const i0.Value.absent(),
i0.Value<String> email = const i0.Value.absent(),
i0.Value<DateTime?> deletedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor?> avatarColor = const i0.Value.absent(),
i0.Value<bool> isAdmin = const i0.Value.absent(),
i0.Value<String> oauthId = const i0.Value.absent(),
i0.Value<String?> pinCode = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
i0.Value<String?> storageLabel = const i0.Value.absent(),
}) =>
i1.AuthUserEntityCompanion(
id: id,
name: name,
email: email,
deletedAt: deletedAt,
avatarColor: avatarColor,
isAdmin: isAdmin,
oauthId: oauthId,
pinCode: pinCode,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
storageLabel: storageLabel,
),
createCompanionCallback: ({
required String id,
required String name,
required String email,
i0.Value<DateTime?> deletedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor?> avatarColor = const i0.Value.absent(),
i0.Value<bool> isAdmin = const i0.Value.absent(),
i0.Value<String> oauthId = const i0.Value.absent(),
i0.Value<String?> pinCode = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
i0.Value<String?> storageLabel = const i0.Value.absent(),
}) =>
i1.AuthUserEntityCompanion.insert(
id: id,
name: name,
email: email,
deletedAt: deletedAt,
avatarColor: avatarColor,
isAdmin: isAdmin,
oauthId: oauthId,
pinCode: pinCode,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
storageLabel: storageLabel,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
.toList(),
prefetchHooksCallback: null,
));
}
typedef $$AuthUserEntityTableProcessedTableManager = i0.ProcessedTableManager<
i0.GeneratedDatabase,
i1.$AuthUserEntityTable,
i1.AuthUserEntityData,
i1.$$AuthUserEntityTableFilterComposer,
i1.$$AuthUserEntityTableOrderingComposer,
i1.$$AuthUserEntityTableAnnotationComposer,
$$AuthUserEntityTableCreateCompanionBuilder,
$$AuthUserEntityTableUpdateCompanionBuilder,
(
i1.AuthUserEntityData,
i0.BaseReferences<i0.GeneratedDatabase, i1.$AuthUserEntityTable,
i1.AuthUserEntityData>
),
i1.AuthUserEntityData,
i0.PrefetchHooks Function()>;
class $AuthUserEntityTable extends i3.AuthUserEntity
with i0.TableInfo<$AuthUserEntityTable, i1.AuthUserEntityData> {
@override
final i0.GeneratedDatabase attachedDatabase;
final String? _alias;
$AuthUserEntityTable(this.attachedDatabase, [this._alias]);
static const i0.VerificationMeta _idMeta = const i0.VerificationMeta('id');
@override
late final i0.GeneratedColumn<String> id = i0.GeneratedColumn<String>(
'id', aliasedName, false,
type: i0.DriftSqlType.string, requiredDuringInsert: true);
static const i0.VerificationMeta _nameMeta =
const i0.VerificationMeta('name');
@override
late final i0.GeneratedColumn<String> name = i0.GeneratedColumn<String>(
'name', aliasedName, false,
type: i0.DriftSqlType.string, requiredDuringInsert: true);
static const i0.VerificationMeta _emailMeta =
const i0.VerificationMeta('email');
@override
late final i0.GeneratedColumn<String> email = i0.GeneratedColumn<String>(
'email', aliasedName, false,
type: i0.DriftSqlType.string, requiredDuringInsert: true);
static const i0.VerificationMeta _deletedAtMeta =
const i0.VerificationMeta('deletedAt');
@override
late final i0.GeneratedColumn<DateTime> deletedAt =
i0.GeneratedColumn<DateTime>('deleted_at', aliasedName, true,
type: i0.DriftSqlType.dateTime, requiredDuringInsert: false);
@override
late final i0.GeneratedColumnWithTypeConverter<i2.AvatarColor?, int>
avatarColor = i0.GeneratedColumn<int>('avatar_color', aliasedName, true,
type: i0.DriftSqlType.int, requiredDuringInsert: false)
.withConverter<i2.AvatarColor?>(
i1.$AuthUserEntityTable.$converteravatarColorn);
static const i0.VerificationMeta _isAdminMeta =
const i0.VerificationMeta('isAdmin');
@override
late final i0.GeneratedColumn<bool> isAdmin = i0.GeneratedColumn<bool>(
'is_admin', aliasedName, false,
type: i0.DriftSqlType.bool,
requiredDuringInsert: false,
defaultConstraints:
i0.GeneratedColumn.constraintIsAlways('CHECK ("is_admin" IN (0, 1))'),
defaultValue: const i4.Constant(false));
static const i0.VerificationMeta _oauthIdMeta =
const i0.VerificationMeta('oauthId');
@override
late final i0.GeneratedColumn<String> oauthId = i0.GeneratedColumn<String>(
'oauth_id', aliasedName, false,
type: i0.DriftSqlType.string,
requiredDuringInsert: false,
defaultValue: const i4.Constant(''));
static const i0.VerificationMeta _pinCodeMeta =
const i0.VerificationMeta('pinCode');
@override
late final i0.GeneratedColumn<String> pinCode = i0.GeneratedColumn<String>(
'pin_code', aliasedName, true,
type: i0.DriftSqlType.string, requiredDuringInsert: false);
static const i0.VerificationMeta _hasProfileImageMeta =
const i0.VerificationMeta('hasProfileImage');
@override
late final i0.GeneratedColumn<bool> hasProfileImage =
i0.GeneratedColumn<bool>('has_profile_image', aliasedName, false,
type: i0.DriftSqlType.bool,
requiredDuringInsert: false,
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
'CHECK ("has_profile_image" IN (0, 1))'),
defaultValue: const i4.Constant(false));
static const i0.VerificationMeta _profileChangedAtMeta =
const i0.VerificationMeta('profileChangedAt');
@override
late final i0.GeneratedColumn<DateTime> profileChangedAt =
i0.GeneratedColumn<DateTime>('profile_changed_at', aliasedName, false,
type: i0.DriftSqlType.dateTime,
requiredDuringInsert: false,
defaultValue: i4.currentDateAndTime);
static const i0.VerificationMeta _quotaSizeInBytesMeta =
const i0.VerificationMeta('quotaSizeInBytes');
@override
late final i0.GeneratedColumn<int> quotaSizeInBytes = i0.GeneratedColumn<int>(
'quota_size_in_bytes', aliasedName, true,
type: i0.DriftSqlType.int, requiredDuringInsert: false);
static const i0.VerificationMeta _quotaUsageInBytesMeta =
const i0.VerificationMeta('quotaUsageInBytes');
@override
late final i0.GeneratedColumn<int> quotaUsageInBytes =
i0.GeneratedColumn<int>('quota_usage_in_bytes', aliasedName, false,
type: i0.DriftSqlType.int,
requiredDuringInsert: false,
defaultValue: const i4.Constant(0));
static const i0.VerificationMeta _storageLabelMeta =
const i0.VerificationMeta('storageLabel');
@override
late final i0.GeneratedColumn<String> storageLabel =
i0.GeneratedColumn<String>('storage_label', aliasedName, true,
type: i0.DriftSqlType.string, requiredDuringInsert: false);
@override
List<i0.GeneratedColumn> get $columns => [
id,
name,
email,
deletedAt,
avatarColor,
isAdmin,
oauthId,
pinCode,
hasProfileImage,
profileChangedAt,
quotaSizeInBytes,
quotaUsageInBytes,
storageLabel
];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'auth_user_entity';
@override
i0.VerificationContext validateIntegrity(
i0.Insertable<i1.AuthUserEntityData> instance,
{bool isInserting = false}) {
final context = i0.VerificationContext();
final data = instance.toColumns(true);
if (data.containsKey('id')) {
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
} else if (isInserting) {
context.missing(_idMeta);
}
if (data.containsKey('name')) {
context.handle(
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
} else if (isInserting) {
context.missing(_nameMeta);
}
if (data.containsKey('email')) {
context.handle(
_emailMeta, email.isAcceptableOrUnknown(data['email']!, _emailMeta));
} else if (isInserting) {
context.missing(_emailMeta);
}
if (data.containsKey('deleted_at')) {
context.handle(_deletedAtMeta,
deletedAt.isAcceptableOrUnknown(data['deleted_at']!, _deletedAtMeta));
}
if (data.containsKey('is_admin')) {
context.handle(_isAdminMeta,
isAdmin.isAcceptableOrUnknown(data['is_admin']!, _isAdminMeta));
}
if (data.containsKey('oauth_id')) {
context.handle(_oauthIdMeta,
oauthId.isAcceptableOrUnknown(data['oauth_id']!, _oauthIdMeta));
}
if (data.containsKey('pin_code')) {
context.handle(_pinCodeMeta,
pinCode.isAcceptableOrUnknown(data['pin_code']!, _pinCodeMeta));
}
if (data.containsKey('has_profile_image')) {
context.handle(
_hasProfileImageMeta,
hasProfileImage.isAcceptableOrUnknown(
data['has_profile_image']!, _hasProfileImageMeta));
}
if (data.containsKey('profile_changed_at')) {
context.handle(
_profileChangedAtMeta,
profileChangedAt.isAcceptableOrUnknown(
data['profile_changed_at']!, _profileChangedAtMeta));
}
if (data.containsKey('quota_size_in_bytes')) {
context.handle(
_quotaSizeInBytesMeta,
quotaSizeInBytes.isAcceptableOrUnknown(
data['quota_size_in_bytes']!, _quotaSizeInBytesMeta));
}
if (data.containsKey('quota_usage_in_bytes')) {
context.handle(
_quotaUsageInBytesMeta,
quotaUsageInBytes.isAcceptableOrUnknown(
data['quota_usage_in_bytes']!, _quotaUsageInBytesMeta));
}
if (data.containsKey('storage_label')) {
context.handle(
_storageLabelMeta,
storageLabel.isAcceptableOrUnknown(
data['storage_label']!, _storageLabelMeta));
}
return context;
}
@override
Set<i0.GeneratedColumn> get $primaryKey => {id};
@override
i1.AuthUserEntityData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return i1.AuthUserEntityData(
id: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}id'])!,
name: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}name'])!,
email: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}email'])!,
deletedAt: attachedDatabase.typeMapping
.read(i0.DriftSqlType.dateTime, data['${effectivePrefix}deleted_at']),
avatarColor: i1.$AuthUserEntityTable.$converteravatarColorn.fromSql(
attachedDatabase.typeMapping.read(
i0.DriftSqlType.int, data['${effectivePrefix}avatar_color'])),
isAdmin: attachedDatabase.typeMapping
.read(i0.DriftSqlType.bool, data['${effectivePrefix}is_admin'])!,
oauthId: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}oauth_id'])!,
pinCode: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}pin_code']),
hasProfileImage: attachedDatabase.typeMapping.read(
i0.DriftSqlType.bool, data['${effectivePrefix}has_profile_image'])!,
profileChangedAt: attachedDatabase.typeMapping.read(
i0.DriftSqlType.dateTime,
data['${effectivePrefix}profile_changed_at'])!,
quotaSizeInBytes: attachedDatabase.typeMapping.read(
i0.DriftSqlType.int, data['${effectivePrefix}quota_size_in_bytes']),
quotaUsageInBytes: attachedDatabase.typeMapping.read(
i0.DriftSqlType.int, data['${effectivePrefix}quota_usage_in_bytes'])!,
storageLabel: attachedDatabase.typeMapping.read(
i0.DriftSqlType.string, data['${effectivePrefix}storage_label']),
);
}
@override
$AuthUserEntityTable createAlias(String alias) {
return $AuthUserEntityTable(attachedDatabase, alias);
}
static i0.JsonTypeConverter2<i2.AvatarColor, int, int> $converteravatarColor =
const i0.EnumIndexConverter<i2.AvatarColor>(i2.AvatarColor.values);
static i0.JsonTypeConverter2<i2.AvatarColor?, int?, int?>
$converteravatarColorn =
i0.JsonTypeConverter2.asNullable($converteravatarColor);
@override
bool get withoutRowId => true;
@override
bool get isStrict => true;
}
class AuthUserEntityData extends i0.DataClass
implements i0.Insertable<i1.AuthUserEntityData> {
final String id;
final String name;
final String email;
final DateTime? deletedAt;
final i2.AvatarColor? avatarColor;
final bool isAdmin;
final String oauthId;
final String? pinCode;
final bool hasProfileImage;
final DateTime profileChangedAt;
final int? quotaSizeInBytes;
final int quotaUsageInBytes;
final String? storageLabel;
const AuthUserEntityData(
{required this.id,
required this.name,
required this.email,
this.deletedAt,
this.avatarColor,
required this.isAdmin,
required this.oauthId,
this.pinCode,
required this.hasProfileImage,
required this.profileChangedAt,
this.quotaSizeInBytes,
required this.quotaUsageInBytes,
this.storageLabel});
@override
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
final map = <String, i0.Expression>{};
map['id'] = i0.Variable<String>(id);
map['name'] = i0.Variable<String>(name);
map['email'] = i0.Variable<String>(email);
if (!nullToAbsent || deletedAt != null) {
map['deleted_at'] = i0.Variable<DateTime>(deletedAt);
}
if (!nullToAbsent || avatarColor != null) {
map['avatar_color'] = i0.Variable<int>(
i1.$AuthUserEntityTable.$converteravatarColorn.toSql(avatarColor));
}
map['is_admin'] = i0.Variable<bool>(isAdmin);
map['oauth_id'] = i0.Variable<String>(oauthId);
if (!nullToAbsent || pinCode != null) {
map['pin_code'] = i0.Variable<String>(pinCode);
}
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
if (!nullToAbsent || quotaSizeInBytes != null) {
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes);
}
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes);
if (!nullToAbsent || storageLabel != null) {
map['storage_label'] = i0.Variable<String>(storageLabel);
}
return map;
}
factory AuthUserEntityData.fromJson(Map<String, dynamic> json,
{i0.ValueSerializer? serializer}) {
serializer ??= i0.driftRuntimeOptions.defaultSerializer;
return AuthUserEntityData(
id: serializer.fromJson<String>(json['id']),
name: serializer.fromJson<String>(json['name']),
email: serializer.fromJson<String>(json['email']),
deletedAt: serializer.fromJson<DateTime?>(json['deletedAt']),
avatarColor: i1.$AuthUserEntityTable.$converteravatarColorn
.fromJson(serializer.fromJson<int?>(json['avatarColor'])),
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
oauthId: serializer.fromJson<String>(json['oauthId']),
pinCode: serializer.fromJson<String?>(json['pinCode']),
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
quotaSizeInBytes: serializer.fromJson<int?>(json['quotaSizeInBytes']),
quotaUsageInBytes: serializer.fromJson<int>(json['quotaUsageInBytes']),
storageLabel: serializer.fromJson<String?>(json['storageLabel']),
);
}
@override
Map<String, dynamic> toJson({i0.ValueSerializer? serializer}) {
serializer ??= i0.driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
'id': serializer.toJson<String>(id),
'name': serializer.toJson<String>(name),
'email': serializer.toJson<String>(email),
'deletedAt': serializer.toJson<DateTime?>(deletedAt),
'avatarColor': serializer.toJson<int?>(
i1.$AuthUserEntityTable.$converteravatarColorn.toJson(avatarColor)),
'isAdmin': serializer.toJson<bool>(isAdmin),
'oauthId': serializer.toJson<String>(oauthId),
'pinCode': serializer.toJson<String?>(pinCode),
'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
'quotaSizeInBytes': serializer.toJson<int?>(quotaSizeInBytes),
'quotaUsageInBytes': serializer.toJson<int>(quotaUsageInBytes),
'storageLabel': serializer.toJson<String?>(storageLabel),
};
}
i1.AuthUserEntityData copyWith(
{String? id,
String? name,
String? email,
i0.Value<DateTime?> deletedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor?> avatarColor = const i0.Value.absent(),
bool? isAdmin,
String? oauthId,
i0.Value<String?> pinCode = const i0.Value.absent(),
bool? hasProfileImage,
DateTime? profileChangedAt,
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
int? quotaUsageInBytes,
i0.Value<String?> storageLabel = const i0.Value.absent()}) =>
i1.AuthUserEntityData(
id: id ?? this.id,
name: name ?? this.name,
email: email ?? this.email,
deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt,
avatarColor: avatarColor.present ? avatarColor.value : this.avatarColor,
isAdmin: isAdmin ?? this.isAdmin,
oauthId: oauthId ?? this.oauthId,
pinCode: pinCode.present ? pinCode.value : this.pinCode,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
quotaSizeInBytes: quotaSizeInBytes.present
? quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
storageLabel:
storageLabel.present ? storageLabel.value : this.storageLabel,
);
AuthUserEntityData copyWithCompanion(i1.AuthUserEntityCompanion data) {
return AuthUserEntityData(
id: data.id.present ? data.id.value : this.id,
name: data.name.present ? data.name.value : this.name,
email: data.email.present ? data.email.value : this.email,
deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt,
avatarColor:
data.avatarColor.present ? data.avatarColor.value : this.avatarColor,
isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin,
oauthId: data.oauthId.present ? data.oauthId.value : this.oauthId,
pinCode: data.pinCode.present ? data.pinCode.value : this.pinCode,
hasProfileImage: data.hasProfileImage.present
? data.hasProfileImage.value
: this.hasProfileImage,
profileChangedAt: data.profileChangedAt.present
? data.profileChangedAt.value
: this.profileChangedAt,
quotaSizeInBytes: data.quotaSizeInBytes.present
? data.quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: data.quotaUsageInBytes.present
? data.quotaUsageInBytes.value
: this.quotaUsageInBytes,
storageLabel: data.storageLabel.present
? data.storageLabel.value
: this.storageLabel,
);
}
@override
String toString() {
return (StringBuffer('AuthUserEntityData(')
..write('id: $id, ')
..write('name: $name, ')
..write('email: $email, ')
..write('deletedAt: $deletedAt, ')
..write('avatarColor: $avatarColor, ')
..write('isAdmin: $isAdmin, ')
..write('oauthId: $oauthId, ')
..write('pinCode: $pinCode, ')
..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes, ')
..write('storageLabel: $storageLabel')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(
id,
name,
email,
deletedAt,
avatarColor,
isAdmin,
oauthId,
pinCode,
hasProfileImage,
profileChangedAt,
quotaSizeInBytes,
quotaUsageInBytes,
storageLabel);
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is i1.AuthUserEntityData &&
other.id == this.id &&
other.name == this.name &&
other.email == this.email &&
other.deletedAt == this.deletedAt &&
other.avatarColor == this.avatarColor &&
other.isAdmin == this.isAdmin &&
other.oauthId == this.oauthId &&
other.pinCode == this.pinCode &&
other.hasProfileImage == this.hasProfileImage &&
other.profileChangedAt == this.profileChangedAt &&
other.quotaSizeInBytes == this.quotaSizeInBytes &&
other.quotaUsageInBytes == this.quotaUsageInBytes &&
other.storageLabel == this.storageLabel);
}
class AuthUserEntityCompanion
extends i0.UpdateCompanion<i1.AuthUserEntityData> {
final i0.Value<String> id;
final i0.Value<String> name;
final i0.Value<String> email;
final i0.Value<DateTime?> deletedAt;
final i0.Value<i2.AvatarColor?> avatarColor;
final i0.Value<bool> isAdmin;
final i0.Value<String> oauthId;
final i0.Value<String?> pinCode;
final i0.Value<bool> hasProfileImage;
final i0.Value<DateTime> profileChangedAt;
final i0.Value<int?> quotaSizeInBytes;
final i0.Value<int> quotaUsageInBytes;
final i0.Value<String?> storageLabel;
const AuthUserEntityCompanion({
this.id = const i0.Value.absent(),
this.name = const i0.Value.absent(),
this.email = const i0.Value.absent(),
this.deletedAt = const i0.Value.absent(),
this.avatarColor = const i0.Value.absent(),
this.isAdmin = const i0.Value.absent(),
this.oauthId = const i0.Value.absent(),
this.pinCode = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
this.storageLabel = const i0.Value.absent(),
});
AuthUserEntityCompanion.insert({
required String id,
required String name,
required String email,
this.deletedAt = const i0.Value.absent(),
this.avatarColor = const i0.Value.absent(),
this.isAdmin = const i0.Value.absent(),
this.oauthId = const i0.Value.absent(),
this.pinCode = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
this.storageLabel = const i0.Value.absent(),
}) : id = i0.Value(id),
name = i0.Value(name),
email = i0.Value(email);
static i0.Insertable<i1.AuthUserEntityData> custom({
i0.Expression<String>? id,
i0.Expression<String>? name,
i0.Expression<String>? email,
i0.Expression<DateTime>? deletedAt,
i0.Expression<int>? avatarColor,
i0.Expression<bool>? isAdmin,
i0.Expression<String>? oauthId,
i0.Expression<String>? pinCode,
i0.Expression<bool>? hasProfileImage,
i0.Expression<DateTime>? profileChangedAt,
i0.Expression<int>? quotaSizeInBytes,
i0.Expression<int>? quotaUsageInBytes,
i0.Expression<String>? storageLabel,
}) {
return i0.RawValuesInsertable({
if (id != null) 'id': id,
if (name != null) 'name': name,
if (email != null) 'email': email,
if (deletedAt != null) 'deleted_at': deletedAt,
if (avatarColor != null) 'avatar_color': avatarColor,
if (isAdmin != null) 'is_admin': isAdmin,
if (oauthId != null) 'oauth_id': oauthId,
if (pinCode != null) 'pin_code': pinCode,
if (hasProfileImage != null) 'has_profile_image': hasProfileImage,
if (profileChangedAt != null) 'profile_changed_at': profileChangedAt,
if (quotaSizeInBytes != null) 'quota_size_in_bytes': quotaSizeInBytes,
if (quotaUsageInBytes != null) 'quota_usage_in_bytes': quotaUsageInBytes,
if (storageLabel != null) 'storage_label': storageLabel,
});
}
i1.AuthUserEntityCompanion copyWith(
{i0.Value<String>? id,
i0.Value<String>? name,
i0.Value<String>? email,
i0.Value<DateTime?>? deletedAt,
i0.Value<i2.AvatarColor?>? avatarColor,
i0.Value<bool>? isAdmin,
i0.Value<String>? oauthId,
i0.Value<String?>? pinCode,
i0.Value<bool>? hasProfileImage,
i0.Value<DateTime>? profileChangedAt,
i0.Value<int?>? quotaSizeInBytes,
i0.Value<int>? quotaUsageInBytes,
i0.Value<String?>? storageLabel}) {
return i1.AuthUserEntityCompanion(
id: id ?? this.id,
name: name ?? this.name,
email: email ?? this.email,
deletedAt: deletedAt ?? this.deletedAt,
avatarColor: avatarColor ?? this.avatarColor,
isAdmin: isAdmin ?? this.isAdmin,
oauthId: oauthId ?? this.oauthId,
pinCode: pinCode ?? this.pinCode,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
storageLabel: storageLabel ?? this.storageLabel,
);
}
@override
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
final map = <String, i0.Expression>{};
if (id.present) {
map['id'] = i0.Variable<String>(id.value);
}
if (name.present) {
map['name'] = i0.Variable<String>(name.value);
}
if (email.present) {
map['email'] = i0.Variable<String>(email.value);
}
if (deletedAt.present) {
map['deleted_at'] = i0.Variable<DateTime>(deletedAt.value);
}
if (avatarColor.present) {
map['avatar_color'] = i0.Variable<int>(i1
.$AuthUserEntityTable.$converteravatarColorn
.toSql(avatarColor.value));
}
if (isAdmin.present) {
map['is_admin'] = i0.Variable<bool>(isAdmin.value);
}
if (oauthId.present) {
map['oauth_id'] = i0.Variable<String>(oauthId.value);
}
if (pinCode.present) {
map['pin_code'] = i0.Variable<String>(pinCode.value);
}
if (hasProfileImage.present) {
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage.value);
}
if (profileChangedAt.present) {
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt.value);
}
if (quotaSizeInBytes.present) {
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes.value);
}
if (quotaUsageInBytes.present) {
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes.value);
}
if (storageLabel.present) {
map['storage_label'] = i0.Variable<String>(storageLabel.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('AuthUserEntityCompanion(')
..write('id: $id, ')
..write('name: $name, ')
..write('email: $email, ')
..write('deletedAt: $deletedAt, ')
..write('avatarColor: $avatarColor, ')
..write('isAdmin: $isAdmin, ')
..write('oauthId: $oauthId, ')
..write('pinCode: $pinCode, ')
..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes, ')
..write('storageLabel: $storageLabel')
..write(')'))
.toString();
}
}

View File

@@ -98,8 +98,7 @@ class ExifInfo {
class RemoteExifEntity extends Table with DriftDefaultsMixin {
const RemoteExifEntity();
TextColumn get assetId =>
text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get assetId => text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get city => text().nullable()();

View File

@@ -9,8 +9,7 @@ class LocalAlbumEntity extends Table with DriftDefaultsMixin {
TextColumn get name => text()();
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get backupSelection => intEnum<BackupSelection>()();
BoolColumn get isIosSharedAlbum =>
boolean().withDefault(const Constant(false))();
BoolColumn get isIosSharedAlbum => boolean().withDefault(const Constant(false))();
// Used for mark & sweep
BoolColumn get marker_ => boolean().nullable()();

View File

@@ -6,11 +6,9 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class LocalAlbumAssetEntity extends Table with DriftDefaultsMixin {
const LocalAlbumAssetEntity();
TextColumn get assetId =>
text().references(LocalAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get assetId => text().references(LocalAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get albumId =>
text().references(LocalAlbumEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get albumId => text().references(LocalAlbumEntity, #id, onDelete: KeyAction.cascade)();
@override
Set<Column> get primaryKey => {assetId, albumId};

View File

@@ -14,8 +14,7 @@ class MemoryEntity extends Table with DriftDefaultsMixin {
DateTimeColumn get deletedAt => dateTime().nullable()();
TextColumn get ownerId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get ownerId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
IntColumn get type => intEnum<MemoryTypeEnum>()();

View File

@@ -6,11 +6,9 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class MemoryAssetEntity extends Table with DriftDefaultsMixin {
const MemoryAssetEntity();
TextColumn get assetId =>
text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get assetId => text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get memoryId =>
text().references(MemoryEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get memoryId => text().references(MemoryEntity, #id, onDelete: KeyAction.cascade)();
@override
Set<Column> get primaryKey => {assetId, memoryId};

View File

@@ -5,11 +5,9 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class PartnerEntity extends Table with DriftDefaultsMixin {
const PartnerEntity();
TextColumn get sharedById =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get sharedById => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get sharedWithId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get sharedWithId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
BoolColumn get inTimeline => boolean().withDefault(const Constant(false))();

View File

@@ -11,8 +11,7 @@ class PersonEntity extends Table with DriftDefaultsMixin {
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
TextColumn get ownerId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get ownerId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get name => text()();

View File

@@ -17,15 +17,12 @@ class RemoteAlbumEntity extends Table with DriftDefaultsMixin {
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
TextColumn get ownerId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get ownerId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get thumbnailAssetId => text()
.references(RemoteAssetEntity, #id, onDelete: KeyAction.setNull)
.nullable()();
TextColumn get thumbnailAssetId =>
text().references(RemoteAssetEntity, #id, onDelete: KeyAction.setNull).nullable()();
BoolColumn get isActivityEnabled =>
boolean().withDefault(const Constant(true))();
BoolColumn get isActivityEnabled => boolean().withDefault(const Constant(true))();
IntColumn get order => intEnum<AlbumAssetOrder>()();

View File

@@ -6,11 +6,9 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class RemoteAlbumAssetEntity extends Table with DriftDefaultsMixin {
const RemoteAlbumAssetEntity();
TextColumn get assetId =>
text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get assetId => text().references(RemoteAssetEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get albumId =>
text().references(RemoteAlbumEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get albumId => text().references(RemoteAlbumEntity, #id, onDelete: KeyAction.cascade)();
@override
Set<Column> get primaryKey => {assetId, albumId};

View File

@@ -7,11 +7,9 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class RemoteAlbumUserEntity extends Table with DriftDefaultsMixin {
const RemoteAlbumUserEntity();
TextColumn get albumId =>
text().references(RemoteAlbumEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get albumId => text().references(RemoteAlbumEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get userId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get userId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
IntColumn get role => intEnum<AlbumUserRole>()();

View File

@@ -11,8 +11,7 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
unique: true,
)
@TableIndex(name: 'idx_remote_asset_checksum', columns: {#checksum})
class RemoteAssetEntity extends Table
with DriftDefaultsMixin, AssetEntityMixin {
class RemoteAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
const RemoteAssetEntity();
TextColumn get id => text()();
@@ -21,8 +20,7 @@ class RemoteAssetEntity extends Table
BoolColumn get isFavorite => boolean().withDefault(const Constant(false))();
TextColumn get ownerId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get ownerId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
DateTimeColumn get localDateTime => dateTime().nullable()();

View File

@@ -11,8 +11,7 @@ class StackEntity extends Table with DriftDefaultsMixin {
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
TextColumn get ownerId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get ownerId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get primaryAssetId => text()();

View File

@@ -1,14 +1,16 @@
import 'package:drift/drift.dart' hide Index;
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart';
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart';
part 'user.entity.g.dart';
// TODO: Remove User once Isar is removed
@Collection(inheritance: false)
class User {
class IsarUser {
Id get isarId => fastHash(id);
@Index(unique: true, replace: false, type: IndexType.hash)
final String id;
@@ -26,7 +28,7 @@ class User {
final int quotaUsageInBytes;
final int quotaSizeInBytes;
const User({
const IsarUser({
required this.id,
required this.updatedAt,
required this.email,
@@ -42,7 +44,7 @@ class User {
this.quotaSizeInBytes = 0,
});
static User fromDto(UserDto dto) => User(
static IsarUser fromDto(UserDto dto) => IsarUser(
id: dto.id,
updatedAt: dto.updatedAt,
email: dto.email,
@@ -79,15 +81,25 @@ class UserEntity extends Table with DriftDefaultsMixin {
const UserEntity();
TextColumn get id => text()();
TextColumn get name => text()();
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
TextColumn get email => text()();
TextColumn get profileImagePath => text().nullable()();
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
// Quota
IntColumn get quotaSizeInBytes => integer().nullable()();
IntColumn get quotaUsageInBytes => integer().withDefault(const Constant(0))();
DateTimeColumn get deletedAt => dateTime().nullable()();
IntColumn get avatarColor => intEnum<AvatarColor>().nullable()();
@override
Set<Column> get primaryKey => {id};
}
extension UserEntityDataDomainEx on UserEntityData {
User toDto() => User(
id: id,
name: name,
email: email,
deletedAt: deletedAt,
avatarColor: avatarColor,
);
}

View File

@@ -3,30 +3,24 @@
import 'package:drift/drift.dart' as i0;
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'
as i1;
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as i2;
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i3;
import 'package:immich_mobile/domain/models/user_metadata.model.dart' as i2;
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as i3;
typedef $$UserEntityTableCreateCompanionBuilder = i1.UserEntityCompanion
Function({
required String id,
required String name,
i0.Value<bool> isAdmin,
required String email,
i0.Value<String?> profileImagePath,
i0.Value<DateTime> updatedAt,
i0.Value<int?> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
i0.Value<DateTime?> deletedAt,
i0.Value<i2.AvatarColor?> avatarColor,
});
typedef $$UserEntityTableUpdateCompanionBuilder = i1.UserEntityCompanion
Function({
i0.Value<String> id,
i0.Value<String> name,
i0.Value<bool> isAdmin,
i0.Value<String> email,
i0.Value<String?> profileImagePath,
i0.Value<DateTime> updatedAt,
i0.Value<int?> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
i0.Value<DateTime?> deletedAt,
i0.Value<i2.AvatarColor?> avatarColor,
});
class $$UserEntityTableFilterComposer
@@ -44,26 +38,16 @@ class $$UserEntityTableFilterComposer
i0.ColumnFilters<String> get name => $composableBuilder(
column: $table.name, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<bool> get isAdmin => $composableBuilder(
column: $table.isAdmin, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get email => $composableBuilder(
column: $table.email, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<String> get profileImagePath => $composableBuilder(
column: $table.profileImagePath,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<DateTime> get deletedAt => $composableBuilder(
column: $table.deletedAt, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<DateTime> get updatedAt => $composableBuilder(
column: $table.updatedAt, builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnFilters<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
builder: (column) => i0.ColumnFilters(column));
i0.ColumnWithTypeConverterFilters<i2.AvatarColor?, i2.AvatarColor, int>
get avatarColor => $composableBuilder(
column: $table.avatarColor,
builder: (column) => i0.ColumnWithTypeConverterFilters(column));
}
class $$UserEntityTableOrderingComposer
@@ -81,26 +65,15 @@ class $$UserEntityTableOrderingComposer
i0.ColumnOrderings<String> get name => $composableBuilder(
column: $table.name, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<bool> get isAdmin => $composableBuilder(
column: $table.isAdmin, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get email => $composableBuilder(
column: $table.email, builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<String> get profileImagePath => $composableBuilder(
column: $table.profileImagePath,
i0.ColumnOrderings<DateTime> get deletedAt => $composableBuilder(
column: $table.deletedAt,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<DateTime> get updatedAt => $composableBuilder(
column: $table.updatedAt,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => i0.ColumnOrderings(column));
i0.ColumnOrderings<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
i0.ColumnOrderings<int> get avatarColor => $composableBuilder(
column: $table.avatarColor,
builder: (column) => i0.ColumnOrderings(column));
}
@@ -119,23 +92,15 @@ class $$UserEntityTableAnnotationComposer
i0.GeneratedColumn<String> get name =>
$composableBuilder(column: $table.name, builder: (column) => column);
i0.GeneratedColumn<bool> get isAdmin =>
$composableBuilder(column: $table.isAdmin, builder: (column) => column);
i0.GeneratedColumn<String> get email =>
$composableBuilder(column: $table.email, builder: (column) => column);
i0.GeneratedColumn<String> get profileImagePath => $composableBuilder(
column: $table.profileImagePath, builder: (column) => column);
i0.GeneratedColumn<DateTime> get deletedAt =>
$composableBuilder(column: $table.deletedAt, builder: (column) => column);
i0.GeneratedColumn<DateTime> get updatedAt =>
$composableBuilder(column: $table.updatedAt, builder: (column) => column);
i0.GeneratedColumn<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes, builder: (column) => column);
i0.GeneratedColumn<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes, builder: (column) => column);
i0.GeneratedColumnWithTypeConverter<i2.AvatarColor?, int> get avatarColor =>
$composableBuilder(
column: $table.avatarColor, builder: (column) => column);
}
class $$UserEntityTableTableManager extends i0.RootTableManager<
@@ -168,42 +133,30 @@ class $$UserEntityTableTableManager extends i0.RootTableManager<
updateCompanionCallback: ({
i0.Value<String> id = const i0.Value.absent(),
i0.Value<String> name = const i0.Value.absent(),
i0.Value<bool> isAdmin = const i0.Value.absent(),
i0.Value<String> email = const i0.Value.absent(),
i0.Value<String?> profileImagePath = const i0.Value.absent(),
i0.Value<DateTime> updatedAt = const i0.Value.absent(),
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
i0.Value<DateTime?> deletedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor?> avatarColor = const i0.Value.absent(),
}) =>
i1.UserEntityCompanion(
id: id,
name: name,
isAdmin: isAdmin,
email: email,
profileImagePath: profileImagePath,
updatedAt: updatedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
deletedAt: deletedAt,
avatarColor: avatarColor,
),
createCompanionCallback: ({
required String id,
required String name,
i0.Value<bool> isAdmin = const i0.Value.absent(),
required String email,
i0.Value<String?> profileImagePath = const i0.Value.absent(),
i0.Value<DateTime> updatedAt = const i0.Value.absent(),
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
i0.Value<DateTime?> deletedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor?> avatarColor = const i0.Value.absent(),
}) =>
i1.UserEntityCompanion.insert(
id: id,
name: name,
isAdmin: isAdmin,
email: email,
profileImagePath: profileImagePath,
updatedAt: updatedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
deletedAt: deletedAt,
avatarColor: avatarColor,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
@@ -229,7 +182,7 @@ typedef $$UserEntityTableProcessedTableManager = i0.ProcessedTableManager<
i1.UserEntityData,
i0.PrefetchHooks Function()>;
class $UserEntityTable extends i2.UserEntity
class $UserEntityTable extends i3.UserEntity
with i0.TableInfo<$UserEntityTable, i1.UserEntityData> {
@override
final i0.GeneratedDatabase attachedDatabase;
@@ -246,61 +199,27 @@ class $UserEntityTable extends i2.UserEntity
late final i0.GeneratedColumn<String> name = i0.GeneratedColumn<String>(
'name', aliasedName, false,
type: i0.DriftSqlType.string, requiredDuringInsert: true);
static const i0.VerificationMeta _isAdminMeta =
const i0.VerificationMeta('isAdmin');
@override
late final i0.GeneratedColumn<bool> isAdmin = i0.GeneratedColumn<bool>(
'is_admin', aliasedName, false,
type: i0.DriftSqlType.bool,
requiredDuringInsert: false,
defaultConstraints:
i0.GeneratedColumn.constraintIsAlways('CHECK ("is_admin" IN (0, 1))'),
defaultValue: const i3.Constant(false));
static const i0.VerificationMeta _emailMeta =
const i0.VerificationMeta('email');
@override
late final i0.GeneratedColumn<String> email = i0.GeneratedColumn<String>(
'email', aliasedName, false,
type: i0.DriftSqlType.string, requiredDuringInsert: true);
static const i0.VerificationMeta _profileImagePathMeta =
const i0.VerificationMeta('profileImagePath');
static const i0.VerificationMeta _deletedAtMeta =
const i0.VerificationMeta('deletedAt');
@override
late final i0.GeneratedColumn<String> profileImagePath =
i0.GeneratedColumn<String>('profile_image_path', aliasedName, true,
type: i0.DriftSqlType.string, requiredDuringInsert: false);
static const i0.VerificationMeta _updatedAtMeta =
const i0.VerificationMeta('updatedAt');
late final i0.GeneratedColumn<DateTime> deletedAt =
i0.GeneratedColumn<DateTime>('deleted_at', aliasedName, true,
type: i0.DriftSqlType.dateTime, requiredDuringInsert: false);
@override
late final i0.GeneratedColumn<DateTime> updatedAt =
i0.GeneratedColumn<DateTime>('updated_at', aliasedName, false,
type: i0.DriftSqlType.dateTime,
requiredDuringInsert: false,
defaultValue: i3.currentDateAndTime);
static const i0.VerificationMeta _quotaSizeInBytesMeta =
const i0.VerificationMeta('quotaSizeInBytes');
late final i0.GeneratedColumnWithTypeConverter<i2.AvatarColor?, int>
avatarColor = i0.GeneratedColumn<int>('avatar_color', aliasedName, true,
type: i0.DriftSqlType.int, requiredDuringInsert: false)
.withConverter<i2.AvatarColor?>(
i1.$UserEntityTable.$converteravatarColorn);
@override
late final i0.GeneratedColumn<int> quotaSizeInBytes = i0.GeneratedColumn<int>(
'quota_size_in_bytes', aliasedName, true,
type: i0.DriftSqlType.int, requiredDuringInsert: false);
static const i0.VerificationMeta _quotaUsageInBytesMeta =
const i0.VerificationMeta('quotaUsageInBytes');
@override
late final i0.GeneratedColumn<int> quotaUsageInBytes =
i0.GeneratedColumn<int>('quota_usage_in_bytes', aliasedName, false,
type: i0.DriftSqlType.int,
requiredDuringInsert: false,
defaultValue: const i3.Constant(0));
@override
List<i0.GeneratedColumn> get $columns => [
id,
name,
isAdmin,
email,
profileImagePath,
updatedAt,
quotaSizeInBytes,
quotaUsageInBytes
];
List<i0.GeneratedColumn> get $columns =>
[id, name, email, deletedAt, avatarColor];
@override
String get aliasedName => _alias ?? actualTableName;
@override
@@ -323,37 +242,15 @@ class $UserEntityTable extends i2.UserEntity
} else if (isInserting) {
context.missing(_nameMeta);
}
if (data.containsKey('is_admin')) {
context.handle(_isAdminMeta,
isAdmin.isAcceptableOrUnknown(data['is_admin']!, _isAdminMeta));
}
if (data.containsKey('email')) {
context.handle(
_emailMeta, email.isAcceptableOrUnknown(data['email']!, _emailMeta));
} else if (isInserting) {
context.missing(_emailMeta);
}
if (data.containsKey('profile_image_path')) {
context.handle(
_profileImagePathMeta,
profileImagePath.isAcceptableOrUnknown(
data['profile_image_path']!, _profileImagePathMeta));
}
if (data.containsKey('updated_at')) {
context.handle(_updatedAtMeta,
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
}
if (data.containsKey('quota_size_in_bytes')) {
context.handle(
_quotaSizeInBytesMeta,
quotaSizeInBytes.isAcceptableOrUnknown(
data['quota_size_in_bytes']!, _quotaSizeInBytesMeta));
}
if (data.containsKey('quota_usage_in_bytes')) {
context.handle(
_quotaUsageInBytesMeta,
quotaUsageInBytes.isAcceptableOrUnknown(
data['quota_usage_in_bytes']!, _quotaUsageInBytesMeta));
if (data.containsKey('deleted_at')) {
context.handle(_deletedAtMeta,
deletedAt.isAcceptableOrUnknown(data['deleted_at']!, _deletedAtMeta));
}
return context;
}
@@ -368,18 +265,13 @@ class $UserEntityTable extends i2.UserEntity
.read(i0.DriftSqlType.string, data['${effectivePrefix}id'])!,
name: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}name'])!,
isAdmin: attachedDatabase.typeMapping
.read(i0.DriftSqlType.bool, data['${effectivePrefix}is_admin'])!,
email: attachedDatabase.typeMapping
.read(i0.DriftSqlType.string, data['${effectivePrefix}email'])!,
profileImagePath: attachedDatabase.typeMapping.read(
i0.DriftSqlType.string, data['${effectivePrefix}profile_image_path']),
updatedAt: attachedDatabase.typeMapping.read(
i0.DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
quotaSizeInBytes: attachedDatabase.typeMapping.read(
i0.DriftSqlType.int, data['${effectivePrefix}quota_size_in_bytes']),
quotaUsageInBytes: attachedDatabase.typeMapping.read(
i0.DriftSqlType.int, data['${effectivePrefix}quota_usage_in_bytes'])!,
deletedAt: attachedDatabase.typeMapping
.read(i0.DriftSqlType.dateTime, data['${effectivePrefix}deleted_at']),
avatarColor: i1.$UserEntityTable.$converteravatarColorn.fromSql(
attachedDatabase.typeMapping.read(
i0.DriftSqlType.int, data['${effectivePrefix}avatar_color'])),
);
}
@@ -388,6 +280,11 @@ class $UserEntityTable extends i2.UserEntity
return $UserEntityTable(attachedDatabase, alias);
}
static i0.JsonTypeConverter2<i2.AvatarColor, int, int> $converteravatarColor =
const i0.EnumIndexConverter<i2.AvatarColor>(i2.AvatarColor.values);
static i0.JsonTypeConverter2<i2.AvatarColor?, int?, int?>
$converteravatarColorn =
i0.JsonTypeConverter2.asNullable($converteravatarColor);
@override
bool get withoutRowId => true;
@override
@@ -398,36 +295,28 @@ class UserEntityData extends i0.DataClass
implements i0.Insertable<i1.UserEntityData> {
final String id;
final String name;
final bool isAdmin;
final String email;
final String? profileImagePath;
final DateTime updatedAt;
final int? quotaSizeInBytes;
final int quotaUsageInBytes;
final DateTime? deletedAt;
final i2.AvatarColor? avatarColor;
const UserEntityData(
{required this.id,
required this.name,
required this.isAdmin,
required this.email,
this.profileImagePath,
required this.updatedAt,
this.quotaSizeInBytes,
required this.quotaUsageInBytes});
this.deletedAt,
this.avatarColor});
@override
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
final map = <String, i0.Expression>{};
map['id'] = i0.Variable<String>(id);
map['name'] = i0.Variable<String>(name);
map['is_admin'] = i0.Variable<bool>(isAdmin);
map['email'] = i0.Variable<String>(email);
if (!nullToAbsent || profileImagePath != null) {
map['profile_image_path'] = i0.Variable<String>(profileImagePath);
if (!nullToAbsent || deletedAt != null) {
map['deleted_at'] = i0.Variable<DateTime>(deletedAt);
}
map['updated_at'] = i0.Variable<DateTime>(updatedAt);
if (!nullToAbsent || quotaSizeInBytes != null) {
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes);
if (!nullToAbsent || avatarColor != null) {
map['avatar_color'] = i0.Variable<int>(
i1.$UserEntityTable.$converteravatarColorn.toSql(avatarColor));
}
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes);
return map;
}
@@ -437,12 +326,10 @@ class UserEntityData extends i0.DataClass
return UserEntityData(
id: serializer.fromJson<String>(json['id']),
name: serializer.fromJson<String>(json['name']),
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
email: serializer.fromJson<String>(json['email']),
profileImagePath: serializer.fromJson<String?>(json['profileImagePath']),
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
quotaSizeInBytes: serializer.fromJson<int?>(json['quotaSizeInBytes']),
quotaUsageInBytes: serializer.fromJson<int>(json['quotaUsageInBytes']),
deletedAt: serializer.fromJson<DateTime?>(json['deletedAt']),
avatarColor: i1.$UserEntityTable.$converteravatarColorn
.fromJson(serializer.fromJson<int?>(json['avatarColor'])),
);
}
@override
@@ -451,54 +338,34 @@ class UserEntityData extends i0.DataClass
return <String, dynamic>{
'id': serializer.toJson<String>(id),
'name': serializer.toJson<String>(name),
'isAdmin': serializer.toJson<bool>(isAdmin),
'email': serializer.toJson<String>(email),
'profileImagePath': serializer.toJson<String?>(profileImagePath),
'updatedAt': serializer.toJson<DateTime>(updatedAt),
'quotaSizeInBytes': serializer.toJson<int?>(quotaSizeInBytes),
'quotaUsageInBytes': serializer.toJson<int>(quotaUsageInBytes),
'deletedAt': serializer.toJson<DateTime?>(deletedAt),
'avatarColor': serializer.toJson<int?>(
i1.$UserEntityTable.$converteravatarColorn.toJson(avatarColor)),
};
}
i1.UserEntityData copyWith(
{String? id,
String? name,
bool? isAdmin,
String? email,
i0.Value<String?> profileImagePath = const i0.Value.absent(),
DateTime? updatedAt,
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
int? quotaUsageInBytes}) =>
i0.Value<DateTime?> deletedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor?> avatarColor = const i0.Value.absent()}) =>
i1.UserEntityData(
id: id ?? this.id,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
email: email ?? this.email,
profileImagePath: profileImagePath.present
? profileImagePath.value
: this.profileImagePath,
updatedAt: updatedAt ?? this.updatedAt,
quotaSizeInBytes: quotaSizeInBytes.present
? quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
deletedAt: deletedAt.present ? deletedAt.value : this.deletedAt,
avatarColor: avatarColor.present ? avatarColor.value : this.avatarColor,
);
UserEntityData copyWithCompanion(i1.UserEntityCompanion data) {
return UserEntityData(
id: data.id.present ? data.id.value : this.id,
name: data.name.present ? data.name.value : this.name,
isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin,
email: data.email.present ? data.email.value : this.email,
profileImagePath: data.profileImagePath.present
? data.profileImagePath.value
: this.profileImagePath,
updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt,
quotaSizeInBytes: data.quotaSizeInBytes.present
? data.quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: data.quotaUsageInBytes.present
? data.quotaUsageInBytes.value
: this.quotaUsageInBytes,
deletedAt: data.deletedAt.present ? data.deletedAt.value : this.deletedAt,
avatarColor:
data.avatarColor.present ? data.avatarColor.value : this.avatarColor,
);
}
@@ -507,104 +374,76 @@ class UserEntityData extends i0.DataClass
return (StringBuffer('UserEntityData(')
..write('id: $id, ')
..write('name: $name, ')
..write('isAdmin: $isAdmin, ')
..write('email: $email, ')
..write('profileImagePath: $profileImagePath, ')
..write('updatedAt: $updatedAt, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes')
..write('deletedAt: $deletedAt, ')
..write('avatarColor: $avatarColor')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(id, name, isAdmin, email, profileImagePath,
updatedAt, quotaSizeInBytes, quotaUsageInBytes);
int get hashCode => Object.hash(id, name, email, deletedAt, avatarColor);
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is i1.UserEntityData &&
other.id == this.id &&
other.name == this.name &&
other.isAdmin == this.isAdmin &&
other.email == this.email &&
other.profileImagePath == this.profileImagePath &&
other.updatedAt == this.updatedAt &&
other.quotaSizeInBytes == this.quotaSizeInBytes &&
other.quotaUsageInBytes == this.quotaUsageInBytes);
other.deletedAt == this.deletedAt &&
other.avatarColor == this.avatarColor);
}
class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
final i0.Value<String> id;
final i0.Value<String> name;
final i0.Value<bool> isAdmin;
final i0.Value<String> email;
final i0.Value<String?> profileImagePath;
final i0.Value<DateTime> updatedAt;
final i0.Value<int?> quotaSizeInBytes;
final i0.Value<int> quotaUsageInBytes;
final i0.Value<DateTime?> deletedAt;
final i0.Value<i2.AvatarColor?> avatarColor;
const UserEntityCompanion({
this.id = const i0.Value.absent(),
this.name = const i0.Value.absent(),
this.isAdmin = const i0.Value.absent(),
this.email = const i0.Value.absent(),
this.profileImagePath = const i0.Value.absent(),
this.updatedAt = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
this.deletedAt = const i0.Value.absent(),
this.avatarColor = const i0.Value.absent(),
});
UserEntityCompanion.insert({
required String id,
required String name,
this.isAdmin = const i0.Value.absent(),
required String email,
this.profileImagePath = const i0.Value.absent(),
this.updatedAt = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
this.deletedAt = const i0.Value.absent(),
this.avatarColor = const i0.Value.absent(),
}) : id = i0.Value(id),
name = i0.Value(name),
email = i0.Value(email);
static i0.Insertable<i1.UserEntityData> custom({
i0.Expression<String>? id,
i0.Expression<String>? name,
i0.Expression<bool>? isAdmin,
i0.Expression<String>? email,
i0.Expression<String>? profileImagePath,
i0.Expression<DateTime>? updatedAt,
i0.Expression<int>? quotaSizeInBytes,
i0.Expression<int>? quotaUsageInBytes,
i0.Expression<DateTime>? deletedAt,
i0.Expression<int>? avatarColor,
}) {
return i0.RawValuesInsertable({
if (id != null) 'id': id,
if (name != null) 'name': name,
if (isAdmin != null) 'is_admin': isAdmin,
if (email != null) 'email': email,
if (profileImagePath != null) 'profile_image_path': profileImagePath,
if (updatedAt != null) 'updated_at': updatedAt,
if (quotaSizeInBytes != null) 'quota_size_in_bytes': quotaSizeInBytes,
if (quotaUsageInBytes != null) 'quota_usage_in_bytes': quotaUsageInBytes,
if (deletedAt != null) 'deleted_at': deletedAt,
if (avatarColor != null) 'avatar_color': avatarColor,
});
}
i1.UserEntityCompanion copyWith(
{i0.Value<String>? id,
i0.Value<String>? name,
i0.Value<bool>? isAdmin,
i0.Value<String>? email,
i0.Value<String?>? profileImagePath,
i0.Value<DateTime>? updatedAt,
i0.Value<int?>? quotaSizeInBytes,
i0.Value<int>? quotaUsageInBytes}) {
i0.Value<DateTime?>? deletedAt,
i0.Value<i2.AvatarColor?>? avatarColor}) {
return i1.UserEntityCompanion(
id: id ?? this.id,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
email: email ?? this.email,
profileImagePath: profileImagePath ?? this.profileImagePath,
updatedAt: updatedAt ?? this.updatedAt,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
deletedAt: deletedAt ?? this.deletedAt,
avatarColor: avatarColor ?? this.avatarColor,
);
}
@@ -617,23 +456,15 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
if (name.present) {
map['name'] = i0.Variable<String>(name.value);
}
if (isAdmin.present) {
map['is_admin'] = i0.Variable<bool>(isAdmin.value);
}
if (email.present) {
map['email'] = i0.Variable<String>(email.value);
}
if (profileImagePath.present) {
map['profile_image_path'] = i0.Variable<String>(profileImagePath.value);
if (deletedAt.present) {
map['deleted_at'] = i0.Variable<DateTime>(deletedAt.value);
}
if (updatedAt.present) {
map['updated_at'] = i0.Variable<DateTime>(updatedAt.value);
}
if (quotaSizeInBytes.present) {
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes.value);
}
if (quotaUsageInBytes.present) {
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes.value);
if (avatarColor.present) {
map['avatar_color'] = i0.Variable<int>(
i1.$UserEntityTable.$converteravatarColorn.toSql(avatarColor.value));
}
return map;
}
@@ -643,12 +474,9 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
return (StringBuffer('UserEntityCompanion(')
..write('id: $id, ')
..write('name: $name, ')
..write('isAdmin: $isAdmin, ')
..write('email: $email, ')
..write('profileImagePath: $profileImagePath, ')
..write('updatedAt: $updatedAt, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes')
..write('deletedAt: $deletedAt, ')
..write('avatarColor: $avatarColor')
..write(')'))
.toString();
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,8 +6,7 @@ import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
class UserMetadataEntity extends Table with DriftDefaultsMixin {
const UserMetadataEntity();
TextColumn get userId =>
text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
TextColumn get userId => text().references(UserEntity, #id, onDelete: KeyAction.cascade)();
IntColumn get key => intEnum<UserMetadataKey>()();
@@ -17,7 +16,6 @@ class UserMetadataEntity extends Table with DriftDefaultsMixin {
Set<Column> get primaryKey => {userId, key};
}
final JsonTypeConverter2<Map<String, Object?>, Uint8List, Object?>
userMetadataConverter = TypeConverter.jsonb(
final JsonTypeConverter2<Map<String, Object?>, Uint8List, Object?> userMetadataConverter = TypeConverter.jsonb(
fromJson: (json) => json as Map<String, Object?>,
);

View File

@@ -8,10 +8,7 @@ class DriftAssetFaceRepository extends DriftDatabaseRepository {
const DriftAssetFaceRepository(this._db) : super(_db);
Future<List<AssetFace>> getAll() {
return _db.assetFaceEntity
.select()
.map((assetFace) => assetFace.toDto())
.get();
return _db.assetFaceEntity.select().map((assetFace) => assetFace.toDto()).get();
}
}

View File

@@ -25,8 +25,7 @@ class DriftBackupRepository extends DriftDatabaseRepository {
),
])
..where(
_db.localAlbumEntity.backupSelection
.equalsValue(BackupSelection.excluded),
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.excluded),
);
}
@@ -41,10 +40,8 @@ class DriftBackupRepository extends DriftDatabaseRepository {
),
])
..where(
_db.localAlbumEntity.backupSelection
.equalsValue(BackupSelection.selected) &
_db.localAlbumAssetEntity.assetId
.isNotInQuery(_getExcludedSubquery()),
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.selected) &
_db.localAlbumAssetEntity.assetId.isNotInQuery(_getExcludedSubquery()),
);
return query.get().then((rows) => rows.length);
@@ -66,18 +63,14 @@ class DriftBackupRepository extends DriftDatabaseRepository {
),
leftOuterJoin(
_db.remoteAssetEntity,
_db.localAssetEntity.checksum
.equalsExp(_db.remoteAssetEntity.checksum),
_db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum),
useColumns: false,
),
])
..where(
_db.localAlbumEntity.backupSelection
.equalsValue(BackupSelection.selected) &
(_db.remoteAssetEntity.id.isNull() |
_db.remoteAssetEntity.ownerId.equals(userId).not()) &
_db.localAlbumAssetEntity.assetId
.isNotInQuery(_getExcludedSubquery()),
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.selected) &
(_db.remoteAssetEntity.id.isNull() | _db.remoteAssetEntity.ownerId.equals(userId).not()) &
_db.localAlbumAssetEntity.assetId.isNotInQuery(_getExcludedSubquery()),
);
return query.get().then((rows) => rows.length);
@@ -101,18 +94,15 @@ class DriftBackupRepository extends DriftDatabaseRepository {
),
innerJoin(
_db.remoteAssetEntity,
_db.localAssetEntity.checksum
.equalsExp(_db.remoteAssetEntity.checksum),
_db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum),
useColumns: false,
),
])
..where(
_db.localAlbumEntity.backupSelection
.equalsValue(BackupSelection.selected) &
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.selected) &
_db.remoteAssetEntity.id.isNotNull() &
_db.remoteAssetEntity.ownerId.equals(userId) &
_db.localAlbumAssetEntity.assetId
.isNotInQuery(_getExcludedSubquery()),
_db.localAlbumAssetEntity.assetId.isNotInQuery(_getExcludedSubquery()),
);
return query.get().then((rows) => rows.length);
@@ -122,8 +112,7 @@ class DriftBackupRepository extends DriftDatabaseRepository {
final selectedAlbumIds = _db.localAlbumEntity.selectOnly(distinct: true)
..addColumns([_db.localAlbumEntity.id])
..where(
_db.localAlbumEntity.backupSelection
.equalsValue(BackupSelection.selected),
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.selected),
);
final query = _db.localAssetEntity.select()
@@ -133,8 +122,7 @@ class DriftBackupRepository extends DriftDatabaseRepository {
_db.localAlbumAssetEntity.selectOnly()
..addColumns([_db.localAlbumAssetEntity.assetId])
..where(
_db.localAlbumAssetEntity.albumId
.isInQuery(selectedAlbumIds) &
_db.localAlbumAssetEntity.albumId.isInQuery(selectedAlbumIds) &
_db.localAlbumAssetEntity.assetId.equalsExp(lae.id),
),
) &

View File

@@ -4,8 +4,9 @@ import 'package:drift/drift.dart';
import 'package:drift_flutter/drift_flutter.dart';
import 'package:flutter/foundation.dart';
import 'package:immich_mobile/domain/interfaces/db.interface.dart';
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.dart';
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.dart';
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart';
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.dart';
import 'package:immich_mobile/infrastructure/entities/local_album.entity.dart';
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.dart';
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.dart';
@@ -43,6 +44,7 @@ class IsarDatabaseRepository implements IDatabaseRepository {
@DriftDatabase(
tables: [
UserEntity,
AuthUserEntity,
UserMetadataEntity,
PartnerEntity,
LocalAlbumEntity,
@@ -74,7 +76,7 @@ class Drift extends $Drift implements IDatabaseRepository {
);
@override
int get schemaVersion => 4;
int get schemaVersion => 5;
@override
MigrationStrategy get migration => MigrationStrategy(
@@ -102,13 +104,18 @@ class Drift extends $Drift implements IDatabaseRepository {
// asset_face_entity is added
await m.create(v4.assetFaceEntity);
},
from4To5: (m, v5) async {
// Some column got moved from user_entity to auth_user_entity
await m.alterTable(TableMigration(v5.userEntity));
// auth_user_entity is added
await m.create(v5.authUserEntity);
},
),
);
if (kDebugMode) {
// Fail if the migration broke foreign keys
final wrongFKs =
await customSelect('PRAGMA foreign_key_check').get();
final wrongFKs = await customSelect('PRAGMA foreign_key_check').get();
assert(wrongFKs.isEmpty, '${wrongFKs.map((e) => e.data)}');
}
@@ -127,6 +134,5 @@ class DriftDatabaseRepository implements IDatabaseRepository {
const DriftDatabaseRepository(this._db);
@override
Future<T> transaction<T>(Future<T> Function() callback) =>
_db.transaction(callback);
Future<T> transaction<T>(Future<T> Function() callback) => _db.transaction(callback);
}

View File

@@ -13,29 +13,31 @@ import 'package:immich_mobile/infrastructure/entities/local_album.entity.drift.d
as i5;
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart'
as i6;
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart'
as i7;
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
as i8;
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
as i9;
import 'package:immich_mobile/infrastructure/entities/remote_album.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
as i10;
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/remote_album.entity.drift.dart'
as i11;
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart'
as i12;
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart'
as i13;
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'
as i14;
import 'package:immich_mobile/infrastructure/entities/person.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart'
as i15;
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.drift.dart'
import 'package:immich_mobile/infrastructure/entities/person.entity.drift.dart'
as i16;
import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart'
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.drift.dart'
as i17;
import 'package:drift/internal/modular.dart' as i18;
import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart'
as i18;
import 'package:drift/internal/modular.dart' as i19;
abstract class $Drift extends i0.GeneratedDatabase {
$Drift(i0.QueryExecutor e) : super(e);
@@ -50,26 +52,28 @@ abstract class $Drift extends i0.GeneratedDatabase {
i5.$LocalAlbumEntityTable(this);
late final i6.$LocalAlbumAssetEntityTable localAlbumAssetEntity =
i6.$LocalAlbumAssetEntityTable(this);
late final i7.$UserMetadataEntityTable userMetadataEntity =
i7.$UserMetadataEntityTable(this);
late final i8.$PartnerEntityTable partnerEntity =
i8.$PartnerEntityTable(this);
late final i9.$RemoteExifEntityTable remoteExifEntity =
i9.$RemoteExifEntityTable(this);
late final i10.$RemoteAlbumEntityTable remoteAlbumEntity =
i10.$RemoteAlbumEntityTable(this);
late final i11.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity =
i11.$RemoteAlbumAssetEntityTable(this);
late final i12.$RemoteAlbumUserEntityTable remoteAlbumUserEntity =
i12.$RemoteAlbumUserEntityTable(this);
late final i13.$MemoryEntityTable memoryEntity = i13.$MemoryEntityTable(this);
late final i14.$MemoryAssetEntityTable memoryAssetEntity =
i14.$MemoryAssetEntityTable(this);
late final i15.$PersonEntityTable personEntity = i15.$PersonEntityTable(this);
late final i16.$AssetFaceEntityTable assetFaceEntity =
i16.$AssetFaceEntityTable(this);
i17.MergedAssetDrift get mergedAssetDrift => i18.ReadDatabaseContainer(this)
.accessor<i17.MergedAssetDrift>(i17.MergedAssetDrift.new);
late final i7.$AuthUserEntityTable authUserEntity =
i7.$AuthUserEntityTable(this);
late final i8.$UserMetadataEntityTable userMetadataEntity =
i8.$UserMetadataEntityTable(this);
late final i9.$PartnerEntityTable partnerEntity =
i9.$PartnerEntityTable(this);
late final i10.$RemoteExifEntityTable remoteExifEntity =
i10.$RemoteExifEntityTable(this);
late final i11.$RemoteAlbumEntityTable remoteAlbumEntity =
i11.$RemoteAlbumEntityTable(this);
late final i12.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity =
i12.$RemoteAlbumAssetEntityTable(this);
late final i13.$RemoteAlbumUserEntityTable remoteAlbumUserEntity =
i13.$RemoteAlbumUserEntityTable(this);
late final i14.$MemoryEntityTable memoryEntity = i14.$MemoryEntityTable(this);
late final i15.$MemoryAssetEntityTable memoryAssetEntity =
i15.$MemoryAssetEntityTable(this);
late final i16.$PersonEntityTable personEntity = i16.$PersonEntityTable(this);
late final i17.$AssetFaceEntityTable assetFaceEntity =
i17.$AssetFaceEntityTable(this);
i18.MergedAssetDrift get mergedAssetDrift => i19.ReadDatabaseContainer(this)
.accessor<i18.MergedAssetDrift>(i18.MergedAssetDrift.new);
@override
Iterable<i0.TableInfo<i0.Table, Object?>> get allTables =>
allSchemaEntities.whereType<i0.TableInfo<i0.Table, Object?>>();
@@ -84,6 +88,7 @@ abstract class $Drift extends i0.GeneratedDatabase {
i4.idxLocalAssetChecksum,
i2.uQRemoteAssetOwnerChecksum,
i2.idxRemoteAssetChecksum,
authUserEntity,
userMetadataEntity,
partnerEntity,
remoteExifEntity,
@@ -268,25 +273,27 @@ class $DriftManager {
i5.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity);
i6.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i6
.$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity);
i7.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
i7.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
i8.$$PartnerEntityTableTableManager get partnerEntity =>
i8.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
i9.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
i9.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
i10.$$RemoteAlbumEntityTableTableManager get remoteAlbumEntity =>
i10.$$RemoteAlbumEntityTableTableManager(_db, _db.remoteAlbumEntity);
i11.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
i11.$$RemoteAlbumAssetEntityTableTableManager(
i7.$$AuthUserEntityTableTableManager get authUserEntity =>
i7.$$AuthUserEntityTableTableManager(_db, _db.authUserEntity);
i8.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
i8.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
i9.$$PartnerEntityTableTableManager get partnerEntity =>
i9.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
i10.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
i10.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
i11.$$RemoteAlbumEntityTableTableManager get remoteAlbumEntity =>
i11.$$RemoteAlbumEntityTableTableManager(_db, _db.remoteAlbumEntity);
i12.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
i12.$$RemoteAlbumAssetEntityTableTableManager(
_db, _db.remoteAlbumAssetEntity);
i12.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i12
i13.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i13
.$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity);
i13.$$MemoryEntityTableTableManager get memoryEntity =>
i13.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
i14.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
i14.$$MemoryAssetEntityTableTableManager(_db, _db.memoryAssetEntity);
i15.$$PersonEntityTableTableManager get personEntity =>
i15.$$PersonEntityTableTableManager(_db, _db.personEntity);
i16.$$AssetFaceEntityTableTableManager get assetFaceEntity =>
i16.$$AssetFaceEntityTableTableManager(_db, _db.assetFaceEntity);
i14.$$MemoryEntityTableTableManager get memoryEntity =>
i14.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
i15.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
i15.$$MemoryAssetEntityTableTableManager(_db, _db.memoryAssetEntity);
i16.$$PersonEntityTableTableManager get personEntity =>
i16.$$PersonEntityTableTableManager(_db, _db.personEntity);
i17.$$AssetFaceEntityTableTableManager get assetFaceEntity =>
i17.$$AssetFaceEntityTableTableManager(_db, _db.assetFaceEntity);
}

View File

@@ -1707,10 +1707,470 @@ i1.GeneratedColumn<int> _column_82(String aliasedName) =>
i1.GeneratedColumn<String> _column_83(String aliasedName) =>
i1.GeneratedColumn<String>('source_type', aliasedName, false,
type: i1.DriftSqlType.string);
final class Schema5 extends i0.VersionedSchema {
Schema5({required super.database}) : super(version: 5);
@override
late final List<i1.DatabaseSchemaEntity> entities = [
userEntity,
remoteAssetEntity,
stackEntity,
localAssetEntity,
localAlbumEntity,
localAlbumAssetEntity,
idxLocalAssetChecksum,
uQRemoteAssetOwnerChecksum,
idxRemoteAssetChecksum,
authUserEntity,
userMetadataEntity,
partnerEntity,
remoteExifEntity,
remoteAlbumEntity,
remoteAlbumAssetEntity,
remoteAlbumUserEntity,
memoryEntity,
memoryAssetEntity,
personEntity,
assetFaceEntity,
];
late final Shape16 userEntity = Shape16(
source: i0.VersionedTable(
entityName: 'user_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_1,
_column_3,
_column_18,
_column_84,
],
attachedDatabase: database,
),
alias: null);
late final Shape1 remoteAssetEntity = Shape1(
source: i0.VersionedTable(
entityName: 'remote_asset_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_1,
_column_8,
_column_9,
_column_5,
_column_10,
_column_11,
_column_12,
_column_0,
_column_13,
_column_14,
_column_15,
_column_16,
_column_17,
_column_18,
_column_19,
_column_20,
_column_21,
],
attachedDatabase: database,
),
alias: null);
late final Shape3 stackEntity = Shape3(
source: i0.VersionedTable(
entityName: 'stack_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_9,
_column_5,
_column_15,
_column_75,
],
attachedDatabase: database,
),
alias: null);
late final Shape2 localAssetEntity = Shape2(
source: i0.VersionedTable(
entityName: 'local_asset_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_1,
_column_8,
_column_9,
_column_5,
_column_10,
_column_11,
_column_12,
_column_0,
_column_22,
_column_14,
_column_23,
],
attachedDatabase: database,
),
alias: null);
late final Shape6 localAlbumEntity = Shape6(
source: i0.VersionedTable(
entityName: 'local_album_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_1,
_column_5,
_column_31,
_column_32,
_column_33,
],
attachedDatabase: database,
),
alias: null);
late final Shape7 localAlbumAssetEntity = Shape7(
source: i0.VersionedTable(
entityName: 'local_album_asset_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(asset_id, album_id)',
],
columns: [
_column_34,
_column_35,
],
attachedDatabase: database,
),
alias: null);
final i1.Index idxLocalAssetChecksum = i1.Index('idx_local_asset_checksum',
'CREATE INDEX idx_local_asset_checksum ON local_asset_entity (checksum)');
final i1.Index uQRemoteAssetOwnerChecksum = i1.Index(
'UQ_remote_asset_owner_checksum',
'CREATE UNIQUE INDEX UQ_remote_asset_owner_checksum ON remote_asset_entity (checksum, owner_id)');
final i1.Index idxRemoteAssetChecksum = i1.Index('idx_remote_asset_checksum',
'CREATE INDEX idx_remote_asset_checksum ON remote_asset_entity (checksum)');
late final Shape17 authUserEntity = Shape17(
source: i0.VersionedTable(
entityName: 'auth_user_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_1,
_column_3,
_column_18,
_column_84,
_column_2,
_column_85,
_column_86,
_column_87,
_column_88,
_column_6,
_column_7,
_column_89,
],
attachedDatabase: database,
),
alias: null);
late final Shape4 userMetadataEntity = Shape4(
source: i0.VersionedTable(
entityName: 'user_metadata_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(user_id, "key")',
],
columns: [
_column_25,
_column_26,
_column_27,
],
attachedDatabase: database,
),
alias: null);
late final Shape5 partnerEntity = Shape5(
source: i0.VersionedTable(
entityName: 'partner_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(shared_by_id, shared_with_id)',
],
columns: [
_column_28,
_column_29,
_column_30,
],
attachedDatabase: database,
),
alias: null);
late final Shape8 remoteExifEntity = Shape8(
source: i0.VersionedTable(
entityName: 'remote_exif_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(asset_id)',
],
columns: [
_column_36,
_column_37,
_column_38,
_column_39,
_column_40,
_column_41,
_column_11,
_column_10,
_column_42,
_column_43,
_column_44,
_column_45,
_column_46,
_column_47,
_column_48,
_column_49,
_column_50,
_column_51,
_column_52,
_column_53,
_column_54,
_column_55,
],
attachedDatabase: database,
),
alias: null);
late final Shape9 remoteAlbumEntity = Shape9(
source: i0.VersionedTable(
entityName: 'remote_album_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_1,
_column_56,
_column_9,
_column_5,
_column_15,
_column_57,
_column_58,
_column_59,
],
attachedDatabase: database,
),
alias: null);
late final Shape7 remoteAlbumAssetEntity = Shape7(
source: i0.VersionedTable(
entityName: 'remote_album_asset_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(asset_id, album_id)',
],
columns: [
_column_36,
_column_60,
],
attachedDatabase: database,
),
alias: null);
late final Shape10 remoteAlbumUserEntity = Shape10(
source: i0.VersionedTable(
entityName: 'remote_album_user_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(album_id, user_id)',
],
columns: [
_column_60,
_column_25,
_column_61,
],
attachedDatabase: database,
),
alias: null);
late final Shape11 memoryEntity = Shape11(
source: i0.VersionedTable(
entityName: 'memory_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_9,
_column_5,
_column_18,
_column_15,
_column_8,
_column_62,
_column_63,
_column_64,
_column_65,
_column_66,
_column_67,
],
attachedDatabase: database,
),
alias: null);
late final Shape12 memoryAssetEntity = Shape12(
source: i0.VersionedTable(
entityName: 'memory_asset_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(asset_id, memory_id)',
],
columns: [
_column_36,
_column_68,
],
attachedDatabase: database,
),
alias: null);
late final Shape14 personEntity = Shape14(
source: i0.VersionedTable(
entityName: 'person_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_9,
_column_5,
_column_15,
_column_1,
_column_69,
_column_71,
_column_72,
_column_73,
_column_74,
],
attachedDatabase: database,
),
alias: null);
late final Shape15 assetFaceEntity = Shape15(
source: i0.VersionedTable(
entityName: 'asset_face_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: [
'PRIMARY KEY(id)',
],
columns: [
_column_0,
_column_36,
_column_76,
_column_77,
_column_78,
_column_79,
_column_80,
_column_81,
_column_82,
_column_83,
],
attachedDatabase: database,
),
alias: null);
}
class Shape16 extends i0.VersionedTable {
Shape16({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get id =>
columnsByName['id']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get name =>
columnsByName['name']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get email =>
columnsByName['email']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<DateTime> get deletedAt =>
columnsByName['deleted_at']! as i1.GeneratedColumn<DateTime>;
i1.GeneratedColumn<int> get avatarColor =>
columnsByName['avatar_color']! as i1.GeneratedColumn<int>;
}
i1.GeneratedColumn<int> _column_84(String aliasedName) =>
i1.GeneratedColumn<int>('avatar_color', aliasedName, true,
type: i1.DriftSqlType.int);
class Shape17 extends i0.VersionedTable {
Shape17({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get id =>
columnsByName['id']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get name =>
columnsByName['name']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get email =>
columnsByName['email']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<DateTime> get deletedAt =>
columnsByName['deleted_at']! as i1.GeneratedColumn<DateTime>;
i1.GeneratedColumn<int> get avatarColor =>
columnsByName['avatar_color']! as i1.GeneratedColumn<int>;
i1.GeneratedColumn<bool> get isAdmin =>
columnsByName['is_admin']! as i1.GeneratedColumn<bool>;
i1.GeneratedColumn<String> get oauthId =>
columnsByName['oauth_id']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get pinCode =>
columnsByName['pin_code']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<bool> get hasProfileImage =>
columnsByName['has_profile_image']! as i1.GeneratedColumn<bool>;
i1.GeneratedColumn<DateTime> get profileChangedAt =>
columnsByName['profile_changed_at']! as i1.GeneratedColumn<DateTime>;
i1.GeneratedColumn<int> get quotaSizeInBytes =>
columnsByName['quota_size_in_bytes']! as i1.GeneratedColumn<int>;
i1.GeneratedColumn<int> get quotaUsageInBytes =>
columnsByName['quota_usage_in_bytes']! as i1.GeneratedColumn<int>;
i1.GeneratedColumn<String> get storageLabel =>
columnsByName['storage_label']! as i1.GeneratedColumn<String>;
}
i1.GeneratedColumn<String> _column_85(String aliasedName) =>
i1.GeneratedColumn<String>('oauth_id', aliasedName, false,
type: i1.DriftSqlType.string,
defaultValue: const CustomExpression('\'\''));
i1.GeneratedColumn<String> _column_86(String aliasedName) =>
i1.GeneratedColumn<String>('pin_code', aliasedName, true,
type: i1.DriftSqlType.string);
i1.GeneratedColumn<bool> _column_87(String aliasedName) =>
i1.GeneratedColumn<bool>('has_profile_image', aliasedName, false,
type: i1.DriftSqlType.bool,
defaultConstraints: i1.GeneratedColumn.constraintIsAlways(
'CHECK ("has_profile_image" IN (0, 1))'),
defaultValue: const CustomExpression('0'));
i1.GeneratedColumn<DateTime> _column_88(String aliasedName) =>
i1.GeneratedColumn<DateTime>('profile_changed_at', aliasedName, false,
type: i1.DriftSqlType.dateTime,
defaultValue: const CustomExpression('CURRENT_TIMESTAMP'));
i1.GeneratedColumn<String> _column_89(String aliasedName) =>
i1.GeneratedColumn<String>('storage_label', aliasedName, true,
type: i1.DriftSqlType.string);
i0.MigrationStepWithVersion migrationSteps({
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
required Future<void> Function(i1.Migrator m, Schema4 schema) from3To4,
required Future<void> Function(i1.Migrator m, Schema5 schema) from4To5,
}) {
return (currentVersion, database) async {
switch (currentVersion) {
@@ -1729,6 +2189,11 @@ i0.MigrationStepWithVersion migrationSteps({
final migrator = i1.Migrator(database, schema);
await from3To4(migrator, schema);
return 4;
case 4:
final schema = Schema5(database: database);
final migrator = i1.Migrator(database, schema);
await from4To5(migrator, schema);
return 5;
default:
throw ArgumentError.value('Unknown migration from $currentVersion');
}
@@ -1739,10 +2204,12 @@ i1.OnUpgrade stepByStep({
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
required Future<void> Function(i1.Migrator m, Schema4 schema) from3To4,
required Future<void> Function(i1.Migrator m, Schema5 schema) from4To5,
}) =>
i0.VersionedSchema.stepByStepHelper(
step: migrationSteps(
from1To2: from1To2,
from2To3: from2To3,
from3To4: from3To4,
from4To5: from4To5,
));

View File

@@ -24,8 +24,7 @@ class IsarDeviceAssetRepository extends IsarDatabaseRepository {
Future<bool> updateAll(List<DeviceAsset> assetHash) {
return transaction(() async {
await _db.deviceAssetEntitys
.putAll(assetHash.map(DeviceAssetEntity.fromDto).toList());
await _db.deviceAssetEntitys.putAll(assetHash.map(DeviceAssetEntity.fromDto).toList());
return true;
});
}

View File

@@ -1,6 +1,5 @@
import 'package:immich_mobile/domain/models/exif.model.dart';
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart'
as entity;
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' as entity;
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
import 'package:isar/isar.dart';

View File

@@ -8,13 +8,7 @@ import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
import 'package:immich_mobile/utils/database.utils.dart';
import 'package:platform/platform.dart';
enum SortLocalAlbumsBy {
id,
backupSelection,
isIosSharedAlbum,
name,
assetCount
}
enum SortLocalAlbumsBy { id, backupSelection, isIosSharedAlbum, name, assetCount }
class DriftLocalAlbumRepository extends DriftDatabaseRepository {
final Drift _db;
@@ -43,12 +37,9 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
orderings.add(
switch (sort) {
SortLocalAlbumsBy.id => OrderingTerm.asc(_db.localAlbumEntity.id),
SortLocalAlbumsBy.backupSelection =>
OrderingTerm.asc(_db.localAlbumEntity.backupSelection),
SortLocalAlbumsBy.isIosSharedAlbum =>
OrderingTerm.asc(_db.localAlbumEntity.isIosSharedAlbum),
SortLocalAlbumsBy.name =>
OrderingTerm.asc(_db.localAlbumEntity.name),
SortLocalAlbumsBy.backupSelection => OrderingTerm.asc(_db.localAlbumEntity.backupSelection),
SortLocalAlbumsBy.isIosSharedAlbum => OrderingTerm.asc(_db.localAlbumEntity.isIosSharedAlbum),
SortLocalAlbumsBy.name => OrderingTerm.asc(_db.localAlbumEntity.name),
SortLocalAlbumsBy.assetCount => OrderingTerm.desc(assetCount),
},
);
@@ -58,9 +49,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
return query
.map(
(row) => row
.readTable(_db.localAlbumEntity)
.toDto(assetCount: row.read(assetCount) ?? 0),
(row) => row.readTable(_db.localAlbumEntity).toDto(assetCount: row.read(assetCount) ?? 0),
)
.get();
}
@@ -69,15 +58,11 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
// Remove all assets that are only in this particular album
// We cannot remove all assets in the album because they might be in other albums in iOS
// That is not the case on Android since asset <-> album has one:one mapping
final assetsToDelete = _platform.isIOS
? await _getUniqueAssetsInAlbum(albumId)
: await getAssetIds(albumId);
final assetsToDelete = _platform.isIOS ? await _getUniqueAssetsInAlbum(albumId) : await getAssetIds(albumId);
await _deleteAssets(assetsToDelete);
// All the other assets that are still associated will be unlinked automatically on-cascade
await _db.managers.localAlbumEntity
.filter((a) => a.id.equals(albumId))
.delete();
await _db.managers.localAlbumEntity.filter((a) => a.id.equals(albumId)).delete();
});
Future<void> syncDeletes(
@@ -95,13 +80,11 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
..join([
innerJoin(
_db.localAlbumEntity,
_db.localAlbumAssetEntity.albumId
.equalsExp(_db.localAlbumEntity.id),
_db.localAlbumAssetEntity.albumId.equalsExp(_db.localAlbumEntity.id),
),
]);
subQuery.where(
_db.localAlbumEntity.id.equals(albumId) &
_db.localAlbumAssetEntity.assetId.isNotIn(assetIdsToKeep),
_db.localAlbumEntity.id.equals(albumId) & _db.localAlbumAssetEntity.assetId.isNotIn(assetIdsToKeep),
);
return localAsset.id.isInQuery(subQuery);
});
@@ -122,8 +105,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
);
return _db.transaction(() async {
await _db.localAlbumEntity
.insertOne(companion, onConflict: DoUpdate((_) => companion));
await _db.localAlbumEntity.insertOne(companion, onConflict: DoUpdate((_) => companion));
if (toUpsert.isNotEmpty) {
await _upsertAssets(toUpsert);
await _db.localAlbumAssetEntity.insertAll(
@@ -142,9 +124,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
Future<void> updateAll(Iterable<LocalAlbum> albums) {
return _db.transaction(() async {
await _db.localAlbumEntity
.update()
.write(const LocalAlbumEntityCompanion(marker_: Value(true)));
await _db.localAlbumEntity.update().write(const LocalAlbumEntityCompanion(marker_: Value(true)));
await _db.batch((batch) {
for (final album in albums) {
@@ -184,8 +164,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
..join([
innerJoin(
_db.localAlbumEntity,
_db.localAlbumAssetEntity.albumId
.equalsExp(_db.localAlbumEntity.id),
_db.localAlbumAssetEntity.albumId.equalsExp(_db.localAlbumEntity.id),
),
]);
subQuery.where(_db.localAlbumEntity.marker_.isNotNull());
@@ -209,18 +188,14 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
)
..where(_db.localAlbumAssetEntity.albumId.equals(albumId))
..orderBy([OrderingTerm.asc(_db.localAssetEntity.id)]);
return query
.map((row) => row.readTable(_db.localAssetEntity).toDto())
.get();
return query.map((row) => row.readTable(_db.localAssetEntity).toDto()).get();
}
Future<List<String>> getAssetIds(String albumId) {
final query = _db.localAlbumAssetEntity.selectOnly()
..addColumns([_db.localAlbumAssetEntity.assetId])
..where(_db.localAlbumAssetEntity.albumId.equals(albumId));
return query
.map((row) => row.read(_db.localAlbumAssetEntity.assetId)!)
.get();
return query.map((row) => row.read(_db.localAlbumAssetEntity.assetId)!).get();
}
Future<void> processDelta({
@@ -240,9 +215,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
assetAlbums.cast<String, List<Object?>>().forEach((assetId, albumIds) {
batch.deleteWhere(
_db.localAlbumAssetEntity,
(f) =>
f.albumId.isNotIn(albumIds.cast<String?>().nonNulls) &
f.assetId.equals(assetId),
(f) => f.albumId.isNotIn(albumIds.cast<String?>().nonNulls) & f.assetId.equals(assetId),
);
});
});
@@ -273,14 +246,11 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
],
)
..where(
_db.localAlbumAssetEntity.albumId.equals(albumId) &
_db.localAssetEntity.checksum.isNull(),
_db.localAlbumAssetEntity.albumId.equals(albumId) & _db.localAssetEntity.checksum.isNull(),
)
..orderBy([OrderingTerm.asc(_db.localAssetEntity.id)]);
return query
.map((row) => row.readTable(_db.localAssetEntity).toDto())
.get();
return query.map((row) => row.readTable(_db.localAssetEntity).toDto()).get();
}
Future<void> _upsertAssets(Iterable<LocalAsset> localAssets) {
@@ -364,8 +334,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
..addColumns([assetId])
..groupBy(
[assetId],
having: _db.localAlbumAssetEntity.albumId.count().equals(1) &
_db.localAlbumAssetEntity.albumId.equals(albumId),
having: _db.localAlbumAssetEntity.albumId.count().equals(1) & _db.localAlbumAssetEntity.albumId.equals(albumId),
);
return query.map((row) => row.read(assetId)!).get();
@@ -392,9 +361,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
..orderBy([OrderingTerm.asc(_db.localAssetEntity.id)])
..limit(1);
final results = await query
.map((row) => row.readTable(_db.localAssetEntity).toDto())
.get();
final results = await query.map((row) => row.readTable(_db.localAssetEntity).toDto()).get();
return results.isNotEmpty ? results.first : null;
}

View File

@@ -10,9 +10,7 @@ class DriftLocalAssetRepository extends DriftDatabaseRepository {
const DriftLocalAssetRepository(this._db) : super(_db);
Stream<LocalAsset?> watchAsset(String id) {
final query = _db.localAssetEntity
.select()
.addColumns([_db.remoteAssetEntity.id]).join([
final query = _db.localAssetEntity.select().addColumns([_db.remoteAssetEntity.id]).join([
leftOuterJoin(
_db.remoteAssetEntity,
_db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum),
@@ -58,8 +56,7 @@ class DriftLocalAssetRepository extends DriftDatabaseRepository {
}
Future<LocalAsset?> getById(String id) {
final query = _db.localAssetEntity.select()
..where((lae) => lae.id.equals(id));
final query = _db.localAssetEntity.select()..where((lae) => lae.id.equals(id));
return query.map((row) => row.toDto()).getSingleOrNull();
}
@@ -69,8 +66,6 @@ class DriftLocalAssetRepository extends DriftDatabaseRepository {
}
Future<int> getHashedCount() {
return _db.managers.localAssetEntity
.filter((e) => e.checksum.isNull().not())
.count();
return _db.managers.localAssetEntity.filter((e) => e.checksum.isNull().not()).count();
}
}

View File

@@ -13,8 +13,7 @@ class IsarLogRepository extends IsarDatabaseRepository {
}
Future<List<LogMessage>> getAll() async {
final logs =
await _db.loggerMessages.where().sortByCreatedAtDesc().findAll();
final logs = await _db.loggerMessages.where().sortByCreatedAtDesc().findAll();
return logs.map((l) => l.toDto()).toList();
}
@@ -28,8 +27,7 @@ class IsarLogRepository extends IsarDatabaseRepository {
Future<bool> insertAll(Iterable<LogMessage> logs) async {
await transaction(() async {
final logEntities =
logs.map((log) => LoggerMessage.fromDto(log)).toList();
final logEntities = logs.map((log) => LoggerMessage.fromDto(log)).toList();
await _db.loggerMessages.putAll(logEntities);
});
return true;

View File

@@ -22,8 +22,7 @@ class DriftMemoryRepository extends DriftDatabaseRepository {
_db.remoteAssetEntity,
_db.remoteAssetEntity.id.equalsExp(_db.memoryAssetEntity.assetId) &
_db.remoteAssetEntity.deletedAt.isNull() &
_db.remoteAssetEntity.visibility
.equalsValue(AssetVisibility.timeline),
_db.remoteAssetEntity.visibility.equalsValue(AssetVisibility.timeline),
),
])
..where(_db.memoryEntity.ownerId.equals(ownerId))

View File

@@ -7,7 +7,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
final Drift _db;
const DriftPartnerRepository(this._db) : super(_db);
Future<List<PartnerUserDto>> getPartners(String userId) {
Future<List<PartnerUser>> getPartners(String userId) {
final query = _db.select(_db.partnerEntity).join([
innerJoin(
_db.userEntity,
@@ -21,7 +21,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
return query.map((row) {
final user = row.readTable(_db.userEntity);
final partner = row.readTable(_db.partnerEntity);
return PartnerUserDto(
return PartnerUser(
id: user.id,
email: user.email,
name: user.name,
@@ -31,12 +31,11 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
}
// Get users who we can share our library with
Future<List<PartnerUserDto>> getAvailablePartners(String currentUserId) {
final query = _db.select(_db.userEntity)
..where((row) => row.id.equals(currentUserId).not());
Future<List<PartnerUser>> getAvailablePartners(String currentUserId) {
final query = _db.select(_db.userEntity)..where((row) => row.id.equals(currentUserId).not());
return query.map((user) {
return PartnerUserDto(
return PartnerUser(
id: user.id,
email: user.email,
name: user.name,
@@ -46,7 +45,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
}
// Get users who are sharing their photos WITH the current user
Future<List<PartnerUserDto>> getSharedWith(String partnerId) {
Future<List<PartnerUser>> getSharedWith(String partnerId) {
final query = _db.select(_db.partnerEntity).join([
innerJoin(
_db.userEntity,
@@ -60,7 +59,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
return query.map((row) {
final user = row.readTable(_db.userEntity);
final partner = row.readTable(_db.partnerEntity);
return PartnerUserDto(
return PartnerUser(
id: user.id,
email: user.email,
name: user.name,
@@ -70,7 +69,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
}
// Get users who the current user is sharing their photos TO
Future<List<PartnerUserDto>> getSharedBy(String userId) {
Future<List<PartnerUser>> getSharedBy(String userId) {
final query = _db.select(_db.partnerEntity).join([
innerJoin(
_db.userEntity,
@@ -84,7 +83,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
return query.map((row) {
final user = row.readTable(_db.userEntity);
final partner = row.readTable(_db.partnerEntity);
return PartnerUserDto(
return PartnerUser(
id: user.id,
email: user.email,
name: user.name,
@@ -95,24 +94,19 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
Future<List<String>> getAllPartnerIds(String userId) async {
// Get users who are sharing with me (sharedWithId = userId)
final sharingWithMeQuery = _db.select(_db.partnerEntity)
..where((tbl) => tbl.sharedWithId.equals(userId));
final sharingWithMe =
await sharingWithMeQuery.map((row) => row.sharedById).get();
final sharingWithMeQuery = _db.select(_db.partnerEntity)..where((tbl) => tbl.sharedWithId.equals(userId));
final sharingWithMe = await sharingWithMeQuery.map((row) => row.sharedById).get();
// Get users who I am sharing with (sharedById = userId)
final sharingWithThemQuery = _db.select(_db.partnerEntity)
..where((tbl) => tbl.sharedById.equals(userId));
final sharingWithThem =
await sharingWithThemQuery.map((row) => row.sharedWithId).get();
final sharingWithThemQuery = _db.select(_db.partnerEntity)..where((tbl) => tbl.sharedById.equals(userId));
final sharingWithThem = await sharingWithThemQuery.map((row) => row.sharedWithId).get();
// Combine both lists and remove duplicates
final allPartnerIds =
<String>{...sharingWithMe, ...sharingWithThem}.toList();
final allPartnerIds = <String>{...sharingWithMe, ...sharingWithThem}.toList();
return allPartnerIds;
}
Future<PartnerUserDto?> getPartner(String partnerId, String userId) {
Future<PartnerUser?> getPartner(String partnerId, String userId) {
final query = _db.select(_db.partnerEntity).join([
innerJoin(
_db.userEntity,
@@ -120,14 +114,13 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
),
])
..where(
_db.partnerEntity.sharedById.equals(partnerId) &
_db.partnerEntity.sharedWithId.equals(userId),
_db.partnerEntity.sharedById.equals(partnerId) & _db.partnerEntity.sharedWithId.equals(userId),
);
return query.map((row) {
final user = row.readTable(_db.userEntity);
final partner = row.readTable(_db.partnerEntity);
return PartnerUserDto(
return PartnerUser(
id: user.id,
email: user.email,
name: user.name,
@@ -136,7 +129,7 @@ class DriftPartnerRepository extends DriftDatabaseRepository {
}).getSingleOrNull();
}
Future<bool> toggleShowInTimeline(PartnerUserDto partner, String userId) {
Future<bool> toggleShowInTimeline(PartnerUser partner, String userId) {
return _db.partnerEntity.update().replace(
PartnerEntityCompanion(
sharedById: Value(partner.id),

View File

@@ -8,8 +8,7 @@ class DriftPersonRepository extends DriftDatabaseRepository {
const DriftPersonRepository(this._db) : super(_db);
Future<List<Person>> getAll(String userId) {
final query = _db.personEntity.select()
..where((e) => e.ownerId.equals(userId));
final query = _db.personEntity.select()..where((e) => e.ownerId.equals(userId));
return query.map((person) {
return person.toDto();

View File

@@ -8,6 +8,7 @@ import 'package:immich_mobile/infrastructure/entities/remote_album.entity.drift.
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
enum SortRemoteAlbumsBy { id, updatedAt }
@@ -40,8 +41,7 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
]);
query
..where(_db.remoteAssetEntity.deletedAt.isNull())
..addColumns([assetCount])
..addColumns([_db.userEntity.name])
..addColumns([assetCount, _db.userEntity.name])
..groupBy([_db.remoteAlbumEntity.id]);
if (sortBy.isNotEmpty) {
@@ -50,8 +50,7 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
orderings.add(
switch (sort) {
SortRemoteAlbumsBy.id => OrderingTerm.asc(_db.remoteAlbumEntity.id),
SortRemoteAlbumsBy.updatedAt =>
OrderingTerm.desc(_db.remoteAlbumEntity.updatedAt),
SortRemoteAlbumsBy.updatedAt => OrderingTerm.desc(_db.remoteAlbumEntity.updatedAt),
},
);
}
@@ -137,8 +136,7 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
..join([
innerJoin(
_db.remoteAssetEntity,
_db.remoteAssetEntity.id
.equalsExp(_db.remoteAlbumAssetEntity.assetId),
_db.remoteAssetEntity.id.equalsExp(_db.remoteAlbumAssetEntity.assetId),
),
]);
@@ -149,37 +147,18 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
}).getSingle();
}
Future<List<UserDto>> getSharedUsers(String albumId) async {
final albumUserRows = await (_db.select(_db.remoteAlbumUserEntity)
..where((row) => row.albumId.equals(albumId)))
.get();
Future<List<User>> getSharedUsers(String albumId) async {
final query = _db.remoteAlbumUserEntity.selectOnly()
..join([
innerJoin(
_db.userEntity,
_db.userEntity.id.equalsExp(_db.remoteAlbumUserEntity.userId),
useColumns: true,
),
])
..where(_db.remoteAlbumUserEntity.albumId.equals(albumId));
if (albumUserRows.isEmpty) {
return [];
}
final userIds = albumUserRows.map((row) => row.userId);
return (_db.select(_db.userEntity)..where((row) => row.id.isIn(userIds)))
.map(
(user) => UserDto(
id: user.id,
email: user.email,
name: user.name,
profileImagePath: user.profileImagePath?.isEmpty == true
? null
: user.profileImagePath,
isAdmin: user.isAdmin,
updatedAt: user.updatedAt,
quotaSizeInBytes: user.quotaSizeInBytes ?? 0,
quotaUsageInBytes: user.quotaUsageInBytes,
memoryEnabled: true,
inTimeline: false,
isPartnerSharedBy: false,
isPartnerSharedWith: false,
),
)
.get();
return query.map((row) => row.readTable(_db.userEntity).toDto()).get();
}
Future<List<RemoteAsset>> getAssets(String albumId) {
@@ -191,9 +170,7 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
])
..where(_db.remoteAlbumAssetEntity.albumId.equals(albumId));
return query
.map((row) => row.readTable(_db.remoteAssetEntity).toDto())
.get();
return query.map((row) => row.readTable(_db.remoteAssetEntity).toDto()).get();
}
Future<int> addAssets(String albumId, List<String> assetIds) async {

View File

@@ -2,8 +2,7 @@ import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
import 'package:immich_mobile/domain/models/exif.model.dart';
import 'package:immich_mobile/domain/models/stack.model.dart';
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart'
hide ExifInfo;
import 'package:immich_mobile/infrastructure/entities/exif.entity.dart' hide ExifInfo;
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart';
@@ -22,8 +21,7 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
(row) =>
_db.remoteAssetEntity.ownerId.equals(userId) &
_db.remoteAssetEntity.deletedAt.isNull() &
_db.remoteAssetEntity.visibility
.equalsValue(AssetVisibility.timeline),
_db.remoteAssetEntity.visibility.equalsValue(AssetVisibility.timeline),
)
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
..limit(10);
@@ -57,8 +55,7 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
final query = _db.remoteAssetEntity.select()
..where(
(row) =>
row.stackId.equals(asset.stackId!) & row.id.equals(asset.id).not(),
(row) => row.stackId.equals(asset.stackId!) & row.id.equals(asset.id).not(),
)
..orderBy([(row) => OrderingTerm.desc(row.createdAt)]);
@@ -74,16 +71,14 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
Future<List<(String, String)>> getPlaces() {
final asset = Subquery(
_db.remoteAssetEntity.select()
..orderBy([(row) => OrderingTerm.desc(row.createdAt)]),
_db.remoteAssetEntity.select()..orderBy([(row) => OrderingTerm.desc(row.createdAt)]),
"asset",
);
final query = asset.selectOnly().join([
innerJoin(
_db.remoteExifEntity,
_db.remoteExifEntity.assetId
.equalsExp(asset.ref(_db.remoteAssetEntity.id)),
_db.remoteExifEntity.assetId.equalsExp(asset.ref(_db.remoteAssetEntity.id)),
useColumns: false,
),
])
@@ -94,9 +89,7 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
..where(
_db.remoteExifEntity.city.isNotNull() &
asset.ref(_db.remoteAssetEntity.deletedAt).isNull() &
asset
.ref(_db.remoteAssetEntity.visibility)
.equals(AssetVisibility.timeline.index),
asset.ref(_db.remoteAssetEntity.visibility).equals(AssetVisibility.timeline.index),
)
..groupBy([_db.remoteExifEntity.city])
..orderBy([OrderingTerm.asc(_db.remoteExifEntity.city)]);

View File

@@ -1,5 +1,4 @@
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart'
hide AssetVisibility;
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart' hide AssetVisibility;
import 'package:immich_mobile/infrastructure/repositories/api.repository.dart';
import 'package:immich_mobile/models/search/search_filter.model.dart';
import 'package:openapi/api.dart';
@@ -28,9 +27,7 @@ class SearchApiRepository extends ApiRepository {
model: filter.camera.model,
takenAfter: filter.date.takenAfter,
takenBefore: filter.date.takenBefore,
visibility: filter.display.isArchive
? AssetVisibility.archive
: AssetVisibility.timeline,
visibility: filter.display.isArchive ? AssetVisibility.archive : AssetVisibility.timeline,
isFavorite: filter.display.isFavorite ? true : null,
isNotInAlbum: filter.display.isNotInAlbum ? true : null,
personIds: filter.people.map((e) => e.id).toList(),
@@ -43,23 +40,16 @@ class SearchApiRepository extends ApiRepository {
return _api.searchAssets(
MetadataSearchDto(
originalFileName: filter.filename != null && filter.filename!.isNotEmpty
? filter.filename
: null,
originalFileName: filter.filename != null && filter.filename!.isNotEmpty ? filter.filename : null,
country: filter.location.country,
description:
filter.description != null && filter.description!.isNotEmpty
? filter.description
: null,
description: filter.description != null && filter.description!.isNotEmpty ? filter.description : null,
state: filter.location.state,
city: filter.location.city,
make: filter.camera.make,
model: filter.camera.model,
takenAfter: filter.date.takenAfter,
takenBefore: filter.date.takenBefore,
visibility: filter.display.isArchive
? AssetVisibility.archive
: AssetVisibility.timeline,
visibility: filter.display.isArchive ? AssetVisibility.archive : AssetVisibility.timeline,
isFavorite: filter.display.isFavorite ? true : null,
isNotInAlbum: filter.display.isNotInAlbum ? true : null,
personIds: filter.people.map((e) => e.id).toList(),

View File

@@ -8,8 +8,7 @@ class DriftStackRepository extends DriftDatabaseRepository {
const DriftStackRepository(this._db) : super(_db);
Future<List<Stack>> getAll(String userId) {
final query = _db.stackEntity.select()
..where((e) => e.ownerId.equals(userId));
final query = _db.stackEntity.select()..where((e) => e.ownerId.equals(userId));
return query.map((stack) {
return stack.toDto();

View File

@@ -63,23 +63,17 @@ class IsarStoreRepository extends IsarDatabaseRepository {
}
Future<StoreDto<Object>> _toUpdateEvent(StoreValue entity) async {
final key = StoreKey.values.firstWhere((e) => e.id == entity.id)
as StoreKey<Object>;
final key = StoreKey.values.firstWhere((e) => e.id == entity.id) as StoreKey<Object>;
final value = await _toValue(key, entity);
return StoreDto(key, value);
}
Future<T?> _toValue<T>(StoreKey<T> key, StoreValue entity) async =>
switch (key.type) {
Future<T?> _toValue<T>(StoreKey<T> key, StoreValue entity) async => switch (key.type) {
const (int) => entity.intValue,
const (String) => entity.strValue,
const (bool) => entity.intValue == 1,
const (DateTime) => entity.intValue == null
? null
: DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
const (UserDto) => entity.strValue == null
? null
: await IsarUserRepository(_db).getByUserId(entity.strValue!),
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
const (UserDto) => entity.strValue == null ? null : await IsarUserRepository(_db).getByUserId(entity.strValue!),
_ => null,
} as T?;
@@ -101,10 +95,7 @@ class IsarStoreRepository extends IsarDatabaseRepository {
}
Future<List<StoreDto<Object>>> getAll() async {
final entities = await _db.storeValues
.filter()
.anyOf(validStoreKeys, (query, id) => query.idEqualTo(id))
.findAll();
final entities = await _db.storeValues.filter().anyOf(validStoreKeys, (query, id) => query.idEqualTo(id)).findAll();
return Future.wait(entities.map((e) => _toUpdateEvent(e)).toList());
}
}

View File

@@ -41,6 +41,7 @@ class SyncApiRepository {
request.body = jsonEncode(
SyncStreamDto(
types: [
SyncRequestType.authUsersV1,
SyncRequestType.usersV1,
SyncRequestType.assetsV1,
SyncRequestType.assetExifsV1,
@@ -112,8 +113,7 @@ class SyncApiRepository {
client.close();
}
stopwatch.stop();
_logger
.info("Remote Sync completed in ${stopwatch.elapsed.inMilliseconds}ms");
_logger.info("Remote Sync completed in ${stopwatch.elapsed.inMilliseconds}ms");
DLog.log("Remote Sync completed in ${stopwatch.elapsed.inMilliseconds}ms");
}
@@ -139,6 +139,7 @@ class SyncApiRepository {
}
const _kResponseMap = <SyncEntityType, Function(Object)>{
SyncEntityType.authUserV1: SyncAuthUserV1.fromJson,
SyncEntityType.userV1: SyncUserV1.fromJson,
SyncEntityType.userDeleteV1: SyncUserDeleteV1.fromJson,
SyncEntityType.partnerV1: SyncPartnerV1.fromJson,

View File

@@ -6,6 +6,7 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
import 'package:immich_mobile/domain/models/memory.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
import 'package:immich_mobile/infrastructure/entities/asset_face.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart';
@@ -29,10 +30,41 @@ class SyncStreamRepository extends DriftDatabaseRepository {
SyncStreamRepository(super.db) : _db = db;
Future<void> updateAuthUsersV1(Iterable<SyncAuthUserV1> data) async {
try {
await _db.batch((batch) {
for (final authUser in data) {
final companion = AuthUserEntityCompanion(
name: Value(authUser.name),
email: Value(authUser.email),
deletedAt: Value(authUser.deletedAt),
avatarColor: Value(authUser.avatarColor?.toAvatarColor()),
isAdmin: Value(authUser.isAdmin),
oauthId: Value(authUser.oauthId),
pinCode: Value(authUser.pinCode),
hasProfileImage: Value(authUser.hasProfileImage),
profileChangedAt: Value(authUser.profileChangedAt),
quotaSizeInBytes: Value(authUser.quotaSizeInBytes),
quotaUsageInBytes: Value(authUser.quotaUsageInBytes),
storageLabel: Value(authUser.storageLabel),
);
batch.insert(
_db.authUserEntity,
companion.copyWith(id: Value(authUser.id)),
onConflict: DoUpdate((_) => companion),
);
}
});
} catch (error, stack) {
_logger.severe('Error: SyncAuthUserV1', error, stack);
rethrow;
}
}
Future<void> deleteUsersV1(Iterable<SyncUserDeleteV1> data) async {
try {
await _db.userEntity
.deleteWhere((row) => row.id.isIn(data.map((e) => e.userId)));
await _db.userEntity.deleteWhere((row) => row.id.isIn(data.map((e) => e.userId)));
} catch (error, stack) {
_logger.severe('Error: SyncUserDeleteV1', error, stack);
rethrow;
@@ -46,6 +78,8 @@ class SyncStreamRepository extends DriftDatabaseRepository {
final companion = UserEntityCompanion(
name: Value(user.name),
email: Value(user.email),
deletedAt: Value(user.deletedAt),
avatarColor: Value(user.avatarColor?.toAvatarColor()),
);
batch.insert(
@@ -84,8 +118,7 @@ class SyncStreamRepository extends DriftDatabaseRepository {
try {
await _db.batch((batch) {
for (final partner in data) {
final companion =
PartnerEntityCompanion(inTimeline: Value(partner.inTimeline));
final companion = PartnerEntityCompanion(inTimeline: Value(partner.inTimeline));
batch.insert(
_db.partnerEntity,
@@ -129,8 +162,7 @@ class SyncStreamRepository extends DriftDatabaseRepository {
type: Value(asset.type.toAssetType()),
createdAt: Value.absentIfNull(asset.fileCreatedAt),
updatedAt: Value.absentIfNull(asset.fileModifiedAt),
durationInSeconds:
Value(asset.duration?.toDuration()?.inSeconds ?? 0),
durationInSeconds: Value(asset.duration?.toDuration()?.inSeconds ?? 0),
checksum: Value(asset.checksum),
isFavorite: Value(asset.isFavorite),
ownerId: Value(asset.ownerId),
@@ -607,6 +639,22 @@ class SyncStreamRepository extends DriftDatabaseRepository {
}
}
extension on UserAvatarColor {
AvatarColor toAvatarColor() => switch (this) {
UserAvatarColor.amber => AvatarColor.amber,
UserAvatarColor.blue => AvatarColor.blue,
UserAvatarColor.gray => AvatarColor.gray,
UserAvatarColor.green => AvatarColor.green,
UserAvatarColor.orange => AvatarColor.orange,
UserAvatarColor.pink => AvatarColor.pink,
UserAvatarColor.primary => AvatarColor.primary,
UserAvatarColor.purple => AvatarColor.purple,
UserAvatarColor.red => AvatarColor.red,
UserAvatarColor.yellow => AvatarColor.yellow,
_ => throw Exception('Unknown AvatarColor value: $this'),
};
}
extension on AssetTypeEnum {
AssetType toAssetType() => switch (this) {
AssetTypeEnum.IMAGE => AssetType.image,
@@ -662,9 +710,7 @@ extension on String {
extension on String {
Duration? toDuration() {
try {
final parts = split(':')
.map((e) => double.parse(e).toInt())
.toList(growable: false);
final parts = split(':').map((e) => double.parse(e).toInt()).toList(growable: false);
return Duration(hours: parts[0], minutes: parts[1], seconds: parts[2]);
} catch (_) {

View File

@@ -22,8 +22,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
final query = _db.partnerEntity.selectOnly()
..addColumns([_db.partnerEntity.sharedById])
..where(
_db.partnerEntity.inTimeline.equals(true) &
_db.partnerEntity.sharedWithId.equals(userId),
_db.partnerEntity.inTimeline.equals(true) & _db.partnerEntity.sharedWithId.equals(userId),
);
return query
@@ -173,8 +172,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
),
leftOuterJoin(
_db.remoteAssetEntity,
_db.localAssetEntity.checksum
.equalsExp(_db.remoteAssetEntity.checksum),
_db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum),
useColumns: false,
),
],
@@ -219,10 +217,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
});
}
return (_db.remoteAlbumEntity.select()
..where((row) => row.id.equals(albumId)))
.watch()
.switchMap((albums) {
return (_db.remoteAlbumEntity.select()..where((row) => row.id.equals(albumId))).watch().switchMap((albums) {
if (albums.isEmpty) {
return Stream.value(<Bucket>[]);
}
@@ -237,14 +232,12 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
..join([
innerJoin(
_db.remoteAlbumAssetEntity,
_db.remoteAlbumAssetEntity.assetId
.equalsExp(_db.remoteAssetEntity.id),
_db.remoteAlbumAssetEntity.assetId.equalsExp(_db.remoteAssetEntity.id),
useColumns: false,
),
])
..where(
_db.remoteAssetEntity.deletedAt.isNull() &
_db.remoteAlbumAssetEntity.albumId.equals(albumId),
_db.remoteAssetEntity.deletedAt.isNull() & _db.remoteAlbumAssetEntity.albumId.equals(albumId),
)
..groupBy([dateExp]);
@@ -270,9 +263,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
required int offset,
required int count,
}) async {
final albumData = await (_db.remoteAlbumEntity.select()
..where((row) => row.id.equals(albumId)))
.getSingleOrNull();
final albumData = await _db.managers.remoteAlbumEntity.filter((row) => row.id.equals(albumId)).getSingleOrNull();
// If album doesn't exist (was deleted), return empty list
if (albumData == null) {
@@ -285,14 +276,12 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
[
innerJoin(
_db.remoteAlbumAssetEntity,
_db.remoteAlbumAssetEntity.assetId
.equalsExp(_db.remoteAssetEntity.id),
_db.remoteAlbumAssetEntity.assetId.equalsExp(_db.remoteAssetEntity.id),
useColumns: false,
),
],
)..where(
_db.remoteAssetEntity.deletedAt.isNull() &
_db.remoteAlbumAssetEntity.albumId.equals(albumId),
_db.remoteAssetEntity.deletedAt.isNull() & _db.remoteAlbumAssetEntity.albumId.equals(albumId),
);
if (isAscending) {
@@ -303,62 +292,44 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
query.limit(count, offset: offset);
return query
.map((row) => row.readTable(_db.remoteAssetEntity).toDto())
.get();
return query.map((row) => row.readTable(_db.remoteAssetEntity).toDto()).get();
}
TimelineQuery fromAssets(List<BaseAsset> assets) => (
bucketSource: () => Stream.value(_generateBuckets(assets.length)),
assetSource: (offset, count) =>
Future.value(assets.skip(offset).take(count).toList()),
assetSource: (offset, count) => Future.value(assets.skip(offset).take(count).toList()),
);
TimelineQuery remote(String ownerId, GroupAssetsBy groupBy) =>
_remoteQueryBuilder(
TimelineQuery remote(String ownerId, GroupAssetsBy groupBy) => _remoteQueryBuilder(
filter: (row) =>
row.deletedAt.isNull() &
row.visibility.equalsValue(AssetVisibility.timeline) &
row.ownerId.equals(ownerId),
row.deletedAt.isNull() & row.visibility.equalsValue(AssetVisibility.timeline) & row.ownerId.equals(ownerId),
groupBy: groupBy,
);
TimelineQuery favorite(String userId, GroupAssetsBy groupBy) =>
_remoteQueryBuilder(
filter: (row) =>
row.deletedAt.isNull() &
row.isFavorite.equals(true) &
row.ownerId.equals(userId),
TimelineQuery favorite(String userId, GroupAssetsBy groupBy) => _remoteQueryBuilder(
filter: (row) => row.deletedAt.isNull() & row.isFavorite.equals(true) & row.ownerId.equals(userId),
groupBy: groupBy,
);
TimelineQuery trash(String userId, GroupAssetsBy groupBy) =>
_remoteQueryBuilder(
TimelineQuery trash(String userId, GroupAssetsBy groupBy) => _remoteQueryBuilder(
filter: (row) => row.deletedAt.isNotNull() & row.ownerId.equals(userId),
groupBy: groupBy,
joinLocal: true,
);
TimelineQuery archived(String userId, GroupAssetsBy groupBy) =>
_remoteQueryBuilder(
TimelineQuery archived(String userId, GroupAssetsBy groupBy) => _remoteQueryBuilder(
filter: (row) =>
row.deletedAt.isNull() &
row.ownerId.equals(userId) &
row.visibility.equalsValue(AssetVisibility.archive),
row.deletedAt.isNull() & row.ownerId.equals(userId) & row.visibility.equalsValue(AssetVisibility.archive),
groupBy: groupBy,
);
TimelineQuery locked(String userId, GroupAssetsBy groupBy) =>
_remoteQueryBuilder(
TimelineQuery locked(String userId, GroupAssetsBy groupBy) => _remoteQueryBuilder(
filter: (row) =>
row.deletedAt.isNull() &
row.visibility.equalsValue(AssetVisibility.locked) &
row.ownerId.equals(userId),
row.deletedAt.isNull() & row.visibility.equalsValue(AssetVisibility.locked) & row.ownerId.equals(userId),
groupBy: groupBy,
);
TimelineQuery video(String userId, GroupAssetsBy groupBy) =>
_remoteQueryBuilder(
TimelineQuery video(String userId, GroupAssetsBy groupBy) => _remoteQueryBuilder(
filter: (row) =>
row.deletedAt.isNull() &
row.type.equalsValue(AssetType.video) &
@@ -405,8 +376,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
..where(
_db.remoteExifEntity.city.equals(place) &
_db.remoteAssetEntity.deletedAt.isNull() &
_db.remoteAssetEntity.visibility
.equalsValue(AssetVisibility.timeline),
_db.remoteAssetEntity.visibility.equalsValue(AssetVisibility.timeline),
)
..groupBy([dateExp])
..orderBy([OrderingTerm.desc(dateExp)]);
@@ -434,15 +404,12 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
)
..where(
_db.remoteAssetEntity.deletedAt.isNull() &
_db.remoteAssetEntity.visibility
.equalsValue(AssetVisibility.timeline) &
_db.remoteAssetEntity.visibility.equalsValue(AssetVisibility.timeline) &
_db.remoteExifEntity.city.equals(place),
)
..orderBy([OrderingTerm.desc(_db.remoteAssetEntity.createdAt)])
..limit(count, offset: offset);
return query
.map((row) => row.readTable(_db.remoteAssetEntity).toDto())
.get();
return query.map((row) => row.readTable(_db.remoteAssetEntity).toDto()).get();
}
TimelineQuery _remoteQueryBuilder({
@@ -496,8 +463,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
final query = _db.remoteAssetEntity.select().join([
leftOuterJoin(
_db.localAssetEntity,
_db.remoteAssetEntity.checksum
.equalsExp(_db.localAssetEntity.checksum),
_db.remoteAssetEntity.checksum.equalsExp(_db.localAssetEntity.checksum),
useColumns: false,
),
])
@@ -539,7 +505,7 @@ extension on Expression<DateTime> {
// to create the correct time bucket
final localTimeExp = modify(const DateTimeModifier.localTime());
return switch (groupBy) {
GroupAssetsBy.day => localTimeExp.date,
GroupAssetsBy.day || GroupAssetsBy.auto => localTimeExp.date,
GroupAssetsBy.month => localTimeExp.strftime("%Y-%m"),
GroupAssetsBy.none => throw ArgumentError(
"GroupAssetsBy.none is not supported for date formatting",
@@ -551,7 +517,7 @@ extension on Expression<DateTime> {
extension on String {
DateTime dateFmt(GroupAssetsBy groupBy) {
final format = switch (groupBy) {
GroupAssetsBy.day => "y-M-d",
GroupAssetsBy.day || GroupAssetsBy.auto => "y-M-d",
GroupAssetsBy.month => "y-M",
GroupAssetsBy.none => throw ArgumentError(
"GroupAssetsBy.none is not supported for date formatting",

View File

@@ -1,7 +1,6 @@
import 'package:immich_mobile/constants/enums.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/infrastructure/entities/user.entity.dart'
as entity;
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as entity;
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
import 'package:isar/isar.dart';
@@ -11,18 +10,18 @@ class IsarUserRepository extends IsarDatabaseRepository {
Future<void> delete(List<String> ids) async {
await transaction(() async {
await _db.users.deleteAllById(ids);
await _db.isarUsers.deleteAllById(ids);
});
}
Future<void> deleteAll() async {
await transaction(() async {
await _db.users.clear();
await _db.isarUsers.clear();
});
}
Future<List<UserDto>> getAll({SortUserBy? sortBy}) async {
return (await _db.users
return (await _db.isarUsers
.where()
.optional(
sortBy != null,
@@ -36,31 +35,44 @@ class IsarUserRepository extends IsarDatabaseRepository {
}
Future<UserDto?> getByUserId(String id) async {
return (await _db.users.getById(id))?.toDto();
return (await _db.isarUsers.getById(id))?.toDto();
}
Future<List<UserDto?>> getByUserIds(List<String> ids) async {
return (await _db.users.getAllById(ids)).map((u) => u?.toDto()).toList();
return (await _db.isarUsers.getAllById(ids)).map((u) => u?.toDto()).toList();
}
Future<bool> insert(UserDto user) async {
await transaction(() async {
await _db.users.put(entity.User.fromDto(user));
await _db.isarUsers.put(entity.IsarUser.fromDto(user));
});
return true;
}
Future<UserDto> update(UserDto user) async {
await transaction(() async {
await _db.users.put(entity.User.fromDto(user));
await _db.isarUsers.put(entity.IsarUser.fromDto(user));
});
return user;
}
Future<bool> updateAll(List<UserDto> users) async {
await transaction(() async {
await _db.users.putAll(users.map(entity.User.fromDto).toList());
await _db.isarUsers.putAll(users.map(entity.IsarUser.fromDto).toList());
});
return true;
}
}
class DriftUserRepository extends DriftDatabaseRepository {
final Drift _db;
const DriftUserRepository(this._db) : super(_db);
Future<List<User>> getAll() {
return _db.managers.userEntity.orderBy((row) => row.id.asc()).map((row) => row.toDto()).get();
}
Future<User?> getById(String id) {
return _db.managers.userEntity.filter((row) => row.id.equals(id)).map((row) => row.toDto()).getSingleOrNull();
}
}

View File

@@ -11,8 +11,7 @@ class UserApiRepository extends ApiRepository {
const UserApiRepository(this._api);
Future<UserDto?> getMyUser() async {
final (adminDto, preferenceDto) =
await (_api.getMyUser(), _api.getMyPreferences()).wait;
final (adminDto, preferenceDto) = await (_api.getMyUser(), _api.getMyPreferences()).wait;
if (adminDto == null) return null;
return UserConverter.fromAdminDto(adminDto, preferenceDto);

View File

@@ -8,8 +8,7 @@ class DriftUserMetadataRepository extends DriftDatabaseRepository {
const DriftUserMetadataRepository(this._db) : super(_db);
Future<List<UserMetadata>> getUserMetadata(String userId) {
final query = _db.userMetadataEntity.select()
..where((e) => e.userId.equals(userId));
final query = _db.userMetadataEntity.select()..where((e) => e.userId.equals(userId));
return query.map((userMetadata) {
return userMetadata.toDto();

View File

@@ -126,8 +126,7 @@ class ImmichApp extends ConsumerStatefulWidget {
ImmichAppState createState() => ImmichAppState();
}
class ImmichAppState extends ConsumerState<ImmichApp>
with WidgetsBindingObserver {
class ImmichAppState extends ConsumerState<ImmichApp> with WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
@@ -168,9 +167,7 @@ class ImmichAppState extends ConsumerState<ImmichApp>
// Android 8 does not support transparent app bars
final info = await DeviceInfoPlugin().androidInfo;
if (info.version.sdkInt <= 26) {
overlayStyle = context.isDarkTheme
? SystemUiOverlayStyle.dark
: SystemUiOverlayStyle.light;
overlayStyle = context.isDarkTheme ? SystemUiOverlayStyle.dark : SystemUiOverlayStyle.light;
}
}
SystemChrome.setSystemUIOverlayStyle(overlayStyle);
@@ -222,8 +219,7 @@ class ImmichAppState extends ConsumerState<ImmichApp>
final deepLinkHandler = ref.read(deepLinkServiceProvider);
final currentRouteName = ref.read(currentRouteNameProvider.notifier).state;
final isColdStart =
currentRouteName == null || currentRouteName == SplashScreenRoute.name;
final isColdStart = currentRouteName == null || currentRouteName == SplashScreenRoute.name;
if (deepLink.uri.scheme == "immich") {
final proposedRoute = await deepLinkHandler.handleScheme(
@@ -299,8 +295,7 @@ class ImmichAppState extends ConsumerState<ImmichApp>
),
routerConfig: router.config(
deepLinkBuilder: _deepLinkBuilder,
navigatorObservers: () =>
[AppNavigationObserver(ref: ref), HeroController()],
navigatorObservers: () => [AppNavigationObserver(ref: ref), HeroController()],
),
),
);

View File

@@ -56,12 +56,7 @@ class Activity {
@override
int get hashCode {
return id.hashCode ^
assetId.hashCode ^
comment.hashCode ^
createdAt.hashCode ^
type.hashCode ^
user.hashCode;
return id.hashCode ^ assetId.hashCode ^ comment.hashCode ^ createdAt.hashCode ^ type.hashCode ^ user.hashCode;
}
}

View File

@@ -32,16 +32,14 @@ class AlbumAddAssetsResponse {
String toJson() => json.encode(toMap());
@override
String toString() =>
'AddAssetsResponse(alreadyInAlbum: $alreadyInAlbum, successfullyAdded: $successfullyAdded)';
String toString() => 'AddAssetsResponse(alreadyInAlbum: $alreadyInAlbum, successfullyAdded: $successfullyAdded)';
@override
bool operator ==(covariant AlbumAddAssetsResponse other) {
if (identical(this, other)) return true;
final listEquals = const DeepCollectionEquality().equals;
return listEquals(other.alreadyInAlbum, alreadyInAlbum) &&
other.successfullyAdded == successfullyAdded;
return listEquals(other.alreadyInAlbum, alreadyInAlbum) && other.successfullyAdded == successfullyAdded;
}
@override

Some files were not shown because too many files have changed in this diff Show More