Merge remote-tracking branch 'public/main' into feature/sync_assets_trashed_state

# Conflicts:
#	mobile/drift_schemas/main/drift_schema_v10.json
#	mobile/lib/infrastructure/repositories/db.repository.dart
#	mobile/lib/infrastructure/repositories/db.repository.drift.dart
#	mobile/lib/infrastructure/repositories/db.repository.steps.dart
#	mobile/test/drift/main/generated/schema_v10.dart
This commit is contained in:
Peter Ombodi 2025-09-09 19:06:33 +03:00
commit a2f726e8e7
32 changed files with 1904 additions and 721 deletions

View file

@ -21,16 +21,23 @@ jobs:
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
run: | run: |
set -euo pipefail
gh pr list --repo $GITHUB_REPOSITORY --author weblate --json number,mergeable | read PR gh pr list --repo $GITHUB_REPOSITORY --author weblate --json number,mergeable | read PR
echo "$PR"
echo "$PR" | jq ' echo "$PR" | jq '
if length == 1 then if length == 1 then
.[0].number .[0].number
else else
error("Expected exactly 1 entry, got \(length)") error("Expected exactly 1 entry, got \(length)")
end end
' | read PR_NUMBER ' 2>&1 | read PR_NUMBER || exit 1
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "$PR" | jq -e '.[0].mergeable == "MERGEABLE"' || (echo "PR is not mergeable" && exit 1) echo "Selected PR $PR_NUMBER"
echo "$PR" | jq -e '.[0].mergeable == "MERGEABLE"' || { echo "PR is not mergeable" ; exit 1 }
- name: Generate a token - name: Generate a token
id: generate_token id: generate_token

View file

@ -39,7 +39,7 @@ jobs:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
run: | run: |
# Then check for APPROVED by the bot, if absent fail # Then check for APPROVED by the bot, if absent fail
gh pr view "$PR_NUMBER" --json reviews | jq -e '.reviews | map(select(.author.login == "github-actions[bot]" and .state == "APPROVED")) | length > 0' \ gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json reviews | jq -e '.reviews | map(select(.author.login == "github-actions[bot]" and .state == "APPROVED")) | length > 0' \
|| (echo "The push-o-matic bot has not approved this PR yet" && exit 1) || (echo "The push-o-matic bot has not approved this PR yet" && exit 1)
success-check-lock: success-check-lock:

View file

@ -2,37 +2,37 @@
# Manual edits may be lost in future updates. # Manual edits may be lost in future updates.
provider "registry.opentofu.org/cloudflare/cloudflare" { provider "registry.opentofu.org/cloudflare/cloudflare" {
version = "4.52.1" version = "4.52.3"
constraints = "4.52.1" constraints = "4.52.3"
hashes = [ hashes = [
"h1:2lHvafwGbLdmc9lYkuJFw3nsInaQjRpjX/JfIRKmq/M=", "h1:3jU62KY4Oj3xzMwkTQWon1nlIvFkgTCqI93IzUGaa0c=",
"h1:596JomwjrtUrOSreq9NNCS+rj70+jOV+0pfja5MXiTI=", "h1:BWimtYXrvbzbbuoVcyobjQnXjjOb9X69JFTw+GuPxfk=",
"h1:7mBOA5TVAIt3qAwPXKCtE0RSYeqij9v30mnksuBbpEg=", "h1:C/KvLEm8dVQ6zG2X4asLDtmw2JW/xu7E8MddtaXniO0=",
"h1:ELVgzh4kHKBCYdL+2A8JjWS0E1snLUN3Mmz3Vo6qSfw=", "h1:Doo0xcLFf+CnfDWjsA7G1NvSLURuwcgyVy8k0NF1gJA=",
"h1:FGGM5yLFf72g3kSXM3LAN64Gf/AkXr5WCmhixgnP+l4=", "h1:Gc3FGDtR8lUWsi9VImnnE5/USDXiIwYsv4Hbl+d2lwY=",
"h1:JupkJbQALcIVoMhHImrLeLDsQR1ET7VJLGC7ONxjqGU=", "h1:HsDY6s1gup5fW9TeuTUy85QMIld1nDOUFlwsfxIq1ig=",
"h1:KsaE4JNq+1uV1nJsuTcYar/8lyY6zKS5UBEpfYg3wvc=", "h1:MnHkB56E4b/kT6WZigsZJnB5rgnCfDVbrLBNxIsEXPY=",
"h1:NHZ5RJIzQDLhie/ykl3uI6UPfNQR9Lu5Ti7JPR6X904=", "h1:O/FUQEqhtknJNdsaMbIBi2pLWBds2VvN5FsTVVntzb0=",
"h1:NfAuMbn6LQPLDtJhbzO1MX9JMIGLMa8K6CpekvtsuX8=", "h1:OKQBynkp0J5DIf5FOl/NR3S2rvh89pY+t5wevYxdTJs=",
"h1:e+vNKokamDsp/kJvFr2pRudzwEz2r49iZ/oSggw+1LY=", "h1:On+vPsYV8U/J/8wFZPXjeAgNJqFFQj42vNOKuNKURkY=",
"h1:jnb4VdfNZ79I3yj7Q8x+JmOT+FxbfjjRfrF0dL0yCW8=", "h1:SPkrMRJahxK0uum7FnUugbGN/JepHMH8M71DBtYrvG0=",
"h1:kmF//O539d7NuHU7qIxDj7Wz4eJmLKFiI5glwQivldU=", "h1:bEh1ASPMiin3F36+hTfjMQTBnuDl2DzjzSCdova3JEM=",
"h1:s6XriaKwOgV4jvKAGPXkrxhhOQxpNU5dceZwi9Z/1k8=", "h1:dtIK+x5Q1sh5SMPaHBHXhL9XDIqbRW0EBmVZ+KHQB8E=",
"h1:wt3WBEBAeSGTlC9OlnTlAALxRiK4SQgLy0KgBIS7qzs=", "h1:kZcwWfODMWWyauZ66oaO/X+xXkqBtrbYwfUFEtspwEc=",
"zh:2fb95e1d3229b9b6c704e1a413c7481c60f139780d9641f657b6eb9b633b90f2", "zh:53946fce4a631f1d98c61550821c88edede9169dfe5cc254e09a2ab207f76b3f",
"zh:379c7680983383862236e9e6e720c3114195c40526172188e88d0ffcf50dfe2e", "zh:61654a21f1dd4331492d4ef77e9ebff066bc01e1281f92b925e5697c9138d681",
"zh:55533beb6cfc02d22ffda8cba8027bc2c841bb172cd637ed0d28323d41395f8f", "zh:6a54e9d129b276f052a2f1b73ad0b8735fe6a7403c6a8f6aa111e525eeefaf35",
"zh:5abd70760e4eb1f37a1c307cbd2989ea7c9ba0afb93818c67c1d363a31f75703", "zh:7692374e655c346a630b5a7cd776c5e0b2388900dcd7ab69a3af85d0c31c6c43",
"zh:699f1c8cd66129176fe659ebf0e6337632a8967a28d2630b6ae5948665c0c2ae",
"zh:69c15acd73c451e89de6477059cda2f3ec200b48ae4b9ff3646c4d389fd3205e",
"zh:6e02b687de21b844f8266dff99e93e7c61fc8eb688f4bbb23803caceb251839e",
"zh:7a51d17b87ed87b7bebf2ad9fc7c3a74f16a1b44eee92c779c08eb89258c0496",
"zh:88ad84436837b0f55302f22748505972634e87400d6902260fd6b7ba1610f937",
"zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f",
"zh:8d46c3d9f4f7ad20ac6ef01daa63f4e30a2d16dcb1bb5c7c7ee3dc6be38e9ca1", "zh:8fe5b792a4d2b1c3a0e573649642962494faa00299baa6aaf813b9a43203dc02",
"zh:913d64e72a4929dae1d4793e2004f4f9a58b138ea337d9d94fa35cafbf06550a", "zh:a0f403a4862df90f09de65c6e939d6cfd069a8dda2dd33f82948bf6f5f1124ef",
"zh:c8d93cf86e2e49f6cec665cfe78b82c144cce15a8b2e30f343385fadd1251849", "zh:a25dc3eb60777b600f8f125d321fe7c50b811c5302b58e9a727ceb749a04e35d",
"zh:cc4f69397d9bc34a528a5609a024c3a48f54f21616c0008792dd417297add955", "zh:a2f2ac7dc703c69d2e8c67c9cb5620b5348cb4fd6b98515fbe3f478517b56602",
"zh:df99cdb8b064aad35ffea77e645cf6541d0b1b2ebc51b6d26c42031de60ab69e", "zh:d452e7bd24445ee14166470cf50f3aca566d46cab5f26f1c5c988c0f3106b697",
"zh:e10a52b0294735659eb3f0821ad2006ec097918efe58d31d37a5e3c47efef5f6",
"zh:e28dd0954cef9f05adf4d4b440d6f134f605344dfa56307181996675e6550af2",
"zh:f1e3b2f43a472280442f01ba71a3c06c9167432e553381132ea5c4a77e0b6dd5",
"zh:f71fd63718d38fd43829861e91fe79e16d7b4c7c3d508ae3d077368d89b8e5a0",
"zh:faf8d3da4b819c4ae8e565d2b1a684c6a948a086cb299189a5e7b30b2178409d",
] ]
} }

View file

@ -5,7 +5,7 @@ terraform {
required_providers { required_providers {
cloudflare = { cloudflare = {
source = "cloudflare/cloudflare" source = "cloudflare/cloudflare"
version = "4.52.1" version = "4.52.3"
} }
} }
} }

View file

