fix: user profile images not working in beta timeline (#20203)

* fix user icons in album view

* revert updateUsersV1 change

* fix: UserDto merge issues

* fix: update user entity

* revert what I thought were merge issues

turns out drift cant figure out when it needs to gen a file...

* fix removed line

* handle defaults for older servers

* feat: checkpoint migrations

* fix: use parenthesis instead of brackets

* Update 1753800911775-ProfileImageCheckpointRemoval.ts

* fix: sync stream updateUsersV1
This commit is contained in:
Brandon Wees 2025-07-30 11:09:28 -05:00 committed by GitHub
parent da5deffd03
commit 097e132fba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 7069 additions and 282 deletions

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,6 @@ class UserDto {
final bool isAdmin;
final DateTime updatedAt;
final String? profileImagePath;
final AvatarColor avatarColor;
final bool memoryEnabled;
@ -25,18 +24,22 @@ class UserDto {
bool get hasQuota => quotaSizeInBytes > 0;
final bool hasProfileImage;
final DateTime profileChangedAt;
const UserDto({
required this.id,
required this.email,
required this.name,
required this.isAdmin,
required this.updatedAt,
this.profileImagePath,
required this.profileChangedAt,
this.avatarColor = AvatarColor.primary,
this.memoryEnabled = true,
this.inTimeline = false,
this.isPartnerSharedBy = false,
this.isPartnerSharedWith = false,
this.hasProfileImage = false,
this.quotaUsageInBytes = 0,
this.quotaSizeInBytes = 0,
});
@ -49,14 +52,13 @@ email: $email,
name: $name,
isAdmin: $isAdmin,
updatedAt: $updatedAt,
profileImagePath: ${profileImagePath ?? '<NA>'},
avatarColor: $avatarColor,
memoryEnabled: $memoryEnabled,
inTimeline: $inTimeline,
isPartnerSharedBy: $isPartnerSharedBy,
isPartnerSharedWith: $isPartnerSharedWith,
quotaUsageInBytes: $quotaUsageInBytes,
quotaSizeInBytes: $quotaSizeInBytes,
hasProfileImage: $hasProfileImage
profileChangedAt: $profileChangedAt
}''';
}
@ -66,28 +68,26 @@ quotaSizeInBytes: $quotaSizeInBytes,
String? name,
bool? isAdmin,
DateTime? updatedAt,
String? profileImagePath,
AvatarColor? avatarColor,
bool? memoryEnabled,
bool? inTimeline,
bool? isPartnerSharedBy,
bool? isPartnerSharedWith,
int? quotaUsageInBytes,
int? quotaSizeInBytes,
bool? hasProfileImage,
DateTime? profileChangedAt,
}) => UserDto(
id: id ?? this.id,
email: email ?? this.email,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
updatedAt: updatedAt ?? this.updatedAt,
profileImagePath: profileImagePath ?? this.profileImagePath,
avatarColor: avatarColor ?? this.avatarColor,
memoryEnabled: memoryEnabled ?? this.memoryEnabled,
inTimeline: inTimeline ?? this.inTimeline,
isPartnerSharedBy: isPartnerSharedBy ?? this.isPartnerSharedBy,
isPartnerSharedWith: isPartnerSharedWith ?? this.isPartnerSharedWith,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
);
@override
@ -101,12 +101,11 @@ quotaSizeInBytes: $quotaSizeInBytes,
other.name == name &&
other.isPartnerSharedBy == isPartnerSharedBy &&
other.isPartnerSharedWith == isPartnerSharedWith &&
other.profileImagePath == profileImagePath &&
other.isAdmin == isAdmin &&
other.memoryEnabled == memoryEnabled &&
other.inTimeline == inTimeline &&
other.quotaUsageInBytes == quotaUsageInBytes &&
other.quotaSizeInBytes == quotaSizeInBytes;
other.hasProfileImage == hasProfileImage &&
other.profileChangedAt.isAtSameMomentAs(profileChangedAt);
}
@override
@ -116,14 +115,13 @@ quotaSizeInBytes: $quotaSizeInBytes,
email.hashCode ^
updatedAt.hashCode ^
isAdmin.hashCode ^
profileImagePath.hashCode ^
avatarColor.hashCode ^
memoryEnabled.hashCode ^
inTimeline.hashCode ^
isPartnerSharedBy.hashCode ^
isPartnerSharedWith.hashCode ^
quotaUsageInBytes.hashCode ^
quotaSizeInBytes.hashCode;
hasProfileImage.hashCode ^
profileChangedAt.hashCode;
}
class PartnerUserDto {

View File

@ -45,7 +45,7 @@ class UserService {
Future<String?> createProfileImage(String name, Uint8List image) async {
try {
final path = await _userApiRepository.createProfileImage(name: name, data: image);
final updatedUser = getMyUser().copyWith(profileImagePath: path);
final updatedUser = getMyUser();
await _storeService.put(StoreKey.currentUser, updatedUser);
await _isarUserRepository.update(updatedUser);
return path;

View File

@ -50,12 +50,10 @@ class User {
isAdmin: dto.isAdmin,
isPartnerSharedBy: dto.isPartnerSharedBy,
isPartnerSharedWith: dto.isPartnerSharedWith,
profileImagePath: dto.profileImagePath ?? "",
profileImagePath: dto.hasProfileImage ? "HAS_PROFILE_IMAGE" : "",
avatarColor: dto.avatarColor,
memoryEnabled: dto.memoryEnabled,
inTimeline: dto.inTimeline,
quotaUsageInBytes: dto.quotaUsageInBytes,
quotaSizeInBytes: dto.quotaSizeInBytes,
);
UserDto toDto() => UserDto(
@ -64,12 +62,13 @@ class User {
name: name,
isAdmin: isAdmin,
updatedAt: updatedAt,
profileImagePath: profileImagePath.isEmpty ? null : profileImagePath,
avatarColor: avatarColor,
memoryEnabled: memoryEnabled,
inTimeline: inTimeline,
isPartnerSharedBy: isPartnerSharedBy,
isPartnerSharedWith: isPartnerSharedWith,
hasProfileImage: profileImagePath.isNotEmpty,
profileChangedAt: updatedAt,
quotaUsageInBytes: quotaUsageInBytes,
quotaSizeInBytes: quotaSizeInBytes,
);
@ -82,11 +81,11 @@ class UserEntity extends Table with DriftDefaultsMixin {
TextColumn get name => text()();
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
TextColumn get email => text()();
TextColumn get profileImagePath => text().nullable()();
BoolColumn get hasProfileImage => boolean().withDefault(const Constant(false))();
DateTimeColumn get profileChangedAt => dateTime().withDefault(currentDateAndTime)();
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
// Quota
IntColumn get quotaSizeInBytes => integer().nullable()();
IntColumn get quotaUsageInBytes => integer().withDefault(const Constant(0))();
@override
Set<Column> get primaryKey => {id};

View File

@ -12,10 +12,9 @@ typedef $$UserEntityTableCreateCompanionBuilder =
required String name,
i0.Value<bool> isAdmin,
required String email,
i0.Value<String?> profileImagePath,
i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt,
i0.Value<DateTime> updatedAt,
i0.Value<int?> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
});
typedef $$UserEntityTableUpdateCompanionBuilder =
i1.UserEntityCompanion Function({
@ -23,10 +22,9 @@ typedef $$UserEntityTableUpdateCompanionBuilder =
i0.Value<String> name,
i0.Value<bool> isAdmin,
i0.Value<String> email,
i0.Value<String?> profileImagePath,
i0.Value<bool> hasProfileImage,
i0.Value<DateTime> profileChangedAt,
i0.Value<DateTime> updatedAt,
i0.Value<int?> quotaSizeInBytes,
i0.Value<int> quotaUsageInBytes,
});
class $$UserEntityTableFilterComposer
@ -58,8 +56,13 @@ class $$UserEntityTableFilterComposer
builder: (column) => i0.ColumnFilters(column),
);
i0.ColumnFilters<String> get profileImagePath => $composableBuilder(
column: $table.profileImagePath,
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),
);
@ -67,16 +70,6 @@ class $$UserEntityTableFilterComposer
column: $table.updatedAt,
builder: (column) => i0.ColumnFilters(column),
);
i0.ColumnFilters<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => i0.ColumnFilters(column),
);
i0.ColumnFilters<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
builder: (column) => i0.ColumnFilters(column),
);
}
class $$UserEntityTableOrderingComposer
@ -108,8 +101,13 @@ class $$UserEntityTableOrderingComposer
builder: (column) => i0.ColumnOrderings(column),
);
i0.ColumnOrderings<String> get profileImagePath => $composableBuilder(
column: $table.profileImagePath,
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),
);
@ -117,16 +115,6 @@ class $$UserEntityTableOrderingComposer
column: $table.updatedAt,
builder: (column) => i0.ColumnOrderings(column),
);
i0.ColumnOrderings<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => i0.ColumnOrderings(column),
);
i0.ColumnOrderings<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
builder: (column) => i0.ColumnOrderings(column),
);
}
class $$UserEntityTableAnnotationComposer
@ -150,23 +138,18 @@ class $$UserEntityTableAnnotationComposer
i0.GeneratedColumn<String> get email =>
$composableBuilder(column: $table.email, builder: (column) => column);
i0.GeneratedColumn<String> get profileImagePath => $composableBuilder(
column: $table.profileImagePath,
i0.GeneratedColumn<bool> get hasProfileImage => $composableBuilder(
column: $table.hasProfileImage,
builder: (column) => column,
);
i0.GeneratedColumn<DateTime> get profileChangedAt => $composableBuilder(
column: $table.profileChangedAt,
builder: (column) => column,
);
i0.GeneratedColumn<DateTime> get updatedAt =>
$composableBuilder(column: $table.updatedAt, builder: (column) => column);
i0.GeneratedColumn<int> get quotaSizeInBytes => $composableBuilder(
column: $table.quotaSizeInBytes,
builder: (column) => column,
);
i0.GeneratedColumn<int> get quotaUsageInBytes => $composableBuilder(
column: $table.quotaUsageInBytes,
builder: (column) => column,
);
}
class $$UserEntityTableTableManager
@ -210,19 +193,17 @@ class $$UserEntityTableTableManager
i0.Value<String> name = const i0.Value.absent(),
i0.Value<bool> isAdmin = const i0.Value.absent(),
i0.Value<String> email = const i0.Value.absent(),
i0.Value<String?> profileImagePath = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<DateTime> updatedAt = const i0.Value.absent(),
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
}) => i1.UserEntityCompanion(
id: id,
name: name,
isAdmin: isAdmin,
email: email,
profileImagePath: profileImagePath,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
updatedAt: updatedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
),
createCompanionCallback:
({
@ -230,19 +211,17 @@ class $$UserEntityTableTableManager
required String name,
i0.Value<bool> isAdmin = const i0.Value.absent(),
required String email,
i0.Value<String?> profileImagePath = const i0.Value.absent(),
i0.Value<bool> hasProfileImage = const i0.Value.absent(),
i0.Value<DateTime> profileChangedAt = const i0.Value.absent(),
i0.Value<DateTime> updatedAt = const i0.Value.absent(),
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
i0.Value<int> quotaUsageInBytes = const i0.Value.absent(),
}) => i1.UserEntityCompanion.insert(
id: id,
name: name,
isAdmin: isAdmin,
email: email,
profileImagePath: profileImagePath,
hasProfileImage: hasProfileImage,
profileChangedAt: profileChangedAt,
updatedAt: updatedAt,
quotaSizeInBytes: quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
@ -326,16 +305,32 @@ class $UserEntityTable extends i2.UserEntity
type: i0.DriftSqlType.string,
requiredDuringInsert: true,
);
static const i0.VerificationMeta _profileImagePathMeta =
const i0.VerificationMeta('profileImagePath');
static const i0.VerificationMeta _hasProfileImageMeta =
const i0.VerificationMeta('hasProfileImage');
@override
late final i0.GeneratedColumn<String> profileImagePath =
i0.GeneratedColumn<String>(
'profile_image_path',
late final i0.GeneratedColumn<bool> hasProfileImage =
i0.GeneratedColumn<bool>(
'has_profile_image',
aliasedName,
true,
type: i0.DriftSqlType.string,
false,
type: i0.DriftSqlType.bool,
requiredDuringInsert: false,
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
'CHECK ("has_profile_image" IN (0, 1))',
),
defaultValue: const i3.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: i3.currentDateAndTime,
);
static const i0.VerificationMeta _updatedAtMeta = const i0.VerificationMeta(
'updatedAt',
@ -350,38 +345,15 @@ class $UserEntityTable extends i2.UserEntity
requiredDuringInsert: false,
defaultValue: i3.currentDateAndTime,
);
static const i0.VerificationMeta _quotaSizeInBytesMeta =
const i0.VerificationMeta('quotaSizeInBytes');
@override
late final i0.GeneratedColumn<int> quotaSizeInBytes = i0.GeneratedColumn<int>(
'quota_size_in_bytes',
aliasedName,
true,
type: i0.DriftSqlType.int,
requiredDuringInsert: false,
);
static const i0.VerificationMeta _quotaUsageInBytesMeta =
const i0.VerificationMeta('quotaUsageInBytes');
@override
late final i0.GeneratedColumn<int> quotaUsageInBytes =
i0.GeneratedColumn<int>(
'quota_usage_in_bytes',
aliasedName,
false,
type: i0.DriftSqlType.int,
requiredDuringInsert: false,
defaultValue: const i3.Constant(0),
);
@override
List<i0.GeneratedColumn> get $columns => [
id,
name,
isAdmin,
email,
profileImagePath,
hasProfileImage,
profileChangedAt,
updatedAt,
quotaSizeInBytes,
quotaUsageInBytes,
];
@override
String get aliasedName => _alias ?? actualTableName;
@ -422,12 +394,21 @@ class $UserEntityTable extends i2.UserEntity
} else if (isInserting) {
context.missing(_emailMeta);
}
if (data.containsKey('profile_image_path')) {
if (data.containsKey('has_profile_image')) {
context.handle(
_profileImagePathMeta,
profileImagePath.isAcceptableOrUnknown(
data['profile_image_path']!,
_profileImagePathMeta,
_hasProfileImageMeta,
hasProfileImage.isAcceptableOrUnknown(
data['has_profile_image']!,
_hasProfileImageMeta,
),
);
}
if (data.containsKey('profile_changed_at')) {
context.handle(
_profileChangedAtMeta,
profileChangedAt.isAcceptableOrUnknown(
data['profile_changed_at']!,
_profileChangedAtMeta,
),
);
}
@ -437,24 +418,6 @@ class $UserEntityTable extends i2.UserEntity
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta),
);
}
if (data.containsKey('quota_size_in_bytes')) {
context.handle(
_quotaSizeInBytesMeta,
quotaSizeInBytes.isAcceptableOrUnknown(
data['quota_size_in_bytes']!,
_quotaSizeInBytesMeta,
),
);
}
if (data.containsKey('quota_usage_in_bytes')) {
context.handle(
_quotaUsageInBytesMeta,
quotaUsageInBytes.isAcceptableOrUnknown(
data['quota_usage_in_bytes']!,
_quotaUsageInBytesMeta,
),
);
}
return context;
}
@ -480,22 +443,18 @@ class $UserEntityTable extends i2.UserEntity
i0.DriftSqlType.string,
data['${effectivePrefix}email'],
)!,
profileImagePath: attachedDatabase.typeMapping.read(
i0.DriftSqlType.string,
data['${effectivePrefix}profile_image_path'],
),
hasProfileImage: attachedDatabase.typeMapping.read(
i0.DriftSqlType.bool,
data['${effectivePrefix}has_profile_image'],
)!,
profileChangedAt: attachedDatabase.typeMapping.read(
i0.DriftSqlType.dateTime,
data['${effectivePrefix}profile_changed_at'],
)!,
updatedAt: attachedDatabase.typeMapping.read(
i0.DriftSqlType.dateTime,
data['${effectivePrefix}updated_at'],
)!,
quotaSizeInBytes: attachedDatabase.typeMapping.read(
i0.DriftSqlType.int,
data['${effectivePrefix}quota_size_in_bytes'],
),
quotaUsageInBytes: attachedDatabase.typeMapping.read(
i0.DriftSqlType.int,
data['${effectivePrefix}quota_usage_in_bytes'],
)!,
);
}
@ -516,19 +475,17 @@ class UserEntityData extends i0.DataClass
final String name;
final bool isAdmin;
final String email;
final String? profileImagePath;
final bool hasProfileImage;
final DateTime profileChangedAt;
final DateTime updatedAt;
final int? quotaSizeInBytes;
final int quotaUsageInBytes;
const UserEntityData({
required this.id,
required this.name,
required this.isAdmin,
required this.email,
this.profileImagePath,
required this.hasProfileImage,
required this.profileChangedAt,
required this.updatedAt,
this.quotaSizeInBytes,
required this.quotaUsageInBytes,
});
@override
Map<String, i0.Expression> toColumns(bool nullToAbsent) {
@ -537,14 +494,9 @@ class UserEntityData extends i0.DataClass
map['name'] = i0.Variable<String>(name);
map['is_admin'] = i0.Variable<bool>(isAdmin);
map['email'] = i0.Variable<String>(email);
if (!nullToAbsent || profileImagePath != null) {
map['profile_image_path'] = i0.Variable<String>(profileImagePath);
}
map['has_profile_image'] = i0.Variable<bool>(hasProfileImage);
map['profile_changed_at'] = i0.Variable<DateTime>(profileChangedAt);
map['updated_at'] = i0.Variable<DateTime>(updatedAt);
if (!nullToAbsent || quotaSizeInBytes != null) {
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes);
}
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes);
return map;
}
@ -558,10 +510,9 @@ class UserEntityData extends i0.DataClass
name: serializer.fromJson<String>(json['name']),
isAdmin: serializer.fromJson<bool>(json['isAdmin']),
email: serializer.fromJson<String>(json['email']),
profileImagePath: serializer.fromJson<String?>(json['profileImagePath']),
hasProfileImage: serializer.fromJson<bool>(json['hasProfileImage']),
profileChangedAt: serializer.fromJson<DateTime>(json['profileChangedAt']),
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
quotaSizeInBytes: serializer.fromJson<int?>(json['quotaSizeInBytes']),
quotaUsageInBytes: serializer.fromJson<int>(json['quotaUsageInBytes']),
);
}
@override
@ -572,10 +523,9 @@ class UserEntityData extends i0.DataClass
'name': serializer.toJson<String>(name),
'isAdmin': serializer.toJson<bool>(isAdmin),
'email': serializer.toJson<String>(email),
'profileImagePath': serializer.toJson<String?>(profileImagePath),
'hasProfileImage': serializer.toJson<bool>(hasProfileImage),
'profileChangedAt': serializer.toJson<DateTime>(profileChangedAt),
'updatedAt': serializer.toJson<DateTime>(updatedAt),
'quotaSizeInBytes': serializer.toJson<int?>(quotaSizeInBytes),
'quotaUsageInBytes': serializer.toJson<int>(quotaUsageInBytes),
};
}
@ -584,23 +534,17 @@ class UserEntityData extends i0.DataClass
String? name,
bool? isAdmin,
String? email,
i0.Value<String?> profileImagePath = const i0.Value.absent(),
bool? hasProfileImage,
DateTime? profileChangedAt,
DateTime? updatedAt,
i0.Value<int?> quotaSizeInBytes = const i0.Value.absent(),
int? quotaUsageInBytes,
}) => i1.UserEntityData(
id: id ?? this.id,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
email: email ?? this.email,
profileImagePath: profileImagePath.present
? profileImagePath.value
: this.profileImagePath,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
updatedAt: updatedAt ?? this.updatedAt,
quotaSizeInBytes: quotaSizeInBytes.present
? quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
);
UserEntityData copyWithCompanion(i1.UserEntityCompanion data) {
return UserEntityData(
@ -608,16 +552,13 @@ class UserEntityData extends i0.DataClass
name: data.name.present ? data.name.value : this.name,
isAdmin: data.isAdmin.present ? data.isAdmin.value : this.isAdmin,
email: data.email.present ? data.email.value : this.email,
profileImagePath: data.profileImagePath.present
? data.profileImagePath.value
: this.profileImagePath,
hasProfileImage: data.hasProfileImage.present
? data.hasProfileImage.value
: this.hasProfileImage,
profileChangedAt: data.profileChangedAt.present
? data.profileChangedAt.value
: this.profileChangedAt,
updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt,
quotaSizeInBytes: data.quotaSizeInBytes.present
? data.quotaSizeInBytes.value
: this.quotaSizeInBytes,
quotaUsageInBytes: data.quotaUsageInBytes.present
? data.quotaUsageInBytes.value
: this.quotaUsageInBytes,
);
}
@ -628,10 +569,9 @@ class UserEntityData extends i0.DataClass
..write('name: $name, ')
..write('isAdmin: $isAdmin, ')
..write('email: $email, ')
..write('profileImagePath: $profileImagePath, ')
..write('updatedAt: $updatedAt, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes')
..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ')
..write('updatedAt: $updatedAt')
..write(')'))
.toString();
}
@ -642,10 +582,9 @@ class UserEntityData extends i0.DataClass
name,
isAdmin,
email,
profileImagePath,
hasProfileImage,
profileChangedAt,
updatedAt,
quotaSizeInBytes,
quotaUsageInBytes,
);
@override
bool operator ==(Object other) =>
@ -655,10 +594,9 @@ class UserEntityData extends i0.DataClass
other.name == this.name &&
other.isAdmin == this.isAdmin &&
other.email == this.email &&
other.profileImagePath == this.profileImagePath &&
other.updatedAt == this.updatedAt &&
other.quotaSizeInBytes == this.quotaSizeInBytes &&
other.quotaUsageInBytes == this.quotaUsageInBytes);
other.hasProfileImage == this.hasProfileImage &&
other.profileChangedAt == this.profileChangedAt &&
other.updatedAt == this.updatedAt);
}
class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
@ -666,29 +604,26 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
final i0.Value<String> name;
final i0.Value<bool> isAdmin;
final i0.Value<String> email;
final i0.Value<String?> profileImagePath;
final i0.Value<bool> hasProfileImage;
final i0.Value<DateTime> profileChangedAt;
final i0.Value<DateTime> updatedAt;
final i0.Value<int?> quotaSizeInBytes;
final i0.Value<int> quotaUsageInBytes;
const UserEntityCompanion({
this.id = const i0.Value.absent(),
this.name = const i0.Value.absent(),
this.isAdmin = const i0.Value.absent(),
this.email = const i0.Value.absent(),
this.profileImagePath = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(),
this.updatedAt = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
});
UserEntityCompanion.insert({
required String id,
required String name,
this.isAdmin = const i0.Value.absent(),
required String email,
this.profileImagePath = const i0.Value.absent(),
this.hasProfileImage = const i0.Value.absent(),
this.profileChangedAt = const i0.Value.absent(),
this.updatedAt = const i0.Value.absent(),
this.quotaSizeInBytes = const i0.Value.absent(),
this.quotaUsageInBytes = const i0.Value.absent(),
}) : id = i0.Value(id),
name = i0.Value(name),
email = i0.Value(email);
@ -697,20 +632,18 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
i0.Expression<String>? name,
i0.Expression<bool>? isAdmin,
i0.Expression<String>? email,
i0.Expression<String>? profileImagePath,
i0.Expression<bool>? hasProfileImage,
i0.Expression<DateTime>? profileChangedAt,
i0.Expression<DateTime>? updatedAt,
i0.Expression<int>? quotaSizeInBytes,
i0.Expression<int>? quotaUsageInBytes,
}) {
return i0.RawValuesInsertable({
if (id != null) 'id': id,
if (name != null) 'name': name,
if (isAdmin != null) 'is_admin': isAdmin,
if (email != null) 'email': email,
if (profileImagePath != null) 'profile_image_path': profileImagePath,
if (hasProfileImage != null) 'has_profile_image': hasProfileImage,
if (profileChangedAt != null) 'profile_changed_at': profileChangedAt,
if (updatedAt != null) 'updated_at': updatedAt,
if (quotaSizeInBytes != null) 'quota_size_in_bytes': quotaSizeInBytes,
if (quotaUsageInBytes != null) 'quota_usage_in_bytes': quotaUsageInBytes,
});
}
@ -719,20 +652,18 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
i0.Value<String>? name,
i0.Value<bool>? isAdmin,
i0.Value<String>? email,
i0.Value<String?>? profileImagePath,
i0.Value<bool>? hasProfileImage,
i0.Value<DateTime>? profileChangedAt,
i0.Value<DateTime>? updatedAt,
i0.Value<int?>? quotaSizeInBytes,
i0.Value<int>? quotaUsageInBytes,
}) {
return i1.UserEntityCompanion(
id: id ?? this.id,
name: name ?? this.name,
isAdmin: isAdmin ?? this.isAdmin,
email: email ?? this.email,
profileImagePath: profileImagePath ?? this.profileImagePath,
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
updatedAt: updatedAt ?? this.updatedAt,
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
);
}
@ -751,18 +682,15 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
if (email.present) {
map['email'] = i0.Variable<String>(email.value);
}
if (profileImagePath.present) {
map['profile_image_path'] = i0.Variable<String>(profileImagePath.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 (updatedAt.present) {
map['updated_at'] = i0.Variable<DateTime>(updatedAt.value);
}
if (quotaSizeInBytes.present) {
map['quota_size_in_bytes'] = i0.Variable<int>(quotaSizeInBytes.value);
}
if (quotaUsageInBytes.present) {
map['quota_usage_in_bytes'] = i0.Variable<int>(quotaUsageInBytes.value);
}
return map;
}
@ -773,10 +701,9 @@ class UserEntityCompanion extends i0.UpdateCompanion<i1.UserEntityData> {
..write('name: $name, ')
..write('isAdmin: $isAdmin, ')
..write('email: $email, ')
..write('profileImagePath: $profileImagePath, ')
..write('updatedAt: $updatedAt, ')
..write('quotaSizeInBytes: $quotaSizeInBytes, ')
..write('quotaUsageInBytes: $quotaUsageInBytes')
..write('hasProfileImage: $hasProfileImage, ')
..write('profileChangedAt: $profileChangedAt, ')
..write('updatedAt: $updatedAt')
..write(')'))
.toString();
}

View File

@ -66,7 +66,7 @@ class Drift extends $Drift implements IDatabaseRepository {
: super(executor ?? driftDatabase(name: 'immich', native: const DriftNativeOptions(shareAcrossIsolates: true)));
@override
int get schemaVersion => 4;
int get schemaVersion => 5;
@override
MigrationStrategy get migration => MigrationStrategy(
@ -94,6 +94,15 @@ class Drift extends $Drift implements IDatabaseRepository {
// asset_face_entity is added
await m.create(v4.assetFaceEntity);
},
from4To5: (m, v5) async {
await m.alterTable(
TableMigration(
v5.userEntity,
newColumns: [v5.userEntity.hasProfileImage, v5.userEntity.profileChangedAt],
columnTransformer: {v5.userEntity.profileChangedAt: currentDateAndTime},
),
);
},
),
);

View File

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

View File

@ -173,15 +173,14 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
id: user.id,
email: user.email,
name: user.name,
profileImagePath: user.profileImagePath?.isEmpty == true ? null : user.profileImagePath,
isAdmin: user.isAdmin,
updatedAt: user.updatedAt,
quotaSizeInBytes: user.quotaSizeInBytes ?? 0,
quotaUsageInBytes: user.quotaUsageInBytes,
memoryEnabled: true,
inTimeline: false,
isPartnerSharedBy: false,
isPartnerSharedWith: false,
profileChangedAt: user.profileChangedAt,
hasProfileImage: user.hasProfileImage,
),
)
.get();

View File

@ -42,7 +42,12 @@ class SyncStreamRepository extends DriftDatabaseRepository {
try {
await _db.batch((batch) {
for (final user in data) {
final companion = UserEntityCompanion(name: Value(user.name), email: Value(user.email));
final companion = UserEntityCompanion(
name: Value(user.name),
email: Value(user.email),
hasProfileImage: Value(user.hasProfileImage),
profileChangedAt: Value(user.profileChangedAt),
);
batch.insert(_db.userEntity, companion.copyWith(id: Value(user.id)), onConflict: DoUpdate((_) => companion));
}

View File

@ -11,7 +11,8 @@ abstract final class UserConverter {
name: dto.name,
isAdmin: false,
updatedAt: DateTime.now(),
profileImagePath: dto.profileImagePath,
hasProfileImage: dto.profileImagePath.isNotEmpty,
profileChangedAt: dto.profileChangedAt,
avatarColor: dto.avatarColor.toAvatarColor(),
);
@ -21,14 +22,13 @@ abstract final class UserConverter {
name: adminDto.name,
isAdmin: adminDto.isAdmin,
updatedAt: adminDto.updatedAt,
profileImagePath: adminDto.profileImagePath,
avatarColor: adminDto.avatarColor.toAvatarColor(),
memoryEnabled: preferenceDto?.memories.enabled ?? true,
inTimeline: false,
isPartnerSharedBy: false,
isPartnerSharedWith: false,
quotaUsageInBytes: adminDto.quotaUsageInBytes ?? 0,
quotaSizeInBytes: adminDto.quotaSizeInBytes ?? 0,
profileChangedAt: adminDto.profileChangedAt,
hasProfileImage: adminDto.profileImagePath.isNotEmpty,
);
static UserDto fromPartnerDto(PartnerResponseDto dto) => UserDto(
@ -37,14 +37,13 @@ abstract final class UserConverter {
name: dto.name,
isAdmin: false,
updatedAt: DateTime.now(),
profileImagePath: dto.profileImagePath,
avatarColor: dto.avatarColor.toAvatarColor(),
memoryEnabled: false,
inTimeline: dto.inTimeline ?? false,
isPartnerSharedBy: false,
isPartnerSharedWith: false,
quotaUsageInBytes: 0,
quotaSizeInBytes: 0,
profileChangedAt: dto.profileChangedAt,
hasProfileImage: dto.profileImagePath.isNotEmpty,
);
}

View File

@ -27,15 +27,14 @@ final driftUsersProvider = FutureProvider.autoDispose<List<UserDto>>((ref) async
name: entity.name,
email: entity.email,
isAdmin: entity.isAdmin,
profileImagePath: entity.profileImagePath,
updatedAt: entity.updatedAt,
quotaSizeInBytes: entity.quotaSizeInBytes ?? 0,
quotaUsageInBytes: entity.quotaUsageInBytes,
isPartnerSharedBy: false,
isPartnerSharedWith: false,
avatarColor: AvatarColor.primary,
memoryEnabled: true,
inTimeline: true,
profileChangedAt: entity.profileChangedAt,
hasProfileImage: entity.hasProfileImage,
),
)
.toList();

View File

@ -167,7 +167,6 @@ class AuthNotifier extends StateNotifier<AuthState> {
isAuthenticated: true,
name: user.name,
isAdmin: user.isAdmin,
profileImagePath: user.profileImagePath,
);
return true;

View File

@ -40,6 +40,11 @@ dynamic upgradeDto(dynamic value, String targetType) {
addDefault(value, 'isOnboarded', false);
}
break;
case 'SyncUserV1':
if (value is Map) {
addDefault(value, 'profileChangedAt', DateTime.now().toIso8601String());
addDefault(value, 'hasProfileImage', false);
}
}
}

View File

@ -32,6 +32,7 @@ class UserCircleAvatar extends ConsumerWidget {
),
child: Text(user.name[0].toUpperCase()),
);
return Tooltip(
message: user.name,
child: Container(
@ -42,13 +43,12 @@ class UserCircleAvatar extends ConsumerWidget {
child: CircleAvatar(
backgroundColor: userAvatarColor,
radius: radius,
child: user.profileImagePath == null
? textIcon
: ClipRRect(
child: user.hasProfileImage
? ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(50)),
child: CachedNetworkImage(
fit: BoxFit.cover,
cacheKey: user.profileImagePath,
cacheKey: user.profileChangedAt.toIso8601String(),
width: size,
height: size,
placeholder: (_, __) => Image.memory(kTransparentImage),
@ -57,7 +57,8 @@ class UserCircleAvatar extends ConsumerWidget {
fadeInDuration: const Duration(milliseconds: 300),
errorWidget: (context, error, stackTrace) => textIcon,
),
),
)
: textIcon,
),
),
);

View File

@ -16,8 +16,10 @@ class SyncUserV1 {
required this.avatarColor,
required this.deletedAt,
required this.email,
required this.hasProfileImage,
required this.id,
required this.name,
required this.profileChangedAt,
});
UserAvatarColor? avatarColor;
@ -26,17 +28,23 @@ class SyncUserV1 {
String email;
bool hasProfileImage;
String id;
String name;
DateTime profileChangedAt;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncUserV1 &&
other.avatarColor == avatarColor &&
other.deletedAt == deletedAt &&
other.email == email &&
other.hasProfileImage == hasProfileImage &&
other.id == id &&
other.name == name;
other.name == name &&
other.profileChangedAt == profileChangedAt;
@override
int get hashCode =>
@ -44,11 +52,13 @@ class SyncUserV1 {
(avatarColor == null ? 0 : avatarColor!.hashCode) +
(deletedAt == null ? 0 : deletedAt!.hashCode) +
(email.hashCode) +
(hasProfileImage.hashCode) +
(id.hashCode) +
(name.hashCode);
(name.hashCode) +
(profileChangedAt.hashCode);
@override
String toString() => 'SyncUserV1[avatarColor=$avatarColor, deletedAt=$deletedAt, email=$email, id=$id, name=$name]';
String toString() => 'SyncUserV1[avatarColor=$avatarColor, deletedAt=$deletedAt, email=$email, hasProfileImage=$hasProfileImage, id=$id, name=$name, profileChangedAt=$profileChangedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -63,8 +73,10 @@ class SyncUserV1 {
// json[r'deletedAt'] = null;
}
json[r'email'] = this.email;
json[r'hasProfileImage'] = this.hasProfileImage;
json[r'id'] = this.id;
json[r'name'] = this.name;
json[r'profileChangedAt'] = this.profileChangedAt.toUtc().toIso8601String();
return json;
}
@ -80,8 +92,10 @@ class SyncUserV1 {
avatarColor: UserAvatarColor.fromJson(json[r'avatarColor']),
deletedAt: mapDateTime(json, r'deletedAt', r''),
email: mapValueOfType<String>(json, r'email')!,
hasProfileImage: mapValueOfType<bool>(json, r'hasProfileImage')!,
id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!,
profileChangedAt: mapDateTime(json, r'profileChangedAt', r'')!,
);
}
return null;
@ -132,8 +146,10 @@ class SyncUserV1 {
'avatarColor',
'deletedAt',
'email',
'hasProfileImage',
'id',
'name',
'profileChangedAt',
};
}

View File

@ -98,7 +98,7 @@ void main() {
group('createProfileImage', () {
test('should return profile image path', () async {
const profileImagePath = 'profile.jpg';
final updatedUser = UserStub.admin.copyWith(profileImagePath: profileImagePath);
final updatedUser = UserStub.admin;
when(
() => mockUserApiRepo.createProfileImage(name: profileImagePath, data: Uint8List(0)),
@ -115,7 +115,7 @@ void main() {
test('should return null if profile image creation fails', () async {
const profileImagePath = 'profile.jpg';
final updatedUser = UserStub.admin.copyWith(profileImagePath: profileImagePath);
final updatedUser = UserStub.admin;
when(
() => mockUserApiRepo.createProfileImage(name: profileImagePath, data: Uint8List(0)),

View File

@ -7,6 +7,7 @@ import 'schema_v1.dart' as v1;
import 'schema_v2.dart' as v2;
import 'schema_v3.dart' as v3;
import 'schema_v4.dart' as v4;
import 'schema_v5.dart' as v5;
class GeneratedHelper implements SchemaInstantiationHelper {
@override
@ -20,10 +21,12 @@ class GeneratedHelper implements SchemaInstantiationHelper {
return v3.DatabaseAtV3(db);
case 4:
return v4.DatabaseAtV4(db);
case 5:
return v5.DatabaseAtV5(db);
default:
throw MissingSchemaException(version, versions);
}
}
static const versions = const [1, 2, 3, 4];
static const versions = const [1, 2, 3, 4, 5];
}

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,28 @@ import 'package:openapi/api.dart';
abstract final class SyncStreamStub {
static final userV1Admin = SyncEvent(
type: SyncEntityType.userV1,
data: SyncUserV1(deletedAt: DateTime(2020), email: "admin@admin", id: "1", name: "Admin", avatarColor: null),
data: SyncUserV1(
deletedAt: DateTime(2020),
email: "admin@admin",
id: "1",
name: "Admin",
avatarColor: null,
hasProfileImage: false,
profileChangedAt: DateTime(2025),
),
ack: "1",
);
static final userV1User = SyncEvent(
type: SyncEntityType.userV1,
data: SyncUserV1(deletedAt: DateTime(2021), email: "user@user", id: "5", name: "User", avatarColor: null),
data: SyncUserV1(
deletedAt: DateTime(2021),
email: "user@user",
id: "5",
name: "User",
avatarColor: null,
hasProfileImage: false,
profileChangedAt: DateTime(2025),
),
ack: "5",
);
static final userDeleteV1 = SyncEvent(

View File

@ -10,7 +10,7 @@ abstract final class UserStub {
name: "admin",
isAdmin: true,
updatedAt: DateTime(2021),
profileImagePath: null,
profileChangedAt: DateTime(2021),
avatarColor: AvatarColor.green,
);
@ -20,7 +20,7 @@ abstract final class UserStub {
name: "user1",
isAdmin: false,
updatedAt: DateTime(2022),
profileImagePath: null,
profileChangedAt: DateTime(2022),
avatarColor: AvatarColor.red,
);
@ -30,7 +30,7 @@ abstract final class UserStub {
name: "user2",
isAdmin: false,
updatedAt: DateTime(2023),
profileImagePath: null,
profileChangedAt: DateTime(2023),
avatarColor: AvatarColor.primary,
);
}

View File

@ -66,7 +66,14 @@ void main() {
final MockPartnerRepository partnerRepository = MockPartnerRepository();
final MockUserService userService = MockUserService();
final owner = UserDto(id: "1", updatedAt: DateTime.now(), email: "a@b.c", name: "first last", isAdmin: false);
final owner = UserDto(
id: "1",
updatedAt: DateTime.now(),
email: "a@b.c",
name: "first last",
isAdmin: false,
profileChangedAt: DateTime(2021),
);
late SyncService s;
setUpAll(() async {
WidgetsFlutterBinding.ensureInitialized();

View File

@ -15124,19 +15124,28 @@
"email": {
"type": "string"
},
"hasProfileImage": {
"type": "boolean"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"profileChangedAt": {
"format": "date-time",
"type": "string"
}
},
"required": [
"avatarColor",
"deletedAt",
"email",
"hasProfileImage",
"id",
"name"
"name",
"profileChangedAt"
],
"type": "object"
},

View File

@ -357,7 +357,7 @@ export const columns = {
],
syncAlbumUser: ['album_user.albumsId as albumId', 'album_user.usersId as userId', 'album_user.role'],
syncStack: ['stack.id', 'stack.createdAt', 'stack.updatedAt', 'stack.primaryAssetId', 'stack.ownerId'],
syncUser: ['id', 'name', 'email', 'avatarColor', 'deletedAt', 'updateId'],
syncUser: ['id', 'name', 'email', 'avatarColor', 'deletedAt', 'updateId', 'profileImagePath', 'profileChangedAt'],
stack: ['stack.id', 'stack.primaryAssetId', 'ownerId'],
syncAssetExif: [
'asset_exif.assetId',

View File

@ -62,6 +62,8 @@ export class SyncUserV1 {
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', nullable: true })
avatarColor!: UserAvatarColor | null;
deletedAt!: Date | null;
hasProfileImage!: boolean;
profileChangedAt!: Date;
}
@ExtraModel()
@ -74,8 +76,6 @@ export class SyncAuthUserV1 extends SyncUserV1 {
quotaSizeInBytes!: number | null;
@ApiProperty({ type: 'integer' })
quotaUsageInBytes!: number;
hasProfileImage!: boolean;
profileChangedAt!: Date;
}
@ExtraModel()

View File

@ -452,14 +452,14 @@ select
"avatarColor",
"deletedAt",
"updateId",
"profileImagePath",
"profileChangedAt",
"isAdmin",
"pinCode",
"oauthId",
"storageLabel",
"quotaSizeInBytes",
"quotaUsageInBytes",
"profileImagePath",
"profileChangedAt"
"quotaUsageInBytes"
from
"user"
where
@ -896,7 +896,9 @@ select
"email",
"avatarColor",
"deletedAt",
"updateId"
"updateId",
"profileImagePath",
"profileChangedAt"
from
"user"
where

View File

@ -375,16 +375,7 @@ class AuthUserSync extends BaseSync {
return this.db
.selectFrom('user')
.select(columns.syncUser)
.select([
'isAdmin',
'pinCode',
'oauthId',
'storageLabel',
'quotaSizeInBytes',
'quotaUsageInBytes',
'profileImagePath',
'profileChangedAt',
])
.select(['isAdmin', 'pinCode', 'oauthId', 'storageLabel', 'quotaSizeInBytes', 'quotaUsageInBytes'])
.$call(this.upsertTableFilters(ack))
.stream();
}

View File

@ -0,0 +1,25 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`DELETE FROM session_sync_checkpoint
WHERE type IN (
'UserV1',
'AssetV1',
'PartnerAssetV1',
'PartnerAssetBackfillV1',
'AlbumAssetV1',
'AlbumAssetBackfillV1'
)`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
await sql`DELETE FROM session_sync_checkpoint
WHERE type IN (
'UserV1',
'AssetV1',
'PartnerAssetV1',
'PartnerAssetBackfillV1',
'AlbumAssetV1',
'AlbumAssetBackfillV1'
)`.execute(db);
}

View File

@ -188,8 +188,8 @@ export class SyncService extends BaseService {
const upsertType = SyncEntityType.UserV1;
const upserts = this.syncRepository.user.getUpserts(checkpointMap[upsertType]);
for await (const { updateId, ...data } of upserts) {
send(response, { type: upsertType, ids: [updateId], data });
for await (const { updateId, profileImagePath, ...data } of upserts) {
send(response, { type: upsertType, ids: [updateId], data: { ...data, hasProfileImage: !!profileImagePath } });
}
}

View File

@ -35,9 +35,11 @@ describe(SyncEntityType.UserV1, () => {
data: {
deletedAt: user.deletedAt,
email: user.email,
hasProfileImage: user.profileImagePath !== '',
id: user.id,
name: user.name,
avatarColor: user.avatarColor,
profileChangedAt: user.profileChangedAt.toISOString(),
},
type: 'UserV1',
},