mirror of
https://github.com/zebrajr/immich.git
synced 2025-12-06 12:20:54 +01:00
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:
parent
da5deffd03
commit
097e132fba
BIN
mobile/drift_schemas/main/drift_schema_v5.json
generated
Normal file
BIN
mobile/drift_schemas/main/drift_schema_v5.json
generated
Normal file
Binary file not shown.
|
|
@ -11,7 +11,6 @@ class UserDto {
|
||||||
final bool isAdmin;
|
final bool isAdmin;
|
||||||
final DateTime updatedAt;
|
final DateTime updatedAt;
|
||||||
|
|
||||||
final String? profileImagePath;
|
|
||||||
final AvatarColor avatarColor;
|
final AvatarColor avatarColor;
|
||||||
|
|
||||||
final bool memoryEnabled;
|
final bool memoryEnabled;
|
||||||
|
|
@ -25,18 +24,22 @@ class UserDto {
|
||||||
|
|
||||||
bool get hasQuota => quotaSizeInBytes > 0;
|
bool get hasQuota => quotaSizeInBytes > 0;
|
||||||
|
|
||||||
|
final bool hasProfileImage;
|
||||||
|
final DateTime profileChangedAt;
|
||||||
|
|
||||||
const UserDto({
|
const UserDto({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.isAdmin,
|
required this.isAdmin,
|
||||||
required this.updatedAt,
|
required this.updatedAt,
|
||||||
this.profileImagePath,
|
required this.profileChangedAt,
|
||||||
this.avatarColor = AvatarColor.primary,
|
this.avatarColor = AvatarColor.primary,
|
||||||
this.memoryEnabled = true,
|
this.memoryEnabled = true,
|
||||||
this.inTimeline = false,
|
this.inTimeline = false,
|
||||||
this.isPartnerSharedBy = false,
|
this.isPartnerSharedBy = false,
|
||||||
this.isPartnerSharedWith = false,
|
this.isPartnerSharedWith = false,
|
||||||
|
this.hasProfileImage = false,
|
||||||
this.quotaUsageInBytes = 0,
|
this.quotaUsageInBytes = 0,
|
||||||
this.quotaSizeInBytes = 0,
|
this.quotaSizeInBytes = 0,
|
||||||
});
|
});
|
||||||
|
|
@ -49,14 +52,13 @@ email: $email,
|
||||||
name: $name,
|
name: $name,
|
||||||
isAdmin: $isAdmin,
|
isAdmin: $isAdmin,
|
||||||
updatedAt: $updatedAt,
|
updatedAt: $updatedAt,
|
||||||
profileImagePath: ${profileImagePath ?? '<NA>'},
|
|
||||||
avatarColor: $avatarColor,
|
avatarColor: $avatarColor,
|
||||||
memoryEnabled: $memoryEnabled,
|
memoryEnabled: $memoryEnabled,
|
||||||
inTimeline: $inTimeline,
|
inTimeline: $inTimeline,
|
||||||
isPartnerSharedBy: $isPartnerSharedBy,
|
isPartnerSharedBy: $isPartnerSharedBy,
|
||||||
isPartnerSharedWith: $isPartnerSharedWith,
|
isPartnerSharedWith: $isPartnerSharedWith,
|
||||||
quotaUsageInBytes: $quotaUsageInBytes,
|
hasProfileImage: $hasProfileImage
|
||||||
quotaSizeInBytes: $quotaSizeInBytes,
|
profileChangedAt: $profileChangedAt
|
||||||
}''';
|
}''';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,28 +68,26 @@ quotaSizeInBytes: $quotaSizeInBytes,
|
||||||
String? name,
|
String? name,
|
||||||
bool? isAdmin,
|
bool? isAdmin,
|
||||||
DateTime? updatedAt,
|
DateTime? updatedAt,
|
||||||
String? profileImagePath,
|
|
||||||
AvatarColor? avatarColor,
|
AvatarColor? avatarColor,
|
||||||
bool? memoryEnabled,
|
bool? memoryEnabled,
|
||||||
bool? inTimeline,
|
bool? inTimeline,
|
||||||
bool? isPartnerSharedBy,
|
bool? isPartnerSharedBy,
|
||||||
bool? isPartnerSharedWith,
|
bool? isPartnerSharedWith,
|
||||||
int? quotaUsageInBytes,
|
bool? hasProfileImage,
|
||||||
int? quotaSizeInBytes,
|
DateTime? profileChangedAt,
|
||||||
}) => UserDto(
|
}) => UserDto(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
email: email ?? this.email,
|
email: email ?? this.email,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
isAdmin: isAdmin ?? this.isAdmin,
|
isAdmin: isAdmin ?? this.isAdmin,
|
||||||
updatedAt: updatedAt ?? this.updatedAt,
|
updatedAt: updatedAt ?? this.updatedAt,
|
||||||
profileImagePath: profileImagePath ?? this.profileImagePath,
|
|
||||||
avatarColor: avatarColor ?? this.avatarColor,
|
avatarColor: avatarColor ?? this.avatarColor,
|
||||||
memoryEnabled: memoryEnabled ?? this.memoryEnabled,
|
memoryEnabled: memoryEnabled ?? this.memoryEnabled,
|
||||||
inTimeline: inTimeline ?? this.inTimeline,
|
inTimeline: inTimeline ?? this.inTimeline,
|
||||||
isPartnerSharedBy: isPartnerSharedBy ?? this.isPartnerSharedBy,
|
isPartnerSharedBy: isPartnerSharedBy ?? this.isPartnerSharedBy,
|
||||||
isPartnerSharedWith: isPartnerSharedWith ?? this.isPartnerSharedWith,
|
isPartnerSharedWith: isPartnerSharedWith ?? this.isPartnerSharedWith,
|
||||||
quotaUsageInBytes: quotaUsageInBytes ?? this.quotaUsageInBytes,
|
hasProfileImage: hasProfileImage ?? this.hasProfileImage,
|
||||||
quotaSizeInBytes: quotaSizeInBytes ?? this.quotaSizeInBytes,
|
profileChangedAt: profileChangedAt ?? this.profileChangedAt,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -101,12 +101,11 @@ quotaSizeInBytes: $quotaSizeInBytes,
|
||||||
other.name == name &&
|
other.name == name &&
|
||||||
other.isPartnerSharedBy == isPartnerSharedBy &&
|
other.isPartnerSharedBy == isPartnerSharedBy &&
|
||||||
other.isPartnerSharedWith == isPartnerSharedWith &&
|
other.isPartnerSharedWith == isPartnerSharedWith &&
|
||||||
other.profileImagePath == profileImagePath &&
|
|
||||||
other.isAdmin == isAdmin &&
|
other.isAdmin == isAdmin &&
|
||||||
other.memoryEnabled == memoryEnabled &&
|
other.memoryEnabled == memoryEnabled &&
|
||||||
other.inTimeline == inTimeline &&
|
other.inTimeline == inTimeline &&
|
||||||
other.quotaUsageInBytes == quotaUsageInBytes &&
|
other.hasProfileImage == hasProfileImage &&
|
||||||
other.quotaSizeInBytes == quotaSizeInBytes;
|
other.profileChangedAt.isAtSameMomentAs(profileChangedAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -116,14 +115,13 @@ quotaSizeInBytes: $quotaSizeInBytes,
|
||||||
email.hashCode ^
|
email.hashCode ^
|
||||||
updatedAt.hashCode ^
|
updatedAt.hashCode ^
|
||||||
isAdmin.hashCode ^
|
isAdmin.hashCode ^
|
||||||
profileImagePath.hashCode ^
|
|
||||||
avatarColor.hashCode ^
|
avatarColor.hashCode ^
|
||||||
memoryEnabled.hashCode ^
|
memoryEnabled.hashCode ^
|
||||||
inTimeline.hashCode ^
|
inTimeline.hashCode ^
|
||||||
isPartnerSharedBy.hashCode ^
|
isPartnerSharedBy.hashCode ^
|
||||||
isPartnerSharedWith.hashCode ^
|
isPartnerSharedWith.hashCode ^
|
||||||
quotaUsageInBytes.hashCode ^
|
hasProfileImage.hashCode ^
|
||||||
quotaSizeInBytes.hashCode;
|
profileChangedAt.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PartnerUserDto {
|
class PartnerUserDto {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class UserService {
|
||||||
Future<String?> createProfileImage(String name, Uint8List image) async {
|
Future<String?> createProfileImage(String name, Uint8List image) async {
|
||||||
try {
|
try {
|
||||||
final path = await _userApiRepository.createProfileImage(name: name, data: image);
|
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 _storeService.put(StoreKey.currentUser, updatedUser);
|
||||||
await _isarUserRepository.update(updatedUser);
|
await _isarUserRepository.update(updatedUser);
|
||||||
return path;
|
return path;
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,10 @@ class User {
|
||||||
isAdmin: dto.isAdmin,
|
isAdmin: dto.isAdmin,
|
||||||
isPartnerSharedBy: dto.isPartnerSharedBy,
|
isPartnerSharedBy: dto.isPartnerSharedBy,
|
||||||
isPartnerSharedWith: dto.isPartnerSharedWith,
|
isPartnerSharedWith: dto.isPartnerSharedWith,
|
||||||
profileImagePath: dto.profileImagePath ?? "",
|
profileImagePath: dto.hasProfileImage ? "HAS_PROFILE_IMAGE" : "",
|
||||||
avatarColor: dto.avatarColor,
|
avatarColor: dto.avatarColor,
|
||||||
memoryEnabled: dto.memoryEnabled,
|
memoryEnabled: dto.memoryEnabled,
|
||||||
inTimeline: dto.inTimeline,
|
inTimeline: dto.inTimeline,
|
||||||
quotaUsageInBytes: dto.quotaUsageInBytes,
|
|
||||||
quotaSizeInBytes: dto.quotaSizeInBytes,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
UserDto toDto() => UserDto(
|
UserDto toDto() => UserDto(
|
||||||
|
|
@ -64,12 +62,13 @@ class User {
|
||||||
name: name,
|
name: name,
|
||||||
isAdmin: isAdmin,
|
isAdmin: isAdmin,
|
||||||
updatedAt: updatedAt,
|
updatedAt: updatedAt,
|
||||||
profileImagePath: profileImagePath.isEmpty ? null : profileImagePath,
|
|
||||||
avatarColor: avatarColor,
|
avatarColor: avatarColor,
|
||||||
memoryEnabled: memoryEnabled,
|
memoryEnabled: memoryEnabled,
|
||||||
inTimeline: inTimeline,
|
inTimeline: inTimeline,
|
||||||
isPartnerSharedBy: isPartnerSharedBy,
|
isPartnerSharedBy: isPartnerSharedBy,
|
||||||
isPartnerSharedWith: isPartnerSharedWith,
|
isPartnerSharedWith: isPartnerSharedWith,
|
||||||
|
hasProfileImage: profileImagePath.isNotEmpty,
|
||||||
|
profileChangedAt: updatedAt,
|
||||||
quotaUsageInBytes: quotaUsageInBytes,
|
quotaUsageInBytes: quotaUsageInBytes,
|
||||||
quotaSizeInBytes: quotaSizeInBytes,
|
quotaSizeInBytes: quotaSizeInBytes,
|
||||||
);
|
);
|
||||||
|
|
@ -82,11 +81,11 @@ class UserEntity extends Table with DriftDefaultsMixin {
|
||||||
TextColumn get name => text()();
|
TextColumn get name => text()();
|
||||||
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
|
BoolColumn get isAdmin => boolean().withDefault(const Constant(false))();
|
||||||
TextColumn get email => text()();
|
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)();
|
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
||||||
// Quota
|
|
||||||
IntColumn get quotaSizeInBytes => integer().nullable()();
|
|
||||||
IntColumn get quotaUsageInBytes => integer().withDefault(const Constant(0))();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<Column> get primaryKey => {id};
|
Set<Column> get primaryKey => {id};
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -66,7 +66,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 => 4;
|
int get schemaVersion => 5;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MigrationStrategy get migration => MigrationStrategy(
|
MigrationStrategy get migration => MigrationStrategy(
|
||||||
|
|
@ -94,6 +94,15 @@ class Drift extends $Drift implements IDatabaseRepository {
|
||||||
// asset_face_entity is added
|
// asset_face_entity is added
|
||||||
await m.create(v4.assetFaceEntity);
|
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},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -173,15 +173,14 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
profileImagePath: user.profileImagePath?.isEmpty == true ? null : user.profileImagePath,
|
|
||||||
isAdmin: user.isAdmin,
|
isAdmin: user.isAdmin,
|
||||||
updatedAt: user.updatedAt,
|
updatedAt: user.updatedAt,
|
||||||
quotaSizeInBytes: user.quotaSizeInBytes ?? 0,
|
|
||||||
quotaUsageInBytes: user.quotaUsageInBytes,
|
|
||||||
memoryEnabled: true,
|
memoryEnabled: true,
|
||||||
inTimeline: false,
|
inTimeline: false,
|
||||||
isPartnerSharedBy: false,
|
isPartnerSharedBy: false,
|
||||||
isPartnerSharedWith: false,
|
isPartnerSharedWith: false,
|
||||||
|
profileChangedAt: user.profileChangedAt,
|
||||||
|
hasProfileImage: user.hasProfileImage,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,12 @@ class SyncStreamRepository extends DriftDatabaseRepository {
|
||||||
try {
|
try {
|
||||||
await _db.batch((batch) {
|
await _db.batch((batch) {
|
||||||
for (final user in data) {
|
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));
|
batch.insert(_db.userEntity, companion.copyWith(id: Value(user.id)), onConflict: DoUpdate((_) => companion));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ abstract final class UserConverter {
|
||||||
name: dto.name,
|
name: dto.name,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
profileImagePath: dto.profileImagePath,
|
hasProfileImage: dto.profileImagePath.isNotEmpty,
|
||||||
|
profileChangedAt: dto.profileChangedAt,
|
||||||
avatarColor: dto.avatarColor.toAvatarColor(),
|
avatarColor: dto.avatarColor.toAvatarColor(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -21,14 +22,13 @@ abstract final class UserConverter {
|
||||||
name: adminDto.name,
|
name: adminDto.name,
|
||||||
isAdmin: adminDto.isAdmin,
|
isAdmin: adminDto.isAdmin,
|
||||||
updatedAt: adminDto.updatedAt,
|
updatedAt: adminDto.updatedAt,
|
||||||
profileImagePath: adminDto.profileImagePath,
|
|
||||||
avatarColor: adminDto.avatarColor.toAvatarColor(),
|
avatarColor: adminDto.avatarColor.toAvatarColor(),
|
||||||
memoryEnabled: preferenceDto?.memories.enabled ?? true,
|
memoryEnabled: preferenceDto?.memories.enabled ?? true,
|
||||||
inTimeline: false,
|
inTimeline: false,
|
||||||
isPartnerSharedBy: false,
|
isPartnerSharedBy: false,
|
||||||
isPartnerSharedWith: false,
|
isPartnerSharedWith: false,
|
||||||
quotaUsageInBytes: adminDto.quotaUsageInBytes ?? 0,
|
profileChangedAt: adminDto.profileChangedAt,
|
||||||
quotaSizeInBytes: adminDto.quotaSizeInBytes ?? 0,
|
hasProfileImage: adminDto.profileImagePath.isNotEmpty,
|
||||||
);
|
);
|
||||||
|
|
||||||
static UserDto fromPartnerDto(PartnerResponseDto dto) => UserDto(
|
static UserDto fromPartnerDto(PartnerResponseDto dto) => UserDto(
|
||||||
|
|
@ -37,14 +37,13 @@ abstract final class UserConverter {
|
||||||
name: dto.name,
|
name: dto.name,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
profileImagePath: dto.profileImagePath,
|
|
||||||
avatarColor: dto.avatarColor.toAvatarColor(),
|
avatarColor: dto.avatarColor.toAvatarColor(),
|
||||||
memoryEnabled: false,
|
memoryEnabled: false,
|
||||||
inTimeline: dto.inTimeline ?? false,
|
inTimeline: dto.inTimeline ?? false,
|
||||||
isPartnerSharedBy: false,
|
isPartnerSharedBy: false,
|
||||||
isPartnerSharedWith: false,
|
isPartnerSharedWith: false,
|
||||||
quotaUsageInBytes: 0,
|
profileChangedAt: dto.profileChangedAt,
|
||||||
quotaSizeInBytes: 0,
|
hasProfileImage: dto.profileImagePath.isNotEmpty,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,14 @@ final driftUsersProvider = FutureProvider.autoDispose<List<UserDto>>((ref) async
|
||||||
name: entity.name,
|
name: entity.name,
|
||||||
email: entity.email,
|
email: entity.email,
|
||||||
isAdmin: entity.isAdmin,
|
isAdmin: entity.isAdmin,
|
||||||
profileImagePath: entity.profileImagePath,
|
|
||||||
updatedAt: entity.updatedAt,
|
updatedAt: entity.updatedAt,
|
||||||
quotaSizeInBytes: entity.quotaSizeInBytes ?? 0,
|
|
||||||
quotaUsageInBytes: entity.quotaUsageInBytes,
|
|
||||||
isPartnerSharedBy: false,
|
isPartnerSharedBy: false,
|
||||||
isPartnerSharedWith: false,
|
isPartnerSharedWith: false,
|
||||||
avatarColor: AvatarColor.primary,
|
avatarColor: AvatarColor.primary,
|
||||||
memoryEnabled: true,
|
memoryEnabled: true,
|
||||||
inTimeline: true,
|
inTimeline: true,
|
||||||
|
profileChangedAt: entity.profileChangedAt,
|
||||||
|
hasProfileImage: entity.hasProfileImage,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,6 @@ class AuthNotifier extends StateNotifier<AuthState> {
|
||||||
isAuthenticated: true,
|
isAuthenticated: true,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
isAdmin: user.isAdmin,
|
isAdmin: user.isAdmin,
|
||||||
profileImagePath: user.profileImagePath,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ dynamic upgradeDto(dynamic value, String targetType) {
|
||||||
addDefault(value, 'isOnboarded', false);
|
addDefault(value, 'isOnboarded', false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'SyncUserV1':
|
||||||
|
if (value is Map) {
|
||||||
|
addDefault(value, 'profileChangedAt', DateTime.now().toIso8601String());
|
||||||
|
addDefault(value, 'hasProfileImage', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class UserCircleAvatar extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
child: Text(user.name[0].toUpperCase()),
|
child: Text(user.name[0].toUpperCase()),
|
||||||
);
|
);
|
||||||
|
|
||||||
return Tooltip(
|
return Tooltip(
|
||||||
message: user.name,
|
message: user.name,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|
@ -42,13 +43,12 @@ class UserCircleAvatar extends ConsumerWidget {
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
backgroundColor: userAvatarColor,
|
backgroundColor: userAvatarColor,
|
||||||
radius: radius,
|
radius: radius,
|
||||||
child: user.profileImagePath == null
|
child: user.hasProfileImage
|
||||||
? textIcon
|
? ClipRRect(
|
||||||
: ClipRRect(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(50)),
|
borderRadius: const BorderRadius.all(Radius.circular(50)),
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
cacheKey: user.profileImagePath,
|
cacheKey: user.profileChangedAt.toIso8601String(),
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
placeholder: (_, __) => Image.memory(kTransparentImage),
|
placeholder: (_, __) => Image.memory(kTransparentImage),
|
||||||
|
|
@ -57,7 +57,8 @@ class UserCircleAvatar extends ConsumerWidget {
|
||||||
fadeInDuration: const Duration(milliseconds: 300),
|
fadeInDuration: const Duration(milliseconds: 300),
|
||||||
errorWidget: (context, error, stackTrace) => textIcon,
|
errorWidget: (context, error, stackTrace) => textIcon,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: textIcon,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
BIN
mobile/openapi/lib/model/sync_user_v1.dart
generated
BIN
mobile/openapi/lib/model/sync_user_v1.dart
generated
Binary file not shown.
|
|
@ -98,7 +98,7 @@ void main() {
|
||||||
group('createProfileImage', () {
|
group('createProfileImage', () {
|
||||||
test('should return profile image path', () async {
|
test('should return profile image path', () async {
|
||||||
const profileImagePath = 'profile.jpg';
|
const profileImagePath = 'profile.jpg';
|
||||||
final updatedUser = UserStub.admin.copyWith(profileImagePath: profileImagePath);
|
final updatedUser = UserStub.admin;
|
||||||
|
|
||||||
when(
|
when(
|
||||||
() => mockUserApiRepo.createProfileImage(name: profileImagePath, data: Uint8List(0)),
|
() => mockUserApiRepo.createProfileImage(name: profileImagePath, data: Uint8List(0)),
|
||||||
|
|
@ -115,7 +115,7 @@ void main() {
|
||||||
|
|
||||||
test('should return null if profile image creation fails', () async {
|
test('should return null if profile image creation fails', () async {
|
||||||
const profileImagePath = 'profile.jpg';
|
const profileImagePath = 'profile.jpg';
|
||||||
final updatedUser = UserStub.admin.copyWith(profileImagePath: profileImagePath);
|
final updatedUser = UserStub.admin;
|
||||||
|
|
||||||
when(
|
when(
|
||||||
() => mockUserApiRepo.createProfileImage(name: profileImagePath, data: Uint8List(0)),
|
() => mockUserApiRepo.createProfileImage(name: profileImagePath, data: Uint8List(0)),
|
||||||
|
|
|
||||||
BIN
mobile/test/drift/main/generated/schema.dart
generated
BIN
mobile/test/drift/main/generated/schema.dart
generated
Binary file not shown.
BIN
mobile/test/drift/main/generated/schema_v5.dart
generated
Normal file
BIN
mobile/test/drift/main/generated/schema_v5.dart
generated
Normal file
Binary file not shown.
20
mobile/test/fixtures/sync_stream.stub.dart
vendored
20
mobile/test/fixtures/sync_stream.stub.dart
vendored
|
|
@ -4,12 +4,28 @@ import 'package:openapi/api.dart';
|
||||||
abstract final class SyncStreamStub {
|
abstract final class SyncStreamStub {
|
||||||
static final userV1Admin = SyncEvent(
|
static final userV1Admin = SyncEvent(
|
||||||
type: SyncEntityType.userV1,
|
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",
|
ack: "1",
|
||||||
);
|
);
|
||||||
static final userV1User = SyncEvent(
|
static final userV1User = SyncEvent(
|
||||||
type: SyncEntityType.userV1,
|
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",
|
ack: "5",
|
||||||
);
|
);
|
||||||
static final userDeleteV1 = SyncEvent(
|
static final userDeleteV1 = SyncEvent(
|
||||||
|
|
|
||||||
6
mobile/test/fixtures/user.stub.dart
vendored
6
mobile/test/fixtures/user.stub.dart
vendored
|
|
@ -10,7 +10,7 @@ abstract final class UserStub {
|
||||||
name: "admin",
|
name: "admin",
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
updatedAt: DateTime(2021),
|
updatedAt: DateTime(2021),
|
||||||
profileImagePath: null,
|
profileChangedAt: DateTime(2021),
|
||||||
avatarColor: AvatarColor.green,
|
avatarColor: AvatarColor.green,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ abstract final class UserStub {
|
||||||
name: "user1",
|
name: "user1",
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
updatedAt: DateTime(2022),
|
updatedAt: DateTime(2022),
|
||||||
profileImagePath: null,
|
profileChangedAt: DateTime(2022),
|
||||||
avatarColor: AvatarColor.red,
|
avatarColor: AvatarColor.red,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ abstract final class UserStub {
|
||||||
name: "user2",
|
name: "user2",
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
updatedAt: DateTime(2023),
|
updatedAt: DateTime(2023),
|
||||||
profileImagePath: null,
|
profileChangedAt: DateTime(2023),
|
||||||
avatarColor: AvatarColor.primary,
|
avatarColor: AvatarColor.primary,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,14 @@ void main() {
|
||||||
final MockPartnerRepository partnerRepository = MockPartnerRepository();
|
final MockPartnerRepository partnerRepository = MockPartnerRepository();
|
||||||
final MockUserService userService = MockUserService();
|
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;
|
late SyncService s;
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
|
||||||
|
|
@ -15124,19 +15124,28 @@
|
||||||
"email": {
|
"email": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"hasProfileImage": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"profileChangedAt": {
|
||||||
|
"format": "date-time",
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"avatarColor",
|
"avatarColor",
|
||||||
"deletedAt",
|
"deletedAt",
|
||||||
"email",
|
"email",
|
||||||
|
"hasProfileImage",
|
||||||
"id",
|
"id",
|
||||||
"name"
|
"name",
|
||||||
|
"profileChangedAt"
|
||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ export const columns = {
|
||||||
],
|
],
|
||||||
syncAlbumUser: ['album_user.albumsId as albumId', 'album_user.usersId as userId', 'album_user.role'],
|
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'],
|
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'],
|
stack: ['stack.id', 'stack.primaryAssetId', 'ownerId'],
|
||||||
syncAssetExif: [
|
syncAssetExif: [
|
||||||
'asset_exif.assetId',
|
'asset_exif.assetId',
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ export class SyncUserV1 {
|
||||||
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', nullable: true })
|
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', nullable: true })
|
||||||
avatarColor!: UserAvatarColor | null;
|
avatarColor!: UserAvatarColor | null;
|
||||||
deletedAt!: Date | null;
|
deletedAt!: Date | null;
|
||||||
|
hasProfileImage!: boolean;
|
||||||
|
profileChangedAt!: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExtraModel()
|
@ExtraModel()
|
||||||
|
|
@ -74,8 +76,6 @@ export class SyncAuthUserV1 extends SyncUserV1 {
|
||||||
quotaSizeInBytes!: number | null;
|
quotaSizeInBytes!: number | null;
|
||||||
@ApiProperty({ type: 'integer' })
|
@ApiProperty({ type: 'integer' })
|
||||||
quotaUsageInBytes!: number;
|
quotaUsageInBytes!: number;
|
||||||
hasProfileImage!: boolean;
|
|
||||||
profileChangedAt!: Date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExtraModel()
|
@ExtraModel()
|
||||||
|
|
|
||||||
|
|
@ -452,14 +452,14 @@ select
|
||||||
"avatarColor",
|
"avatarColor",
|
||||||
"deletedAt",
|
"deletedAt",
|
||||||
"updateId",
|
"updateId",
|
||||||
|
"profileImagePath",
|
||||||
|
"profileChangedAt",
|
||||||
"isAdmin",
|
"isAdmin",
|
||||||
"pinCode",
|
"pinCode",
|
||||||
"oauthId",
|
"oauthId",
|
||||||
"storageLabel",
|
"storageLabel",
|
||||||
"quotaSizeInBytes",
|
"quotaSizeInBytes",
|
||||||
"quotaUsageInBytes",
|
"quotaUsageInBytes"
|
||||||
"profileImagePath",
|
|
||||||
"profileChangedAt"
|
|
||||||
from
|
from
|
||||||
"user"
|
"user"
|
||||||
where
|
where
|
||||||
|
|
@ -896,7 +896,9 @@ select
|
||||||
"email",
|
"email",
|
||||||
"avatarColor",
|
"avatarColor",
|
||||||
"deletedAt",
|
"deletedAt",
|
||||||
"updateId"
|
"updateId",
|
||||||
|
"profileImagePath",
|
||||||
|
"profileChangedAt"
|
||||||
from
|
from
|
||||||
"user"
|
"user"
|
||||||
where
|
where
|
||||||
|
|
|
||||||
|
|
@ -375,16 +375,7 @@ class AuthUserSync extends BaseSync {
|
||||||
return this.db
|
return this.db
|
||||||
.selectFrom('user')
|
.selectFrom('user')
|
||||||
.select(columns.syncUser)
|
.select(columns.syncUser)
|
||||||
.select([
|
.select(['isAdmin', 'pinCode', 'oauthId', 'storageLabel', 'quotaSizeInBytes', 'quotaUsageInBytes'])
|
||||||
'isAdmin',
|
|
||||||
'pinCode',
|
|
||||||
'oauthId',
|
|
||||||
'storageLabel',
|
|
||||||
'quotaSizeInBytes',
|
|
||||||
'quotaUsageInBytes',
|
|
||||||
'profileImagePath',
|
|
||||||
'profileChangedAt',
|
|
||||||
])
|
|
||||||
.$call(this.upsertTableFilters(ack))
|
.$call(this.upsertTableFilters(ack))
|
||||||
.stream();
|
.stream();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -188,8 +188,8 @@ export class SyncService extends BaseService {
|
||||||
|
|
||||||
const upsertType = SyncEntityType.UserV1;
|
const upsertType = SyncEntityType.UserV1;
|
||||||
const upserts = this.syncRepository.user.getUpserts(checkpointMap[upsertType]);
|
const upserts = this.syncRepository.user.getUpserts(checkpointMap[upsertType]);
|
||||||
for await (const { updateId, ...data } of upserts) {
|
for await (const { updateId, profileImagePath, ...data } of upserts) {
|
||||||
send(response, { type: upsertType, ids: [updateId], data });
|
send(response, { type: upsertType, ids: [updateId], data: { ...data, hasProfileImage: !!profileImagePath } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,11 @@ describe(SyncEntityType.UserV1, () => {
|
||||||
data: {
|
data: {
|
||||||
deletedAt: user.deletedAt,
|
deletedAt: user.deletedAt,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
|
hasProfileImage: user.profileImagePath !== '',
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
avatarColor: user.avatarColor,
|
avatarColor: user.avatarColor,
|
||||||
|
profileChangedAt: user.profileChangedAt.toISOString(),
|
||||||
},
|
},
|
||||||
type: 'UserV1',
|
type: 'UserV1',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user