@ -2,37 +2,37 @@
# Manual edits may be lost in future updates. # Manual edits may be lost in future updates.
provider "registry.opentofu.org/cloudflare/cloudflare" { provider "registry.opentofu.org/cloudflare/cloudflare" {
version = "4.52.1" version = "4.52.3"
constraints = "4.52.1" constraints = "4.52.3"
hashes = [ hashes = [
"h1:2lHvafwGbLdmc9lYkuJFw3nsInaQjRpjX/JfIRKmq/M=", "h1:3jU62KY4Oj3xzMwkTQWon1nlIvFkgTCqI93IzUGaa0c=",
"h1:596JomwjrtUrOSreq9NNCS+rj70+jOV+0pfja5MXiTI=", "h1:BWimtYXrvbzbbuoVcyobjQnXjjOb9X69JFTw+GuPxfk=",
"h1:7mBOA5TVAIt3qAwPXKCtE0RSYeqij9v30mnksuBbpEg=", "h1:C/KvLEm8dVQ6zG2X4asLDtmw2JW/xu7E8MddtaXniO0=",
"h1:ELVgzh4kHKBCYdL+2A8JjWS0E1snLUN3Mmz3Vo6qSfw=", "h1:Doo0xcLFf+CnfDWjsA7G1NvSLURuwcgyVy8k0NF1gJA=",
"h1:FGGM5yLFf72g3kSXM3LAN64Gf/AkXr5WCmhixgnP+l4=", "h1:Gc3FGDtR8lUWsi9VImnnE5/USDXiIwYsv4Hbl+d2lwY=",
"h1:JupkJbQALcIVoMhHImrLeLDsQR1ET7VJLGC7ONxjqGU=", "h1:HsDY6s1gup5fW9TeuTUy85QMIld1nDOUFlwsfxIq1ig=",
"h1:KsaE4JNq+1uV1nJsuTcYar/8lyY6zKS5UBEpfYg3wvc=", "h1:MnHkB56E4b/kT6WZigsZJnB5rgnCfDVbrLBNxIsEXPY=",
"h1:NHZ5RJIzQDLhie/ykl3uI6UPfNQR9Lu5Ti7JPR6X904=", "h1:O/FUQEqhtknJNdsaMbIBi2pLWBds2VvN5FsTVVntzb0=",
"h1:NfAuMbn6LQPLDtJhbzO1MX9JMIGLMa8K6CpekvtsuX8=", "h1:OKQBynkp0J5DIf5FOl/NR3S2rvh89pY+t5wevYxdTJs=",
"h1:e+vNKokamDsp/kJvFr2pRudzwEz2r49iZ/oSggw+1LY=", "h1:On+vPsYV8U/J/8wFZPXjeAgNJqFFQj42vNOKuNKURkY=",
"h1:jnb4VdfNZ79I3yj7Q8x+JmOT+FxbfjjRfrF0dL0yCW8=", "h1:SPkrMRJahxK0uum7FnUugbGN/JepHMH8M71DBtYrvG0=",
"h1:kmF//O539d7NuHU7qIxDj7Wz4eJmLKFiI5glwQivldU=", "h1:bEh1ASPMiin3F36+hTfjMQTBnuDl2DzjzSCdova3JEM=",
"h1:s6XriaKwOgV4jvKAGPXkrxhhOQxpNU5dceZwi9Z/1k8=", "h1:dtIK+x5Q1sh5SMPaHBHXhL9XDIqbRW0EBmVZ+KHQB8E=",
"h1:wt3WBEBAeSGTlC9OlnTlAALxRiK4SQgLy0KgBIS7qzs=", "h1:kZcwWfODMWWyauZ66oaO/X+xXkqBtrbYwfUFEtspwEc=",
"zh:2fb95e1d3229b9b6c704e1a413c7481c60f139780d9641f657b6eb9b633b90f2", "zh:53946fce4a631f1d98c61550821c88edede9169dfe5cc254e09a2ab207f76b3f",
"zh:379c7680983383862236e9e6e720c3114195c40526172188e88d0ffcf50dfe2e", "zh:61654a21f1dd4331492d4ef77e9ebff066bc01e1281f92b925e5697c9138d681",
"zh:55533beb6cfc02d22ffda8cba8027bc2c841bb172cd637ed0d28323d41395f8f", "zh:6a54e9d129b276f052a2f1b73ad0b8735fe6a7403c6a8f6aa111e525eeefaf35",
"zh:5abd70760e4eb1f37a1c307cbd2989ea7c9ba0afb93818c67c1d363a31f75703", "zh:7692374e655c346a630b5a7cd776c5e0b2388900dcd7ab69a3af85d0c31c6c43",
"zh:699f1c8cd66129176fe659ebf0e6337632a8967a28d2630b6ae5948665c0c2ae",
"zh:69c15acd73c451e89de6477059cda2f3ec200b48ae4b9ff3646c4d389fd3205e",
"zh:6e02b687de21b844f8266dff99e93e7c61fc8eb688f4bbb23803caceb251839e",
"zh:7a51d17b87ed87b7bebf2ad9fc7c3a74f16a1b44eee92c779c08eb89258c0496",
"zh:88ad84436837b0f55302f22748505972634e87400d6902260fd6b7ba1610f937",
"zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f",
"zh:8d46c3d9f4f7ad20ac6ef01daa63f4e30a2d16dcb1bb5c7c7ee3dc6be38e9ca1", "zh:8fe5b792a4d2b1c3a0e573649642962494faa00299baa6aaf813b9a43203dc02",
"zh:913d64e72a4929dae1d4793e2004f4f9a58b138ea337d9d94fa35cafbf06550a", "zh:a0f403a4862df90f09de65c6e939d6cfd069a8dda2dd33f82948bf6f5f1124ef",
"zh:c8d93cf86e2e49f6cec665cfe78b82c144cce15a8b2e30f343385fadd1251849", "zh:a25dc3eb60777b600f8f125d321fe7c50b811c5302b58e9a727ceb749a04e35d",
"zh:cc4f69397d9bc34a528a5609a024c3a48f54f21616c0008792dd417297add955", "zh:a2f2ac7dc703c69d2e8c67c9cb5620b5348cb4fd6b98515fbe3f478517b56602",
"zh:df99cdb8b064aad35ffea77e645cf6541d0b1b2ebc51b6d26c42031de60ab69e", "zh:d452e7bd24445ee14166470cf50f3aca566d46cab5f26f1c5c988c0f3106b697",
"zh:e10a52b0294735659eb3f0821ad2006ec097918efe58d31d37a5e3c47efef5f6",
"zh:e28dd0954cef9f05adf4d4b440d6f134f605344dfa56307181996675e6550af2",
"zh:f1e3b2f43a472280442f01ba71a3c06c9167432e553381132ea5c4a77e0b6dd5",
"zh:f71fd63718d38fd43829861e91fe79e16d7b4c7c3d508ae3d077368d89b8e5a0",
"zh:faf8d3da4b819c4ae8e565d2b1a684c6a948a086cb299189a5e7b30b2178409d",
] ]
} }

View file

