mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 01:11:20 +03:00
refactor(mobile): remove int user id (#16814)
* refactor: user entity * chore: rebase fixes * refactor: remove int user Id * refactor: migrate store userId from int to string * refactor: rename uid to id * fix: migration * pr feedback --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -40,7 +40,7 @@ class User {
|
||||
});
|
||||
|
||||
static User fromDto(UserDto dto) => User(
|
||||
id: dto.uid,
|
||||
id: dto.id,
|
||||
updatedAt: dto.updatedAt,
|
||||
email: dto.email,
|
||||
name: dto.name,
|
||||
@@ -56,7 +56,7 @@ class User {
|
||||
);
|
||||
|
||||
UserDto toDto() => UserDto(
|
||||
uid: id,
|
||||
id: id,
|
||||
email: email,
|
||||
name: name,
|
||||
isAdmin: isAdmin,
|
||||
|
||||
@@ -78,7 +78,9 @@ class IsarStoreRepository extends IsarDatabaseRepository
|
||||
const (DateTime) => entity.intValue == null
|
||||
? null
|
||||
: DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
||||
const (UserDto) => await IsarUserRepository(_db).get(entity.intValue!),
|
||||
const (UserDto) => entity.strValue == null
|
||||
? null
|
||||
: await IsarUserRepository(_db).getByUserId(entity.strValue!),
|
||||
_ => null,
|
||||
} as T?;
|
||||
|
||||
@@ -89,8 +91,8 @@ class IsarStoreRepository extends IsarDatabaseRepository
|
||||
const (bool) => ((value as bool) ? 1 : 0, null),
|
||||
const (DateTime) => ((value as DateTime).millisecondsSinceEpoch, null),
|
||||
const (UserDto) => (
|
||||
(await IsarUserRepository(_db).update(value as UserDto)).id,
|
||||
null,
|
||||
(await IsarUserRepository(_db).update(value as UserDto)).id,
|
||||
),
|
||||
_ => throw UnsupportedError(
|
||||
"Unsupported primitive type: ${key.type} for key: ${key.name}",
|
||||
|
||||
@@ -11,9 +11,9 @@ class IsarUserRepository extends IsarDatabaseRepository
|
||||
const IsarUserRepository(super.db) : _db = db;
|
||||
|
||||
@override
|
||||
Future<void> delete(List<int> ids) async {
|
||||
Future<void> delete(List<String> ids) async {
|
||||
await transaction(() async {
|
||||
await _db.users.deleteAll(ids);
|
||||
await _db.users.deleteAllById(ids);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,11 +24,6 @@ class IsarUserRepository extends IsarDatabaseRepository
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserDto?> get(int id) async {
|
||||
return (await _db.users.get(id))?.toDto();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<UserDto>> getAll({SortUserBy? sortBy}) async {
|
||||
return (await _db.users
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:openapi/api.dart';
|
||||
abstract final class UserConverter {
|
||||
/// Base user dto used where the complete user object is not required
|
||||
static UserDto fromSimpleUserDto(UserResponseDto dto) => UserDto(
|
||||
uid: dto.id,
|
||||
id: dto.id,
|
||||
email: dto.email,
|
||||
name: dto.name,
|
||||
isAdmin: false,
|
||||
@@ -18,7 +18,7 @@ abstract final class UserConverter {
|
||||
UserPreferencesResponseDto? preferenceDto,
|
||||
]) =>
|
||||
UserDto(
|
||||
uid: adminDto.id,
|
||||
id: adminDto.id,
|
||||
email: adminDto.email,
|
||||
name: adminDto.name,
|
||||
isAdmin: adminDto.isAdmin,
|
||||
@@ -34,7 +34,7 @@ abstract final class UserConverter {
|
||||
);
|
||||
|
||||
static UserDto fromPartnerDto(PartnerResponseDto dto) => UserDto(
|
||||
uid: dto.id,
|
||||
id: dto.id,
|
||||
email: dto.email,
|
||||
name: dto.name,
|
||||
isAdmin: false,
|
||||
|
||||
Reference in New Issue
Block a user