@ -5,7 +5,7 @@ terraform {
required_providers { required_providers {
cloudflare = { cloudflare = {
source = "cloudflare/cloudflare" source = "cloudflare/cloudflare"
version = "4.52.1" version = "4.52.3"
} }
} }
} }

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,36 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first // ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert'; import 'dart:convert';
import 'dart:ui';
import 'package:immich_mobile/domain/models/user_metadata.model.dart'; enum AvatarColor {
// do not change this order or reuse indices for other purposes, adding is OK
primary("primary"),
pink("pink"),
red("red"),
yellow("yellow"),
blue("blue"),
green("green"),
purple("purple"),
orange("orange"),
gray("gray"),
amber("amber");
final String value;
const AvatarColor(this.value);
Color toColor({bool isDarkTheme = false}) => switch (this) {
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),
AvatarColor.blue => const Color.fromARGB(255, 59, 130, 246),
AvatarColor.green => const Color.fromARGB(255, 22, 163, 74),
AvatarColor.purple => const Color.fromARGB(255, 147, 51, 234),
AvatarColor.orange => const Color.fromARGB(255, 234, 88, 12),
AvatarColor.gray => const Color.fromARGB(255, 75, 85, 99),
AvatarColor.amber => const Color.fromARGB(255, 217, 119, 6),
};
}
// TODO: Rename to User once Isar is removed // TODO: Rename to User once Isar is removed
class UserDto { class UserDto {
@ -9,7 +38,7 @@ class UserDto {
final String email; final String email;
final String name; final String name;
final bool isAdmin; final bool isAdmin;
final DateTime updatedAt; final DateTime? updatedAt;
final AvatarColor avatarColor; final AvatarColor avatarColor;
@ -31,8 +60,8 @@ class UserDto {
required this.id, required this.id,
required this.email, required this.email,
required this.name, required this.name,
required this.isAdmin, this.isAdmin = false,
required this.updatedAt, this.updatedAt,
required this.profileChangedAt, required this.profileChangedAt,
this.avatarColor = AvatarColor.primary, this.avatarColor = AvatarColor.primary,
this.memoryEnabled = true, this.memoryEnabled = true,
@ -99,7 +128,8 @@ profileChangedAt: $profileChangedAt
if (identical(this, other)) return true; if (identical(this, other)) return true;
return other.id == id && return other.id == id &&
other.updatedAt.isAtSameMomentAs(updatedAt) && ((updatedAt == null && other.updatedAt == null) ||
(updatedAt != null && other.updatedAt != null && other.updatedAt!.isAtSameMomentAs(updatedAt!))) &&
other.avatarColor == avatarColor && other.avatarColor == avatarColor &&
other.email == email && other.email == email &&
other.name == name && other.name == name &&

View file

@ -1,4 +1,4 @@
import 'dart:ui'; import 'package:immich_mobile/domain/models/user.model.dart';
enum UserMetadataKey { enum UserMetadataKey {
// do not change this order! // do not change this order!
@ -7,36 +7,6 @@ enum UserMetadataKey {
license, license,
} }
enum AvatarColor {
// do not change this order or reuse indices for other purposes, adding is OK
primary("primary"),
pink("pink"),
red("red"),
yellow("yellow"),
blue("blue"),
green("green"),
purple("purple"),
orange("orange"),
gray("gray"),
amber("amber");
final String value;
const AvatarColor(this.value);
Color toColor({bool isDarkTheme = false}) => switch (this) {
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),
AvatarColor.blue => const Color.fromARGB(255, 59, 130, 246),
AvatarColor.green => const Color.fromARGB(255, 22, 163, 74),
AvatarColor.purple => const Color.fromARGB(255, 147, 51, 234),
AvatarColor.orange => const Color.fromARGB(255, 234, 88, 12),
AvatarColor.gray => const Color.fromARGB(255, 75, 85, 99),
AvatarColor.amber => const Color.fromARGB(255, 217, 119, 6),
};
}
class Onboarding { class Onboarding {
final bool isOnboarded; final bool isOnboarded;

View file

@ -169,15 +169,20 @@ class BackgroundWorkerBgService extends BackgroundWorkerFlutterApi {
try { try {
_isCleanedUp = true; _isCleanedUp = true;
_logger.info("Cleaning up background worker"); _logger.info("Cleaning up background worker");
await _ref.read(backgroundSyncProvider).cancel(); final cleanupFutures = [
await _ref.read(backgroundSyncProvider).cancelLocal(); _drift.close(),
_driftLogger.close(),
_ref.read(backgroundSyncProvider).cancel(),
_ref.read(backgroundSyncProvider).cancelLocal(),
];
if (_isar.isOpen) { if (_isar.isOpen) {
await _isar.close(); cleanupFutures.add(_isar.close());
} }
await _drift.close();
await _driftLogger.close();
_ref.dispose(); _ref.dispose();
_lockManager.releaseLock(); _lockManager.releaseLock();
await Future.wait(cleanupFutures);
_logger.info("Background worker resources cleaned up"); _logger.info("Background worker resources cleaned up");
} catch (error, stack) { } catch (error, stack) {
debugPrint('Failed to cleanup background worker: $error with stack: $stack'); debugPrint('Failed to cleanup background worker: $error with stack: $stack');

View file

@ -74,6 +74,8 @@ class SyncStreamService {
Future<void> _handleSyncData(SyncEntityType type, Iterable<Object> data) async { Future<void> _handleSyncData(SyncEntityType type, Iterable<Object> data) async {
_logger.fine("Processing sync data for $type of length ${data.length}"); _logger.fine("Processing sync data for $type of length ${data.length}");
switch (type) { switch (type) {
case SyncEntityType.authUserV1:
return _syncStreamRepository.updateAuthUsersV1(data.cast());
case SyncEntityType.userV1: case SyncEntityType.userV1:
return _syncStreamRepository.updateUsersV1(data.cast()); return _syncStreamRepository.updateUsersV1(data.cast());
case SyncEntityType.userDeleteV1: case SyncEntityType.userDeleteV1:

View file

@ -0,0 +1,27 @@
import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/models/user.model.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()();
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
// Profile image
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get avatarColor => intEnum<AvatarColor>()();
// Quota
IntColumn get quotaSizeInBytes => integer().withDefault(const Constant(0))();
IntColumn get quotaUsageInBytes => integer().withDefault(const Constant(0))();
// Locked Folder
TextColumn get pinCode => text().nullable()();
@override
Set<Column> get primaryKey => {id};
}

View file

@ -0,0 +1,933 @@
// 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.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<bool> isAdmin,
i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt,
required i2.AvatarColor avatarColor,
i0.Value<int> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
i0.Value<String?> pinCode,
});
typedef $$AuthUserEntityTableUpdateCompanionBuilder =
i1.AuthUserEntityCompanion Function({
i0.Value<String> id,
i0.Value<String> name,
i0.Value<String> email,
i0.Value<bool> isAdmin,
i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt,
i0.Value<i2.AvatarColor> avatarColor,
i0.Value<int> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
i0.Value<String?> pinCode,
});
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<bool> get isAdmin => $composableBuilder(
column: $table.isAdmin,
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.ColumnWithTypeConverterFilters<i2.AvatarColor, i2.AvatarColor, int>
get avatarColor => $composableBuilder(
column: $table.avatarColor,
builder: (column) => i0.ColumnWithTypeConverterFilters(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 pinCode => $composableBuilder(
column: $table.pinCode,
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<bool> get isAdmin => $composableBuilder(
column: $table.isAdmin,
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 avatarColor => $composableBuilder(
column: $table.avatarColor,
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 pinCode => $composableBuilder(
column: $table.pinCode,
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<bool> get isAdmin =>
$composableBuilder(column: $table.isAdmin, 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.GeneratedColumnWithTypeConverter<i2.AvatarColor, int> get avatarColor =>
$composableBuilder(
column: $table.avatarColor,
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 pinCode =>
$composableBuilder(column: $table.pinCode, 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<bool> isAdmin = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<i2.AvatarColor> avatarColor = const i0.Value.absent(),
i0.Value<int> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
i0.Value<String?> pinCode = const i0.Value.absent(),
}) => i1.AuthUserEntityCompanion(
id: id,
name: name,
email: email,
isAdmin: isAdmin,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
avatarColor: avatarColor,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
pinCode: pinCode,
),
createCompanionCallback:
({
required String id,
required String name,
required String email,
i0.Value<bool> isAdmin = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
required i2.AvatarColor avatarColor,
i0.Value<int> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
i0.Value<String?> pinCode = const i0.Value.absent(),
}) => i1.AuthUserEntityCompanion.insert(
id: id,
name: name,
email: email,
isAdmin: isAdmin,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
avatarColor: avatarColor,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
pinCode: pinCode,
),
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 _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 _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,
);
@override
late final i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int>
avatarColor =
i0.GeneratedColumn<int>(
'avatar_color',
aliasedName,
false,
type: i0.DriftSqlType.int,
requiredDuringInsert: true,
).withConverter<i2.AvatarColor>(
i1.$AuthUserEntityTable.$converteravatarColor,
);
static const i0.VerificationMeta _quotaSizeInBytesMeta =
const i0.VerificationMeta('quotaSizeInBytes');
@override
late final i0.GeneratedColumn<int> quotaSizeInBytes = i0.GeneratedColumn<int>(
'quota_size_in_bytes',
aliasedName,
false,
type: i0.DriftSqlType.int,
requiredDuringInsert: false,
defaultValue: const i4.Constant(0),
);
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 _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,
);
@override
List<i0.GeneratedColumn> get $columns => [
id,
name,
email,
isAdmin,
hasProfileImage,
profileChangedAt,
avatarColor,
quotaSizeInBytes,
quotaUsageInBytes,
pinCode,
];
@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('is_admin')) {
context.handle(
_isAdminMeta,
isAdmin.isAcceptableOrUnknown(data['is_admin']!, _isAdminMeta),
);
}
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('pin_code')) {
context.handle(
_pinCodeMeta,
pinCode.isAcceptableOrUnknown(data['pin_code']!, _pinCodeMeta),
);
}
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'],
)!,
isAdmin: attachedDatabase.typeMapping.read(
i0.DriftSqlType.bool,
data['${effectivePrefix}is_admin'],
)!,
hasProfileImage: attachedDatabase.typeMapping.read(
i0.DriftSqlType.bool,
data['${effectivePrefix}has_profile_image'],
)!,
profileChangedAt: attachedDatabase.typeMapping.read(
i0.DriftSqlType.dateTime,
data['${effectivePrefix}profile_changed_at'],
)!,
avatarColor: i1.$AuthUserEntityTable.$converteravatarColor.fromSql(
attachedDatabase.typeMapping.read(
i0.DriftSqlType.int,
data['${effectivePrefix}avatar_color'],
)!,
),
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'],
)!,
pinCode: attachedDatabase.typeMapping.read(
i0.DriftSqlType.string,
data['${effectivePrefix}pin_code'],
),
);
}
@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);
@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 bool isAdmin;
final bool hasProfileImage;
final DateTime profileChangedAt;
final i2.AvatarColor avatarColor;
final int quotaSizeInBytes;
final int quotaUsageInBytes;
final String? pinCode;
const AuthUserEntityData({
required this.id,
required this.name,
required this.email,
required this.isAdmin,
required this.hasProfileImage,
required this.profileChangedAt,
required this.avatarColor,
required this.quotaSizeInBytes,
required this.quotaUsageInBytes,
this.pinCode,
});
@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);
map['is_admin'] = i0.Variable<bool>(isAdmin);
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
{
map['avatar_color'] = i0.Variable<int>(
i1.$AuthUserEntityTable.$converteravatarColor.toSql(avatarColor),
);
}
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes);
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes);
if (!nullToAbsent || pinCode != null) {
map['pin_code'] = i0.Variable<String>(pinCode);
}
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']),
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
avatarColor: i1.$AuthUserEntityTable.$converteravatarColor.fromJson(
serializer.fromJson<int>(json['avatarColor']),
),
quotaSizeInBytes: serializer.fromJson<int>(json['quotaSizeInBytes']),
quotaUsageInBytes: serializer.fromJson<int>(json['quotaUsageInBytes']),
pinCode: serializer.fromJson<String?>(json['pinCode']),
);
}
@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),
'isAdmin': serializer.toJson<bool>(isAdmin),
'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
'avatarColor': serializer.toJson<int>(
i1.$AuthUserEntityTable.$converteravatarColor.toJson(avatarColor),
),
'quotaSizeInBytes': serializer.toJson<int>(quotaSizeInBytes),
'quotaUsageInBytes': serializer.toJson<int>(quotaUsageInBytes),
'pinCode': serializer.toJson<String?>(pinCode),
};
}
i1.AuthUserEntityData copyWith({
String? id,
String? name,
String? email,
bool? isAdmin,
bool? hasProfileImage,
DateTime? profileChangedAt,
i2.AvatarColor? avatarColor,
int? quotaSizeInBytes,
int? quotaUsageInBytes,
i0.Value<String?> pinCode = const i0.Value.absent(),
}) => i1.AuthUserEntityData(
id: id ?? this.id,
name: name ?? this.name,
email: email ?? this.email,
isAdmin: isAdmin ?? this.isAdmin,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
avatarColor: avatarColor ?? this.avatarColor,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
pinCode: pinCode.present ? pinCode.value : this.pinCode,
);
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,
isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin,
hasProfileImage: data.hasProfileImage.present
? data.hasProfileImage.value
: this.hasProfileImage,
profileChangedAt: data.profileChangedAt.present
? data.profileChangedAt.value
: this.profileChangedAt,
avatarColor: data.avatarColor.present
? data.avatarColor.value
: this.avatarColor,
quotaSizeInBytes: data.quotaSizeInBytes.present
? data.quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: data.quotaUsageInBytes.present
? data.quotaUsageInBytes.value
: this.quotaUsageInBytes,
pinCode: data.pinCode.present ? data.pinCode.value : this.pinCode,
);
}
@override
String toString() {
return (StringBuffer('AuthUserEntityData(')
..write('id: $id, ')
..write('name: $name, ')
..write('email: $email, ')
..write('isAdmin: $isAdmin, ')
..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ')
..write('avatarColor: $avatarColor, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes, ')
..write('pinCode: $pinCode')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(
id,
name,
email,
isAdmin,
hasProfileImage,
profileChangedAt,
avatarColor,
quotaSizeInBytes,
quotaUsageInBytes,
pinCode,
);
@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.isAdmin == this.isAdmin &&
other.hasProfileImage == this.hasProfileImage &&
other.profileChangedAt == this.profileChangedAt &&
other.avatarColor == this.avatarColor &&
other.quotaSizeInBytes == this.quotaSizeInBytes &&
other.quotaUsageInBytes == this.quotaUsageInBytes &&
other.pinCode == this.pinCode);
}
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<bool> isAdmin;
final i0.Value<bool> hasProfileImage;
final i0.Value<DateTime> profileChangedAt;
final i0.Value<i2.AvatarColor> avatarColor;
final i0.Value<int> quotaSizeInBytes;
final i0.Value<int> quotaUsageInBytes;
final i0.Value<String?> pinCode;
const AuthUserEntityCompanion({
this.id = const i0.Value.absent(),
this.name = const i0.Value.absent(),
this.email = const i0.Value.absent(),
this.isAdmin = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(),
this.avatarColor = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
this.pinCode = const i0.Value.absent(),
});
AuthUserEntityCompanion.insert({
required String id,
required String name,
required String email,
this.isAdmin = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(),
required i2.AvatarColor avatarColor,
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
this.pinCode = const i0.Value.absent(),
}) : id = i0.Value(id),
name = i0.Value(name),
email = i0.Value(email),
avatarColor = i0.Value(avatarColor);
static i0.Insertable<i1.AuthUserEntityData> custom({
i0.Expression<String>? id,
i0.Expression<String>? name,
i0.Expression<String>? email,
i0.Expression<bool>? isAdmin,
i0.Expression<bool>? hasProfileImage,
i0.Expression<DateTime>? profileChangedAt,
i0.Expression<int>? avatarColor,
i0.Expression<int>? quotaSizeInBytes,
i0.Expression<int>? quotaUsageInBytes,
i0.Expression<String>? pinCode,
}) {
return i0.RawValuesInsertable({
if (id != null) 'id': id,
if (name != null) 'name': name,
if (email != null) 'email': email,
if (isAdmin != null) 'is_admin': isAdmin,
if (hasProfileImage != null) 'has_profile_image': hasProfileImage,
if (profileChangedAt != null) 'profile_changed_at': profileChangedAt,
if (avatarColor != null) 'avatar_color': avatarColor,
if (quotaSizeInBytes != null) 'quota_size_in_bytes': quotaSizeInBytes,
if (quotaUsageInBytes != null) 'quota_usage_in_bytes': quotaUsageInBytes,
if (pinCode != null) 'pin_code': pinCode,
});
}
i1.AuthUserEntityCompanion copyWith({
i0.Value<String>? id,
i0.Value<String>? name,
i0.Value<String>? email,
i0.Value<bool>? isAdmin,
i0.Value<bool>? hasProfileImage,
i0.Value<DateTime>? profileChangedAt,
i0.Value<i2.AvatarColor>? avatarColor,
i0.Value<int>? quotaSizeInBytes,
i0.Value<int>? quotaUsageInBytes,
i0.Value<String?>? pinCode,
}) {
return i1.AuthUserEntityCompanion(
id: id ?? this.id,
name: name ?? this.name,
email: email ?? this.email,
isAdmin: isAdmin ?? this.isAdmin,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
avatarColor: avatarColor ?? this.avatarColor,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
pinCode: pinCode ?? this.pinCode,
);
}
@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 (isAdmin.present) {
map['is_admin'] = i0.Variable<bool>(isAdmin.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 (avatarColor.present) {
map['avatar_color'] = i0.Variable<int>(
i1.$AuthUserEntityTable.$converteravatarColor.toSql(avatarColor.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 (pinCode.present) {
map['pin_code'] = i0.Variable<String>(pinCode.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('AuthUserEntityCompanion(')
..write('id: $id, ')
..write('name: $name, ')
..write('email: $email, ')
..write('isAdmin: $isAdmin, ')
..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ')
..write('avatarColor: $avatarColor, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes, ')
..write('pinCode: $pinCode')
..write(')'))
.toString();
}
}

View file

@ -1,6 +1,5 @@
import 'package:drift/drift.dart' hide Index; import 'package:drift/drift.dart' hide Index;
import 'package:immich_mobile/domain/models/user.model.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/utils/drift_default.mixin.dart'; import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
import 'package:immich_mobile/utils/hash.dart'; import 'package:immich_mobile/utils/hash.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
@ -44,7 +43,7 @@ class User {
static User fromDto(UserDto dto) => User( static User fromDto(UserDto dto) => User(
id: dto.id, id: dto.id,
updatedAt: dto.updatedAt, updatedAt: dto.updatedAt ?? DateTime(2025),
email: dto.email, email: dto.email,
name: dto.name, name: dto.name,
isAdmin: dto.isAdmin, isAdmin: dto.isAdmin,
@ -81,13 +80,12 @@ class UserEntity extends Table with DriftDefaultsMixin {
TextColumn get id => text()(); TextColumn get id => text()();
TextColumn get name => text()(); TextColumn get name => text()();
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
TextColumn get email => text()(); TextColumn get email => text()();
// Profile image
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))(); BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)(); DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get avatarColor => intEnum<AvatarColor>().withDefault(const Constant(0))();
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
@override @override
Set<Column> get primaryKey => {id}; Set<Column> get primaryKey => {id};

View file

@ -3,28 +3,27 @@
import 'package:drift/drift.dart' as i0; import 'package:drift/drift.dart' as i0;
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart'
as i1; as i1;
import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as i2; import 'package:immich_mobile/domain/models/user.model.dart' as i2;
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i3; import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as i3;
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i4;
typedef $$UserEntityTableCreateCompanionBuilder = typedef $$UserEntityTableCreateCompanionBuilder =
i1.UserEntityCompanion Function({ i1.UserEntityCompanion Function({
required String id, required String id,
required String name, required String name,
i0.Value<bool> isAdmin,
required String email, required String email,
i0.Value<bool> hasProfileImage, i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt, i0.Value<DateTime> profileChangedAt,
i0.Value<DateTime> updatedAt, i0.Value<i2.AvatarColor> avatarColor,
}); });
typedef $$UserEntityTableUpdateCompanionBuilder = typedef $$UserEntityTableUpdateCompanionBuilder =
i1.UserEntityCompanion Function({ i1.UserEntityCompanion Function({
i0.Value<String> id, i0.Value<String> id,
i0.Value<String> name, i0.Value<String> name,
i0.Value<bool> isAdmin,
i0.Value<String> email, i0.Value<String> email,
i0.Value<bool> hasProfileImage, i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt, i0.Value<DateTime> profileChangedAt,
i0.Value<DateTime> updatedAt, i0.Value<i2.AvatarColor> avatarColor,
}); });
class $$UserEntityTableFilterComposer class $$UserEntityTableFilterComposer
@ -46,11 +45,6 @@ class $$UserEntityTableFilterComposer
builder: (column) => i0.ColumnFilters(column), 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( i0.ColumnFilters<String> get email => $composableBuilder(
column: $table.email, column: $table.email,
builder: (column) => i0.ColumnFilters(column), builder: (column) => i0.ColumnFilters(column),
@ -66,9 +60,10 @@ class $$UserEntityTableFilterComposer
builder: (column) => i0.ColumnFilters(column), builder: (column) => i0.ColumnFilters(column),
); );
i0.ColumnFilters<DateTime> get updatedAt => $composableBuilder( i0.ColumnWithTypeConverterFilters<i2.AvatarColor, i2.AvatarColor, int>
column: $table.updatedAt, get avatarColor => $composableBuilder(
builder: (column) => i0.ColumnFilters(column), column: $table.avatarColor,
builder: (column) => i0.ColumnWithTypeConverterFilters(column),
); );
} }
@ -91,11 +86,6 @@ class $$UserEntityTableOrderingComposer
builder: (column) => i0.ColumnOrderings(column), 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( i0.ColumnOrderings<String> get email => $composableBuilder(
column: $table.email, column: $table.email,
builder: (column) => i0.ColumnOrderings(column), builder: (column) => i0.ColumnOrderings(column),
@ -111,8 +101,8 @@ class $$UserEntityTableOrderingComposer
builder: (column) => i0.ColumnOrderings(column), builder: (column) => i0.ColumnOrderings(column),
); );
i0.ColumnOrderings<DateTime> get updatedAt => $composableBuilder( i0.ColumnOrderings<int> get avatarColor => $composableBuilder(
column: $table.updatedAt, column: $table.avatarColor,
builder: (column) => i0.ColumnOrderings(column), builder: (column) => i0.ColumnOrderings(column),
); );
} }
@ -132,9 +122,6 @@ class $$UserEntityTableAnnotationComposer
i0.GeneratedColumn<String> get name => i0.GeneratedColumn<String> get name =>
$composableBuilder(column: $table.name, builder: (column) => column); $composableBuilder(column: $table.name, builder: (column) => column);
i0.GeneratedColumn<bool> get isAdmin =>
$composableBuilder(column: $table.isAdmin, builder: (column) => column);
i0.GeneratedColumn<String> get email => i0.GeneratedColumn<String> get email =>
$composableBuilder(column: $table.email, builder: (column) => column); $composableBuilder(column: $table.email, builder: (column) => column);
@ -148,8 +135,11 @@ class $$UserEntityTableAnnotationComposer
builder: (column) => column, builder: (column) => column,
); );
i0.GeneratedColumn<DateTime> get updatedAt => i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int> get avatarColor =>
$composableBuilder(column: $table.updatedAt, builder: (column) => column); $composableBuilder(
column: $table.avatarColor,
builder: (column) => column,
);
} }
class $$UserEntityTableTableManager class $$UserEntityTableTableManager
@ -191,37 +181,33 @@ class $$UserEntityTableTableManager
({ ({
i0.Value<String> id = const i0.Value.absent(), i0.Value<String> id = const i0.Value.absent(),
i0.Value<String> name = 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> email = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(), i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(), i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<DateTime> updatedAt = const i0.Value.absent(), i0.Value<i2.AvatarColor> avatarColor = const i0.Value.absent(),
}) => i1.UserEntityCompanion( }) => i1.UserEntityCompanion(
id: id, id: id,
name: name, name: name,
isAdmin: isAdmin,
email: email, email: email,
hasProfileImage: hasProfileImage, hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt, profileChangedAt: profileChangedAt,
updatedAt: updatedAt, avatarColor: avatarColor,
), ),
createCompanionCallback: createCompanionCallback:
({ ({
required String id, required String id,
required String name, required String name,
i0.Value<bool> isAdmin = const i0.Value.absent(),
required String email, required String email,
i0.Value<bool> hasProfileImage = const i0.Value.absent(), i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(), i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<DateTime> updatedAt = const i0.Value.absent(), i0.Value<i2.AvatarColor> avatarColor = const i0.Value.absent(),
}) => i1.UserEntityCompanion.insert( }) => i1.UserEntityCompanion.insert(
id: id, id: id,
name: name, name: name,
isAdmin: isAdmin,
email: email, email: email,
hasProfileImage: hasProfileImage, hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt, profileChangedAt: profileChangedAt,
updatedAt: updatedAt, avatarColor: avatarColor,
), ),
withReferenceMapper: (p0) => p0 withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e))) .map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
@ -253,7 +239,7 @@ typedef $$UserEntityTableProcessedTableManager =
i0.PrefetchHooks Function() i0.PrefetchHooks Function()
>; >;
class $UserEntityTable extends i2.UserEntity class $UserEntityTable extends i3.UserEntity
with i0.TableInfo<$UserEntityTable, i1.UserEntityData> { with i0.TableInfo<$UserEntityTable, i1.UserEntityData> {
@override @override
final i0.GeneratedDatabase attachedDatabase; final i0.GeneratedDatabase attachedDatabase;
@ -279,21 +265,6 @@ class $UserEntityTable extends i2.UserEntity
type: i0.DriftSqlType.string, type: i0.DriftSqlType.string,
requiredDuringInsert: true, 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( static const i0.VerificationMeta _emailMeta = const i0.VerificationMeta(
'email', 'email',
); );
@ -318,7 +289,7 @@ class $UserEntityTable extends i2.UserEntity
defaultConstraints: i0.GeneratedColumn.constraintIsAlways( defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
'CHECK ("has_profile_image" IN (0, 1))', 'CHECK ("has_profile_image" IN (0, 1))',
), ),
defaultValue: const i3.Constant(false), defaultValue: const i4.Constant(false),
); );
static const i0.VerificationMeta _profileChangedAtMeta = static const i0.VerificationMeta _profileChangedAtMeta =
const i0.VerificationMeta('profileChangedAt'); const i0.VerificationMeta('profileChangedAt');
@ -330,30 +301,26 @@ class $UserEntityTable extends i2.UserEntity
false, false,
type: i0.DriftSqlType.dateTime, type: i0.DriftSqlType.dateTime,
requiredDuringInsert: false, requiredDuringInsert: false,
defaultValue: i3.currentDateAndTime, defaultValue: i4.currentDateAndTime,
); );
static const i0.VerificationMeta _updatedAtMeta = const i0.VerificationMeta(
'updatedAt',
);
@override @override
late final i0.GeneratedColumn<DateTime> updatedAt = late final i0.GeneratedColumnWithTypeConverter<i2.AvatarColor, int>
i0.GeneratedColumn<DateTime>( avatarColor = i0.GeneratedColumn<int>(
'updated_at', 'avatar_color',
aliasedName, aliasedName,
false, false,
type: i0.DriftSqlType.dateTime, type: i0.DriftSqlType.int,
requiredDuringInsert: false, requiredDuringInsert: false,
defaultValue: i3.currentDateAndTime, defaultValue: const i4.Constant(0),
); ).withConverter<i2.AvatarColor>(i1.$UserEntityTable.$converteravatarColor);
@override @override
List<i0.GeneratedColumn> get $columns => [ List<i0.GeneratedColumn> get $columns => [
id, id,
name, name,
isAdmin,
email, email,
hasProfileImage, hasProfileImage,
profileChangedAt, profileChangedAt,
updatedAt, avatarColor,
]; ];
@override @override
String get aliasedName => _alias ?? actualTableName; String get aliasedName => _alias ?? actualTableName;
@ -380,12 +347,6 @@ class $UserEntityTable extends i2.UserEntity
} else if (isInserting) { } else if (isInserting) {
context.missing(_nameMeta); context.missing(_nameMeta);
} }
if (data.containsKey('is_admin')) {
context.handle(
_isAdminMeta,
isAdmin.isAcceptableOrUnknown(data['is_admin']!, _isAdminMeta),
);
}
if (data.containsKey('email')) { if (data.containsKey('email')) {
context.handle( context.handle(
_emailMeta, _emailMeta,
@ -412,12 +373,6 @@ class $UserEntityTable extends i2.UserEntity
), ),
); );
} }
if (data.containsKey('updated_at')) {
context.handle(
_updatedAtMeta,
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta),
);
}
return context; return context;
} }
@ -435,10 +390,6 @@ class $UserEntityTable extends i2.UserEntity
i0.DriftSqlType.string, i0.DriftSqlType.string,
data['${effectivePrefix}name'], data['${effectivePrefix}name'],
)!, )!,
isAdmin: attachedDatabase.typeMapping.read(
i0.DriftSqlType.bool,
data['${effectivePrefix}is_admin'],
)!,
email: attachedDatabase.typeMapping.read( email: attachedDatabase.typeMapping.read(
i0.DriftSqlType.string, i0.DriftSqlType.string,
data['${effectivePrefix}email'], data['${effectivePrefix}email'],
@ -451,10 +402,12 @@ class $UserEntityTable extends i2.UserEntity
i0.DriftSqlType.dateTime, i0.DriftSqlType.dateTime,
data['${effectivePrefix}profile_changed_at'], data['${effectivePrefix}profile_changed_at'],
)!, )!,
updatedAt: attachedDatabase.typeMapping.read( avatarColor: i1.$UserEntityTable.$converteravatarColor.fromSql(
i0.DriftSqlType.dateTime, attachedDatabase.typeMapping.read(
data['${effectivePrefix}updated_at'], i0.DriftSqlType.int,
)!, data['${effectivePrefix}avatar_color'],
)!,
),
); );
} }
@ -463,6 +416,8 @@ class $UserEntityTable extends i2.UserEntity
return $UserEntityTable(attachedDatabase, alias); return $UserEntityTable(attachedDatabase, alias);
} }
static i0.JsonTypeConverter2<i2.AvatarColor, int, int> $converteravatarColor =
const i0.EnumIndexConverter<i2.AvatarColor>(i2.AvatarColor.values);
@override @override
bool get withoutRowId => true; bool get withoutRowId => true;
@override @override
@ -473,30 +428,31 @@ class UserEntityData extends i0.DataClass
implements i0.Insertable<i1.UserEntityData> { implements i0.Insertable<i1.UserEntityData> {
final String id; final String id;
final String name; final String name;
final bool isAdmin;
final String email; final String email;
final bool hasProfileImage; final bool hasProfileImage;
final DateTime profileChangedAt; final DateTime profileChangedAt;
final DateTime updatedAt; final i2.AvatarColor avatarColor;
const UserEntityData({ const UserEntityData({
required this.id, required this.id,
required this.name, required this.name,
required this.isAdmin,
required this.email, required this.email,
required this.hasProfileImage, required this.hasProfileImage,
required this.profileChangedAt, required this.profileChangedAt,
required this.updatedAt, required this.avatarColor,
}); });
@override @override
Map<String, i0.Expression> toColumns(bool nullToAbsent) { Map<String, i0.Expression> toColumns(bool nullToAbsent) {
final map = <String, i0.Expression>{}; final map = <String, i0.Expression>{};
map['id'] = i0.Variable<String>(id); map['id'] = i0.Variable<String>(id);
map['name'] = i0.Variable<String>(name); map['name'] = i0.Variable<String>(name);
map['is_admin'] = i0.Variable<bool>(isAdmin);
map['email'] = i0.Variable<String>(email); map['email'] = i0.Variable<String>(email);
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage); map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt); map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
map['updated_at'] = i0.Variable<DateTime>(updatedAt); {
map['avatar_color'] = i0.Variable<int>(
i1.$UserEntityTable.$converteravatarColor.toSql(avatarColor),
);
}
return map; return map;
} }
@ -508,11 +464,12 @@ class UserEntityData extends i0.DataClass
return UserEntityData( return UserEntityData(
id: serializer.fromJson<String>(json['id']), id: serializer.fromJson<String>(json['id']),
name: serializer.fromJson<String>(json['name']), name: serializer.fromJson<String>(json['name']),
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
email: serializer.fromJson<String>(json['email']), email: serializer.fromJson<String>(json['email']),
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']), hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']), profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']), avatarColor: i1.$UserEntityTable.$converteravatarColor.fromJson(
serializer.fromJson<int>(json['avatarColor']),
),
); );
} }
@override @override
@ -521,36 +478,34 @@ class UserEntityData extends i0.DataClass
return <String, dynamic>{ return <String, dynamic>{
'id': serializer.toJson<String>(id), 'id': serializer.toJson<String>(id),
'name': serializer.toJson<String>(name), 'name': serializer.toJson<String>(name),
'isAdmin': serializer.toJson<bool>(isAdmin),
'email': serializer.toJson<String>(email), 'email': serializer.toJson<String>(email),
'hasProfileImage': serializer.toJson<bool>(hasProfileImage), 'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt), 'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
'updatedAt': serializer.toJson<DateTime>(updatedAt), 'avatarColor': serializer.toJson<int>(
i1.$UserEntityTable.$converteravatarColor.toJson(avatarColor),
),
}; };
} }
i1.UserEntityData copyWith({ i1.UserEntityData copyWith({
String? id, String? id,
String? name, String? name,
bool? isAdmin,
String? email, String? email,
bool? hasProfileImage, bool? hasProfileImage,
DateTime? profileChangedAt, DateTime? profileChangedAt,
DateTime? updatedAt, i2.AvatarColor? avatarColor,
}) => i1.UserEntityData( }) => i1.UserEntityData(
id: id ?? this.id, id: id ?? this.id,
name: name ?? this.name, name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
email: email ?? this.email, email: email ?? this.email,
hasProfileImage: hasProfileImage ?? this.hasProfileImage, hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt, profileChangedAt: profileChangedAt ?? this.profileChangedAt,
updatedAt: updatedAt ?? this.updatedAt, avatarColor: avatarColor ?? this.avatarColor,
); );
UserEntityData copyWithCompanion(i1.UserEntityCompanion data) { UserEntityData copyWithCompanion(i1.UserEntityCompanion data) {
return UserEntityData( return UserEntityData(
id: data.id.present ? data.id.value : this.id, id: data.id.present ? data.id.value : this.id,
name: data.name.present ? data.name.value : this.name, 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, email: data.email.present ? data.email.value : this.email,
hasProfileImage: data.hasProfileImage.present hasProfileImage: data.hasProfileImage.present
? data.hasProfileImage.value ? data.hasProfileImage.value
@ -558,7 +513,9 @@ class UserEntityData extends i0.DataClass
profileChangedAt: data.profileChangedAt.present profileChangedAt: data.profileChangedAt.present
? data.profileChangedAt.value ? data.profileChangedAt.value
: this.profileChangedAt, : this.profileChangedAt,
updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, avatarColor: data.avatarColor.present
? data.avatarColor.value
: this.avatarColor,
); );
} }
@ -567,11 +524,10 @@ class UserEntityData extends i0.DataClass
return (StringBuffer('UserEntityData(') return (StringBuffer('UserEntityData(')
..write('id: $id, ') ..write('id: $id, ')
..write('name: $name, ') ..write('name: $name, ')
..write('isAdmin: $isAdmin, ')
..write('email: $email, ') ..write('email: $email, ')
..write('hasProfileImage: $hasProfileImage, ') ..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ') ..write('profileChangedAt: $profileChangedAt, ')
..write('updatedAt: $updatedAt') ..write('avatarColor: $avatarColor')
..write(')')) ..write(')'))
.toString(); .toString();
} }
@ -580,11 +536,10 @@ class UserEntityData extends i0.DataClass
int get hashCode => Object.hash( int get hashCode => Object.hash(
id, id,
name, name,
isAdmin,
email, email,
hasProfileImage, hasProfileImage,
profileChangedAt, profileChangedAt,
updatedAt, avatarColor,
); );
@override @override
bool operator ==(Object other) => bool operator ==(Object other) =>
@ -592,78 +547,70 @@ class UserEntityData extends i0.DataClass
(other is i1.UserEntityData && (other is i1.UserEntityData &&
other.id == this.id && other.id == this.id &&
other.name == this.name && other.name == this.name &&
other.isAdmin == this.isAdmin &&
other.email == this.email && other.email == this.email &&
other.hasProfileImage == this.hasProfileImage && other.hasProfileImage == this.hasProfileImage &&
other.profileChangedAt == this.profileChangedAt && other.profileChangedAt == this.profileChangedAt &&
other.updatedAt == this.updatedAt); other.avatarColor == this.avatarColor);
} }
class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> { class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
final i0.Value<String> id; final i0.Value<String> id;
final i0.Value<String> name; final i0.Value<String> name;
final i0.Value<bool> isAdmin;
final i0.Value<String> email; final i0.Value<String> email;
final i0.Value<bool> hasProfileImage; final i0.Value<bool> hasProfileImage;
final i0.Value<DateTime> profileChangedAt; final i0.Value<DateTime> profileChangedAt;
final i0.Value<DateTime> updatedAt; final i0.Value<i2.AvatarColor> avatarColor;
const UserEntityCompanion({ const UserEntityCompanion({
this.id = const i0.Value.absent(), this.id = const i0.Value.absent(),
this.name = const i0.Value.absent(), this.name = const i0.Value.absent(),
this.isAdmin = const i0.Value.absent(),
this.email = const i0.Value.absent(), this.email = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(), this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(), this.profileChangedAt = const i0.Value.absent(),
this.updatedAt = const i0.Value.absent(), this.avatarColor = const i0.Value.absent(),
}); });
UserEntityCompanion.insert({ UserEntityCompanion.insert({
required String id, required String id,
required String name, required String name,
this.isAdmin = const i0.Value.absent(),
required String email, required String email,
this.hasProfileImage = const i0.Value.absent(), this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(), this.profileChangedAt = const i0.Value.absent(),
this.updatedAt = const i0.Value.absent(), this.avatarColor = const i0.Value.absent(),
}) : id = i0.Value(id), }) : id = i0.Value(id),
name = i0.Value(name), name = i0.Value(name),
email = i0.Value(email); email = i0.Value(email);
static i0.Insertable<i1.UserEntityData> custom({ static i0.Insertable<i1.UserEntityData> custom({
i0.Expression<String>? id, i0.Expression<String>? id,
i0.Expression<String>? name, i0.Expression<String>? name,
i0.Expression<bool>? isAdmin,
i0.Expression<String>? email, i0.Expression<String>? email,
i0.Expression<bool>? hasProfileImage, i0.Expression<bool>? hasProfileImage,
i0.Expression<DateTime>? profileChangedAt, i0.Expression<DateTime>? profileChangedAt,
i0.Expression<DateTime>? updatedAt, i0.Expression<int>? avatarColor,
}) { }) {
return i0.RawValuesInsertable({ return i0.RawValuesInsertable({
if (id != null) 'id': id, if (id != null) 'id': id,
if (name != null) 'name': name, if (name != null) 'name': name,
if (isAdmin != null) 'is_admin': isAdmin,
if (email != null) 'email': email, if (email != null) 'email': email,
if (hasProfileImage != null) 'has_profile_image': hasProfileImage, if (hasProfileImage != null) 'has_profile_image': hasProfileImage,
if (profileChangedAt != null) 'profile_changed_at': profileChangedAt, if (profileChangedAt != null) 'profile_changed_at': profileChangedAt,
if (updatedAt != null) 'updated_at': updatedAt, if (avatarColor != null) 'avatar_color': avatarColor,
}); });
} }
i1.UserEntityCompanion copyWith({ i1.UserEntityCompanion copyWith({
i0.Value<String>? id, i0.Value<String>? id,
i0.Value<String>? name, i0.Value<String>? name,
i0.Value<bool>? isAdmin,
i0.Value<String>? email, i0.Value<String>? email,
i0.Value<bool>? hasProfileImage, i0.Value<bool>? hasProfileImage,
i0.Value<DateTime>? profileChangedAt, i0.Value<DateTime>? profileChangedAt,
i0.Value<DateTime>? updatedAt, i0.Value<i2.AvatarColor>? avatarColor,
}) { }) {
return i1.UserEntityCompanion( return i1.UserEntityCompanion(
id: id ?? this.id, id: id ?? this.id,
name: name ?? this.name, name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
email: email ?? this.email, email: email ?? this.email,
hasProfileImage: hasProfileImage ?? this.hasProfileImage, hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt, profileChangedAt: profileChangedAt ?? this.profileChangedAt,
updatedAt: updatedAt ?? this.updatedAt, avatarColor: avatarColor ?? this.avatarColor,
); );
} }
@ -676,9 +623,6 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
if (name.present) { if (name.present) {
map['name'] = i0.Variable<String>(name.value); map['name'] = i0.Variable<String>(name.value);
} }
if (isAdmin.present) {
map['is_admin'] = i0.Variable<bool>(isAdmin.value);
}
if (email.present) { if (email.present) {
map['email'] = i0.Variable<String>(email.value); map['email'] = i0.Variable<String>(email.value);
} }
@ -688,8 +632,10 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
if (profileChangedAt.present) { if (profileChangedAt.present) {
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt.value); map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt.value);
} }
if (updatedAt.present) { if (avatarColor.present) {
map['updated_at'] = i0.Variable<DateTime>(updatedAt.value); map['avatar_color'] = i0.Variable<int>(
i1.$UserEntityTable.$converteravatarColor.toSql(avatarColor.value),
);
} }
return map; return map;
} }
@ -699,11 +645,10 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
return (StringBuffer('UserEntityCompanion(') return (StringBuffer('UserEntityCompanion(')
..write('id: $id, ') ..write('id: $id, ')
..write('name: $name, ') ..write('name: $name, ')
..write('isAdmin: $isAdmin, ')
..write('email: $email, ') ..write('email: $email, ')
..write('hasProfileImage: $hasProfileImage, ') ..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ') ..write('profileChangedAt: $profileChangedAt, ')
..write('updatedAt: $updatedAt') ..write('avatarColor: $avatarColor')
..write(')')) ..write(')'))
.toString(); .toString();
} }

View file

@ -5,6 +5,7 @@ import 'package:drift_flutter/drift_flutter.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:immich_mobile/domain/interfaces/db.interface.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/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/exif.entity.dart';
import 'package:immich_mobile/infrastructure/entities/local_album.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_album_asset.entity.dart';
@ -44,6 +45,7 @@ class IsarDatabaseRepository implements IDatabaseRepository {
@DriftDatabase( @DriftDatabase(
tables: [ tables: [
AuthUserEntity,
UserEntity, UserEntity,
UserMetadataEntity, UserMetadataEntity,
PartnerEntity, PartnerEntity,
@ -70,7 +72,7 @@ class Drift extends $Drift implements IDatabaseRepository {
: super(executor ?? driftDatabase(name: 'immich', native: const DriftNativeOptions(shareAcrossIsolates: true))); : super(executor ?? driftDatabase(name: 'immich', native: const DriftNativeOptions(shareAcrossIsolates: true)));
@override @override
int get schemaVersion => 10; int get schemaVersion => 11;
@override @override
MigrationStrategy get migration => MigrationStrategy( MigrationStrategy get migration => MigrationStrategy(
@ -129,7 +131,12 @@ class Drift extends $Drift implements IDatabaseRepository {
await m.addColumn(v9.localAlbumEntity, v9.localAlbumEntity.linkedRemoteAlbumId); await m.addColumn(v9.localAlbumEntity, v9.localAlbumEntity.linkedRemoteAlbumId);
}, },
from9To10: (m, v10) async { from9To10: (m, v10) async {
await m.create(v10.localTrashedAssetEntity); await m.createTable(v10.authUserEntity);
await m.addColumn(v10.userEntity, v10.userEntity.avatarColor);
await m.alterTable(TableMigration(v10.userEntity));
},
from10To11: (m, v11) async {
await m.create(v11.localTrashedAssetEntity);
}, },
), ),
); );
@ -146,14 +153,13 @@ class Drift extends $Drift implements IDatabaseRepository {
await customStatement('PRAGMA foreign_keys = ON'); await customStatement('PRAGMA foreign_keys = ON');
await customStatement('PRAGMA synchronous = NORMAL'); await customStatement('PRAGMA synchronous = NORMAL');
await customStatement('PRAGMA journal_mode = WAL'); await customStatement('PRAGMA journal_mode = WAL');
await customStatement('PRAGMA busy_timeout = 500'); await customStatement('PRAGMA busy_timeout = 30000');
}, },
); );
} }
class DriftDatabaseRepository implements IDatabaseRepository { class DriftDatabaseRepository implements IDatabaseRepository {
final Drift _db; final Drift _db;
const DriftDatabaseRepository(this._db); const DriftDatabaseRepository(this._db);
@override @override

View file

@ -15,26 +15,28 @@ import 'package:immich_mobile/infrastructure/entities/local_album.entity.drift.d
as i6; as i6;
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart'
as i7; as i7;
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/auth_user.entity.drift.dart'
as i8; as i8;
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
as i9; as i9;
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
as i10; as i10;
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
as i11; 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; 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; 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; 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; 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; as i16;
import 'package:immich_mobile/infrastructure/entities/store.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/asset_face.entity.drift.dart'
as i17; as i17;
import 'package:immich_mobile/infrastructure/entities/store.entity.drift.dart'
as i18;
import 'package:immich_mobile/infrastructure/entities/local_trashed_asset.entity.drift.dart' import 'package:immich_mobile/infrastructure/entities/local_trashed_asset.entity.drift.dart'
as i18; as i18;
import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart' import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart'
@ -56,26 +58,27 @@ abstract class $Drift extends i0.GeneratedDatabase {
.$LocalAlbumEntityTable(this); .$LocalAlbumEntityTable(this);
late final i7.$LocalAlbumAssetEntityTable localAlbumAssetEntity = i7 late final i7.$LocalAlbumAssetEntityTable localAlbumAssetEntity = i7
.$LocalAlbumAssetEntityTable(this); .$LocalAlbumAssetEntityTable(this);
late final i8.$UserMetadataEntityTable userMetadataEntity = i8 late final i8.$AuthUserEntityTable authUserEntity = i8.$AuthUserEntityTable(
.$UserMetadataEntityTable(this);
late final i9.$PartnerEntityTable partnerEntity = i9.$PartnerEntityTable(
this, this,
); );
late final i10.$RemoteExifEntityTable remoteExifEntity = i10 late final i9.$UserMetadataEntityTable userMetadataEntity = i9
.$UserMetadataEntityTable(this);
late final i10.$PartnerEntityTable partnerEntity = i10.$PartnerEntityTable(
this,
);
late final i11.$RemoteExifEntityTable remoteExifEntity = i11
.$RemoteExifEntityTable(this); .$RemoteExifEntityTable(this);
late final i11.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity = i11 late final i12.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity = i12
.$RemoteAlbumAssetEntityTable(this); .$RemoteAlbumAssetEntityTable(this);
late final i12.$RemoteAlbumUserEntityTable remoteAlbumUserEntity = i12 late final i13.$RemoteAlbumUserEntityTable remoteAlbumUserEntity = i13
.$RemoteAlbumUserEntityTable(this); .$RemoteAlbumUserEntityTable(this);
late final i13.$MemoryEntityTable memoryEntity = i13.$MemoryEntityTable(this); late final i14.$MemoryEntityTable memoryEntity = i14.$MemoryEntityTable(this);
late final i14.$MemoryAssetEntityTable memoryAssetEntity = i14 late final i15.$MemoryAssetEntityTable memoryAssetEntity = i15
.$MemoryAssetEntityTable(this); .$MemoryAssetEntityTable(this);
late final i15.$PersonEntityTable personEntity = i15.$PersonEntityTable(this); late final i16.$PersonEntityTable personEntity = i16.$PersonEntityTable(this);
late final i16.$AssetFaceEntityTable assetFaceEntity = i16 late final i17.$AssetFaceEntityTable assetFaceEntity = i17
.$AssetFaceEntityTable(this); .$AssetFaceEntityTable(this);
late final i17.$StoreEntityTable storeEntity = i17.$StoreEntityTable(this); late final i18.$StoreEntityTable storeEntity = i18.$StoreEntityTable(this);
late final i18.$LocalTrashedAssetEntityTable localTrashedAssetEntity = i18
.$LocalTrashedAssetEntityTable(this);
i19.MergedAssetDrift get mergedAssetDrift => i20.ReadDatabaseContainer( i19.MergedAssetDrift get mergedAssetDrift => i20.ReadDatabaseContainer(
this, this,
).accessor<i19.MergedAssetDrift>(i19.MergedAssetDrift.new); ).accessor<i19.MergedAssetDrift>(i19.MergedAssetDrift.new);
@ -96,6 +99,7 @@ abstract class $Drift extends i0.GeneratedDatabase {
i2.uQRemoteAssetsOwnerChecksum, i2.uQRemoteAssetsOwnerChecksum,
i2.uQRemoteAssetsOwnerLibraryChecksum, i2.uQRemoteAssetsOwnerLibraryChecksum,
i2.idxRemoteAssetChecksum, i2.idxRemoteAssetChecksum,
authUserEntity,
userMetadataEntity, userMetadataEntity,
partnerEntity, partnerEntity,
remoteExifEntity, remoteExifEntity,
@ -106,9 +110,7 @@ abstract class $Drift extends i0.GeneratedDatabase {
personEntity, personEntity,
assetFaceEntity, assetFaceEntity,
storeEntity, storeEntity,
localTrashedAssetEntity, i11.idxLatLng,
i10.idxLatLng,
i18.idxLocalTrashedAssetRemoteId,
]; ];
@override @override
i0.StreamQueryUpdateRules i0.StreamQueryUpdateRules
@ -323,29 +325,31 @@ class $DriftManager {
i6.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity); i6.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity);
i7.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i7 i7.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i7
.$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity); .$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity);
i8.$$UserMetadataEntityTableTableManager get userMetadataEntity => i8.$$AuthUserEntityTableTableManager get authUserEntity =>
i8.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity); i8.$$AuthUserEntityTableTableManager(_db, _db.authUserEntity);
i9.$$PartnerEntityTableTableManager get partnerEntity => i9.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
i9.$$PartnerEntityTableTableManager(_db, _db.partnerEntity); i9.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
i10.$$RemoteExifEntityTableTableManager get remoteExifEntity => i10.$$PartnerEntityTableTableManager get partnerEntity =>
i10.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity); i10.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
i11.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity => i11.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
i11.$$RemoteAlbumAssetEntityTableTableManager( i11.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
i12.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
i12.$$RemoteAlbumAssetEntityTableTableManager(
_db, _db,
_db.remoteAlbumAssetEntity, _db.remoteAlbumAssetEntity,
); );
i12.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i12 i13.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i13
.$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity); .$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity);
i13.$$MemoryEntityTableTableManager get memoryEntity => i14.$$MemoryEntityTableTableManager get memoryEntity =>
i13.$$MemoryEntityTableTableManager(_db, _db.memoryEntity); i14.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
i14.$$MemoryAssetEntityTableTableManager get memoryAssetEntity => i15.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
i14.$$MemoryAssetEntityTableTableManager(_db, _db.memoryAssetEntity); i15.$$MemoryAssetEntityTableTableManager(_db, _db.memoryAssetEntity);
i15.$$PersonEntityTableTableManager get personEntity => i16.$$PersonEntityTableTableManager get personEntity =>
i15.$$PersonEntityTableTableManager(_db, _db.personEntity); i16.$$PersonEntityTableTableManager(_db, _db.personEntity);
i16.$$AssetFaceEntityTableTableManager get assetFaceEntity => i17.$$AssetFaceEntityTableTableManager get assetFaceEntity =>
i16.$$AssetFaceEntityTableTableManager(_db, _db.assetFaceEntity); i17.$$AssetFaceEntityTableTableManager(_db, _db.assetFaceEntity);
i17.$$StoreEntityTableTableManager get storeEntity => i18.$$StoreEntityTableTableManager get storeEntity =>
i17.$$StoreEntityTableTableManager(_db, _db.storeEntity); i18.$$StoreEntityTableTableManager(_db, _db.storeEntity);
i18.$$LocalTrashedAssetEntityTableTableManager get localTrashedAssetEntity => i18.$$LocalTrashedAssetEntityTableTableManager get localTrashedAssetEntity =>
i18.$$LocalTrashedAssetEntityTableTableManager( i18.$$LocalTrashedAssetEntityTableTableManager(
_db, _db,

View file

@ -3837,6 +3837,7 @@ final class Schema10 extends i0.VersionedSchema {
uQRemoteAssetsOwnerChecksum, uQRemoteAssetsOwnerChecksum,
uQRemoteAssetsOwnerLibraryChecksum, uQRemoteAssetsOwnerLibraryChecksum,
idxRemoteAssetChecksum, idxRemoteAssetChecksum,
authUserEntity,
userMetadataEntity, userMetadataEntity,
partnerEntity, partnerEntity,
remoteExifEntity, remoteExifEntity,
@ -3847,11 +3848,9 @@ final class Schema10 extends i0.VersionedSchema {
personEntity, personEntity,
assetFaceEntity, assetFaceEntity,
storeEntity, storeEntity,
localTrashedAssetEntity,
idxLatLng, idxLatLng,
idxLocalTrashedAssetChecksum,
]; ];
late final Shape16 userEntity = Shape16( late final Shape20 userEntity = Shape20(
source: i0.VersionedTable( source: i0.VersionedTable(
entityName: 'user_entity', entityName: 'user_entity',
withoutRowId: true, withoutRowId: true,
@ -3860,11 +3859,10 @@ final class Schema10 extends i0.VersionedSchema {
columns: [ columns: [
_column_0, _column_0,
_column_1, _column_1,
_column_2,
_column_3, _column_3,
_column_84, _column_84,
_column_85, _column_85,
_column_5, _column_91,
], ],
attachedDatabase: database, attachedDatabase: database,
), ),
@ -4005,6 +4003,28 @@ final class Schema10 extends i0.VersionedSchema {
'idx_remote_asset_checksum', 'idx_remote_asset_checksum',
'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)', 'CREATE INDEX IF NOT EXISTS idx_remote_asset_checksum ON remote_asset_entity (checksum)',
); );
late final Shape21 authUserEntity = Shape21(
source: i0.VersionedTable(
entityName: 'auth_user_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: ['PRIMARY KEY(id)'],
columns: [
_column_0,
_column_1,
_column_3,
_column_2,
_column_84,
_column_85,
_column_92,
_column_93,
_column_7,
_column_94,
],
attachedDatabase: database,
),
alias: null,
);
late final Shape4 userMetadataEntity = Shape4( late final Shape4 userMetadataEntity = Shape4(
source: i0.VersionedTable( source: i0.VersionedTable(
entityName: 'user_metadata_entity', entityName: 'user_metadata_entity',
@ -4173,41 +4193,83 @@ final class Schema10 extends i0.VersionedSchema {
), ),
alias: null, alias: null,
); );
late final Shape20 localTrashedAssetEntity = Shape20(
source: i0.VersionedTable(
entityName: 'local_trashed_asset_entity',
withoutRowId: true,
isStrict: true,
tableConstraints: ['PRIMARY KEY(id)'],
columns: [_column_0, _column_36, _column_13, _column_1, _column_9],
attachedDatabase: database,
),
alias: null,
);
final i1.Index idxLatLng = i1.Index( final i1.Index idxLatLng = i1.Index(
'idx_lat_lng', 'idx_lat_lng',
'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)', 'CREATE INDEX IF NOT EXISTS idx_lat_lng ON remote_exif_entity (latitude, longitude)',
); );
final i1.Index idxLocalTrashedAssetChecksum = i1.Index(
'idx_local_trashed_asset_checksum',
'CREATE INDEX IF NOT EXISTS idx_local_trashed_asset_checksum ON local_trashed_asset_entity (checksum)',
);
} }
class Shape20 extends i0.VersionedTable { class Shape20 extends i0.VersionedTable {
Shape20({required super.source, required super.alias}) : super.aliased(); Shape20({required super.source, required super.alias}) : super.aliased();
i1.GeneratedColumn<String> get id => i1.GeneratedColumn<String> get id =>
columnsByName['id']! as i1.GeneratedColumn<String>; columnsByName['id']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get assetId =>
columnsByName['asset_id']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get checksum =>
columnsByName['checksum']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<String> get name => i1.GeneratedColumn<String> get name =>
columnsByName['name']! as i1.GeneratedColumn<String>; columnsByName['name']! as i1.GeneratedColumn<String>;
i1.GeneratedColumn<DateTime> get createdAt => i1.GeneratedColumn<String> get email =>
columnsByName['created_at']! as i1.GeneratedColumn<DateTime>; columnsByName['email']! 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 avatarColor =>
columnsByName['avatar_color']! as i1.GeneratedColumn<int>;
} }
i1.GeneratedColumn<int> _column_91(String aliasedName) =>
i1.GeneratedColumn<int>(
'avatar_color',
aliasedName,
false,
type: i1.DriftSqlType.int,
defaultValue: const CustomExpression('0'),
);
class Shape21 extends i0.VersionedTable {
Shape21({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<bool> get isAdmin =>
columnsByName['is_admin']! as i1.GeneratedColumn<bool>;
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 avatarColor =>
columnsByName['avatar_color']! as i1.GeneratedColumn<int>;
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 pinCode =>
columnsByName['pin_code']! as i1.GeneratedColumn<String>;
}
i1.GeneratedColumn<int> _column_92(String aliasedName) =>
i1.GeneratedColumn<int>(
'avatar_color',
aliasedName,
false,
type: i1.DriftSqlType.int,
);
i1.GeneratedColumn<int> _column_93(String aliasedName) =>
i1.GeneratedColumn<int>(
'quota_size_in_bytes',
aliasedName,
false,
type: i1.DriftSqlType.int,
defaultValue: const CustomExpression('0'),
);
i1.GeneratedColumn<String> _column_94(String aliasedName) =>
i1.GeneratedColumn<String>(
'pin_code',
aliasedName,
true,
type: i1.DriftSqlType.string,
);
i0.MigrationStepWithVersion migrationSteps({ i0.MigrationStepWithVersion migrationSteps({
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2, 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, Schema3 schema) from2To3,

View file

@ -202,14 +202,13 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
id: user.id, id: user.id,
email: user.email, email: user.email,
name: user.name, name: user.name,
isAdmin: user.isAdmin,
updatedAt: user.updatedAt,
memoryEnabled: true, memoryEnabled: true,
inTimeline: false, inTimeline: false,
isPartnerSharedBy: false, isPartnerSharedBy: false,
isPartnerSharedWith: false, isPartnerSharedWith: false,
profileChangedAt: user.profileChangedAt, profileChangedAt: user.profileChangedAt,
hasProfileImage: user.hasProfileImage, hasProfileImage: user.hasProfileImage,
avatarColor: user.avatarColor,
), ),
) )
.get(); .get();

View file

@ -173,7 +173,7 @@ class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepo
const (bool) => entity.intValue == 1, const (bool) => entity.intValue == 1,
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!), const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
const (UserDto) => const (UserDto) =>
entity.stringValue == null ? null : await DriftUserRepository(_db).get(entity.stringValue!), entity.stringValue == null ? null : await DriftAuthUserRepository(_db).get(entity.stringValue!),
_ => null, _ => null,
} }
as T?; as T?;
@ -184,7 +184,7 @@ class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepo
const (String) => (null, value as String), const (String) => (null, value as String),
const (bool) => ((value as bool) ? 1 : 0, null), const (bool) => ((value as bool) ? 1 : 0, null),
const (DateTime) => ((value as DateTime).millisecondsSinceEpoch, null), const (DateTime) => ((value as DateTime).millisecondsSinceEpoch, null),
const (UserDto) => (null, (await DriftUserRepository(_db).upsert(value as UserDto)).id), const (UserDto) => (null, (await DriftAuthUserRepository(_db).upsert(value as UserDto)).id),
_ => throw UnsupportedError("Unsupported primitive type: ${key.type} for key: ${key.name}"), _ => throw UnsupportedError("Unsupported primitive type: ${key.type} for key: ${key.name}"),
}; };
return StoreEntityCompanion(id: Value(key.id), intValue: Value(intValue), stringValue: Value(strValue)); return StoreEntityCompanion(id: Value(key.id), intValue: Value(intValue), stringValue: Value(strValue));

View file

@ -38,6 +38,7 @@ class SyncApiRepository {
request.body = jsonEncode( request.body = jsonEncode(
SyncStreamDto( SyncStreamDto(
types: [ types: [
SyncRequestType.authUsersV1,
SyncRequestType.usersV1, SyncRequestType.usersV1,
SyncRequestType.assetsV1, SyncRequestType.assetsV1,
SyncRequestType.assetExifsV1, SyncRequestType.assetExifsV1,
@ -133,6 +134,7 @@ class SyncApiRepository {
} }
const _kResponseMap = <SyncEntityType, Function(Object)>{ const _kResponseMap = <SyncEntityType, Function(Object)>{
SyncEntityType.authUserV1: SyncAuthUserV1.fromJson,
SyncEntityType.userV1: SyncUserV1.fromJson, SyncEntityType.userV1: SyncUserV1.fromJson,
SyncEntityType.userDeleteV1: SyncUserDeleteV1.fromJson, SyncEntityType.userDeleteV1: SyncUserDeleteV1.fromJson,
SyncEntityType.partnerV1: SyncPartnerV1.fromJson, SyncEntityType.partnerV1: SyncPartnerV1.fromJson,

View file

@ -1,11 +1,14 @@
import 'dart:convert'; import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:drift/drift.dart'; import 'package:drift/drift.dart';
import 'package:immich_mobile/domain/models/album/album.model.dart'; import 'package:immich_mobile/domain/models/album/album.model.dart';
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart'; 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/memory.model.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.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/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/exif.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'; import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart';
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart'; import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart';
@ -59,6 +62,35 @@ class SyncStreamRepository extends DriftDatabaseRepository {
} }
} }
Future<void> updateAuthUsersV1(Iterable<SyncAuthUserV1> data) async {
try {
await _db.batch((batch) {
for (final user in data) {
final companion = AuthUserEntityCompanion(
name: Value(user.name),
email: Value(user.email),
hasProfileImage: Value(user.hasProfileImage),
profileChangedAt: Value(user.profileChangedAt),
avatarColor: Value(user.avatarColor?.toAvatarColor() ?? AvatarColor.primary),
isAdmin: Value(user.isAdmin),
pinCode: Value(user.pinCode),
quotaSizeInBytes: Value(user.quotaSizeInBytes ?? 0),
quotaUsageInBytes: Value(user.quotaUsageInBytes),
);
batch.insert(
_db.authUserEntity,
companion.copyWith(id: Value(user.id)),
onConflict: DoUpdate((_) => companion),
);
}
});
} catch (error, stack) {
_logger.severe('Error: SyncAuthUserV1', error, stack);
rethrow;
}
}
Future<void> deleteUsersV1(Iterable<SyncUserDeleteV1> data) async { Future<void> deleteUsersV1(Iterable<SyncUserDeleteV1> data) async {
try { 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)));
@ -77,6 +109,7 @@ class SyncStreamRepository extends DriftDatabaseRepository {
email: Value(user.email), email: Value(user.email),
hasProfileImage: Value(user.hasProfileImage), hasProfileImage: Value(user.hasProfileImage),
profileChangedAt: Value(user.profileChangedAt), profileChangedAt: Value(user.profileChangedAt),
avatarColor: Value(user.avatarColor?.toAvatarColor() ?? AvatarColor.primary),
); );
batch.insert(_db.userEntity, companion.copyWith(id: Value(user.id)), onConflict: DoUpdate((_) => companion)); batch.insert(_db.userEntity, companion.copyWith(id: Value(user.id)), onConflict: DoUpdate((_) => companion));
@ -603,3 +636,7 @@ extension on String {
} }
} }
} }
extension on UserAvatarColor {
AvatarColor? toAvatarColor() => AvatarColor.values.firstWhereOrNull((c) => c.name == value);
}

View file

@ -2,8 +2,8 @@ import 'package:drift/drift.dart';
import 'package:immich_mobile/constants/enums.dart'; import 'package:immich_mobile/constants/enums.dart';
import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.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/entities/user.entity.dart' as entity; import 'package:immich_mobile/infrastructure/entities/user.entity.dart' as entity;
import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart';
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
import 'package:immich_mobile/infrastructure/repositories/user_metadata.repository.dart'; import 'package:immich_mobile/infrastructure/repositories/user_metadata.repository.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
@ -68,12 +68,12 @@ class IsarUserRepository extends IsarDatabaseRepository {
} }
} }
class DriftUserRepository extends DriftDatabaseRepository { class DriftAuthUserRepository extends DriftDatabaseRepository {
final Drift _db; final Drift _db;
const DriftUserRepository(super.db) : _db = db; const DriftAuthUserRepository(super.db) : _db = db;
Future<UserDto?> get(String id) async { Future<UserDto?> get(String id) async {
final user = await _db.managers.userEntity.filter((user) => user.id.equals(id)).getSingleOrNull(); final user = await _db.managers.authUserEntity.filter((user) => user.id.equals(id)).getSingleOrNull();
if (user == null) return null; if (user == null) return null;
@ -84,43 +84,30 @@ class DriftUserRepository extends DriftDatabaseRepository {
} }
Future<UserDto> upsert(UserDto user) async { Future<UserDto> upsert(UserDto user) async {
await _db.userEntity.insertOnConflictUpdate( await _db.authUserEntity.insertOnConflictUpdate(
UserEntityCompanion( AuthUserEntityCompanion(
id: Value(user.id), id: Value(user.id),
isAdmin: Value(user.isAdmin),
updatedAt: Value(user.updatedAt),
name: Value(user.name), name: Value(user.name),
email: Value(user.email), email: Value(user.email),
hasProfileImage: Value(user.hasProfileImage), hasProfileImage: Value(user.hasProfileImage),
profileChangedAt: Value(user.profileChangedAt), profileChangedAt: Value(user.profileChangedAt),
isAdmin: Value(user.isAdmin),
quotaSizeInBytes: Value(user.quotaSizeInBytes),
quotaUsageInBytes: Value(user.quotaUsageInBytes),
avatarColor: Value(user.avatarColor),
), ),
); );
return user; return user;
} }
Future<List<UserDto>> getAll() async {
final users = await _db.userEntity.select().get();
final List<UserDto> result = [];
for (final user in users) {
final query = _db.userMetadataEntity.select()..where((e) => e.userId.equals(user.id));
final metadata = await query.map((row) => row.toDto()).get();
result.add(user.toDto(metadata));
}
return result;
}
} }
extension on UserEntityData { extension on AuthUserEntityData {
UserDto toDto([List<UserMetadata>? metadata]) { UserDto toDto([List<UserMetadata>? metadata]) {
AvatarColor avatarColor = AvatarColor.primary;
bool memoryEnabled = true; bool memoryEnabled = true;
if (metadata != null) { if (metadata != null) {
for (final meta in metadata) { for (final meta in metadata) {
if (meta.key == UserMetadataKey.preferences && meta.preferences != null) { if (meta.key == UserMetadataKey.preferences && meta.preferences != null) {
avatarColor = meta.preferences?.userAvatarColor ?? AvatarColor.primary;
memoryEnabled = meta.preferences?.memoriesEnabled ?? true; memoryEnabled = meta.preferences?.memoriesEnabled ?? true;
} }
} }
@ -130,12 +117,13 @@ extension on UserEntityData {
id: id, id: id,
email: email, email: email,
name: name, name: name,
isAdmin: isAdmin,
updatedAt: updatedAt,
profileChangedAt: profileChangedAt, profileChangedAt: profileChangedAt,
hasProfileImage: hasProfileImage, hasProfileImage: hasProfileImage,
avatarColor: avatarColor, avatarColor: avatarColor,
memoryEnabled: memoryEnabled, memoryEnabled: memoryEnabled,
isAdmin: isAdmin,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
); );
} }
} }

View file

@ -1,5 +1,4 @@
import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
// TODO: Move to repository once all classes are refactored // TODO: Move to repository once all classes are refactored

View file

@ -3,9 +3,8 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/album/album.model.dart'; import 'package:immich_mobile/domain/models/album/album.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart'; import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:immich_mobile/providers/infrastructure/db.provider.dart'; import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
@ -26,11 +25,9 @@ final driftUsersProvider = FutureProvider.autoDispose<List<UserDto>>((ref) async
id: entity.id, id: entity.id,
name: entity.name, name: entity.name,
email: entity.email, email: entity.email,
isAdmin: entity.isAdmin,
updatedAt: entity.updatedAt,
isPartnerSharedBy: false, isPartnerSharedBy: false,
isPartnerSharedWith: false, isPartnerSharedWith: false,
avatarColor: AvatarColor.primary, avatarColor: entity.avatarColor,
memoryEnabled: true, memoryEnabled: true,
inTimeline: true, inTimeline: true,
profileChangedAt: entity.profileChangedAt, profileChangedAt: entity.profileChangedAt,

View file

@ -147,7 +147,9 @@ class SyncService {
dbUsers, dbUsers,
compare: (UserDto a, UserDto b) => a.id.compareTo(b.id), compare: (UserDto a, UserDto b) => a.id.compareTo(b.id),
both: (UserDto a, UserDto b) { both: (UserDto a, UserDto b) {
if (!a.updatedAt.isAtSameMomentAs(b.updatedAt) || if ((a.updatedAt == null && b.updatedAt != null) ||
(a.updatedAt != null && b.updatedAt == null) ||
(a.updatedAt != null && b.updatedAt != null && !a.updatedAt!.isAtSameMomentAs(b.updatedAt!)) ||
a.isPartnerSharedBy != b.isPartnerSharedBy || a.isPartnerSharedBy != b.isPartnerSharedBy ||
a.isPartnerSharedWith != b.isPartnerSharedWith || a.isPartnerSharedWith != b.isPartnerSharedWith ||
a.inTimeline != b.inTimeline) { a.inTimeline != b.inTimeline) {

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,4 @@
import 'package:immich_mobile/domain/models/user.model.dart'; import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/domain/models/user_metadata.model.dart';
abstract final class UserStub { abstract final class UserStub {
const UserStub._(); const UserStub._();

View file

@ -43,7 +43,9 @@ export class StorageCore {
private storageRepository: StorageRepository, private storageRepository: StorageRepository,
private systemMetadataRepository: SystemMetadataRepository, private systemMetadataRepository: SystemMetadataRepository,
private logger: LoggingRepository, private logger: LoggingRepository,
) {} ) {
this.logger.setContext(StorageCore.name);
}
static create( static create(
assetRepository: AssetRepository, assetRepository: AssetRepository,

View file

@ -591,6 +591,7 @@ from
where where
"user"."updateId" < $1 "user"."updateId" < $1
and "user"."updateId" > $2 and "user"."updateId" > $2
and "id" = $3
order by order by
"user"."updateId" asc "user"."updateId" asc

View file

@ -412,6 +412,7 @@ class AuthUserSync extends BaseSync {
return this.upsertQuery('user', options) return this.upsertQuery('user', options)
.select(columns.syncUser) .select(columns.syncUser)
.select(['isAdmin', 'pinCode', 'oauthId', 'storageLabel', 'quotaSizeInBytes', 'quotaUsageInBytes']) .select(['isAdmin', 'pinCode', 'oauthId', 'storageLabel', 'quotaSizeInBytes', 'quotaUsageInBytes'])
.where('id', '=', options.userId)
.stream(); .stream();
} }
} }

View file

@ -84,4 +84,23 @@ describe(SyncEntityType.AuthUserV1, () => {
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }), expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
]); ]);
}); });
it('should only sync the auth user', async () => {
const { auth, user, ctx } = await setup(await getKyselyDB());
await ctx.newUser();
const response = await ctx.syncStream(auth, [SyncRequestType.AuthUsersV1]);
expect(response).toEqual([
{
ack: expect.any(String),
data: expect.objectContaining({
id: user.id,
isAdmin: false,
}),
type: 'AuthUserV1',
},
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
]);
});
}); });