2023-03-04 00:38:30 +02:00
|
|
|
import 'package:immich_mobile/shared/models/album.dart';
|
|
|
|
import 'package:immich_mobile/utils/hash.dart';
|
|
|
|
import 'package:isar/isar.dart';
|
2023-02-06 09:13:32 +02:00
|
|
|
import 'package:openapi/api.dart';
|
|
|
|
|
2023-03-04 00:38:30 +02:00
|
|
|
part 'user.g.dart';
|
|
|
|
|
|
|
|
@Collection(inheritance: false)
|
2023-02-06 09:13:32 +02:00
|
|
|
class User {
|
|
|
|
User({
|
|
|
|
required this.id,
|
2023-03-04 00:38:30 +02:00
|
|
|
required this.updatedAt,
|
2023-02-06 09:13:32 +02:00
|
|
|
required this.email,
|
|
|
|
required this.firstName,
|
|
|
|
required this.lastName,
|
|
|
|
required this.isAdmin,
|
2023-05-25 05:52:43 +02:00
|
|
|
this.isPartnerSharedBy = false,
|
|
|
|
this.isPartnerSharedWith = false,
|
2023-07-28 05:05:27 +02:00
|
|
|
this.profileImagePath = '',
|
2023-08-10 04:01:16 +02:00
|
|
|
this.memoryEnabled = true,
|
2023-02-06 09:13:32 +02:00
|
|
|
});
|
|
|
|
|
2023-03-04 00:38:30 +02:00
|
|
|
Id get isarId => fastHash(id);
|
|
|
|
|
2023-02-06 09:13:32 +02:00
|
|
|
User.fromDto(UserResponseDto dto)
|
|
|
|
: id = dto.id,
|
2023-05-30 15:15:56 +02:00
|
|
|
updatedAt = dto.updatedAt,
|
2023-02-06 09:13:32 +02:00
|
|
|
email = dto.email,
|
|
|
|
firstName = dto.firstName,
|
|
|
|
lastName = dto.lastName,
|
2023-05-25 05:52:43 +02:00
|
|
|
isPartnerSharedBy = false,
|
|
|
|
isPartnerSharedWith = false,
|
2023-07-28 05:05:27 +02:00
|
|
|
profileImagePath = dto.profileImagePath,
|
2023-08-10 04:01:16 +02:00
|
|
|
isAdmin = dto.isAdmin,
|
|
|
|
memoryEnabled = dto.memoriesEnabled;
|
2023-02-06 09:13:32 +02:00
|
|
|
|
2023-03-04 00:38:30 +02:00
|
|
|
@Index(unique: true, replace: false, type: IndexType.hash)
|
2023-02-06 09:13:32 +02:00
|
|
|
String id;
|
2023-03-04 00:38:30 +02:00
|
|
|
DateTime updatedAt;
|
2023-02-06 09:13:32 +02:00
|
|
|
String email;
|
|
|
|
String firstName;
|
|
|
|
String lastName;
|
2023-05-25 05:52:43 +02:00
|
|
|
bool isPartnerSharedBy;
|
|
|
|
bool isPartnerSharedWith;
|
2023-02-06 09:13:32 +02:00
|
|
|
bool isAdmin;
|
2023-07-28 05:05:27 +02:00
|
|
|
String profileImagePath;
|
2023-08-14 19:52:06 +02:00
|
|
|
bool? memoryEnabled;
|
2023-03-04 00:38:30 +02:00
|
|
|
@Backlink(to: 'owner')
|
|
|
|
final IsarLinks<Album> albums = IsarLinks<Album>();
|
|
|
|
@Backlink(to: 'sharedUsers')
|
|
|
|
final IsarLinks<Album> sharedAlbums = IsarLinks<Album>();
|
2023-02-06 09:13:32 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(other) {
|
|
|
|
if (other is! User) return false;
|
|
|
|
return id == other.id &&
|
2023-05-25 05:52:43 +02:00
|
|
|
updatedAt.isAtSameMomentAs(other.updatedAt) &&
|
2023-02-06 09:13:32 +02:00
|
|
|
email == other.email &&
|
|
|
|
firstName == other.firstName &&
|
|
|
|
lastName == other.lastName &&
|
2023-05-25 05:52:43 +02:00
|
|
|
isPartnerSharedBy == other.isPartnerSharedBy &&
|
|
|
|
isPartnerSharedWith == other.isPartnerSharedWith &&
|
2023-07-28 05:05:27 +02:00
|
|
|
profileImagePath == other.profileImagePath &&
|
2023-08-10 04:01:16 +02:00
|
|
|
isAdmin == other.isAdmin &&
|
|
|
|
memoryEnabled == other.memoryEnabled;
|
2023-02-06 09:13:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2023-03-04 00:38:30 +02:00
|
|
|
@ignore
|
2023-02-06 09:13:32 +02:00
|
|
|
int get hashCode =>
|
|
|
|
id.hashCode ^
|
2023-03-04 00:38:30 +02:00
|
|
|
updatedAt.hashCode ^
|
2023-02-06 09:13:32 +02:00
|
|
|
email.hashCode ^
|
|
|
|
firstName.hashCode ^
|
|
|
|
lastName.hashCode ^
|
2023-05-25 05:52:43 +02:00
|
|
|
isPartnerSharedBy.hashCode ^
|
|
|
|
isPartnerSharedWith.hashCode ^
|
2023-07-28 05:05:27 +02:00
|
|
|
profileImagePath.hashCode ^
|
2023-08-10 04:01:16 +02:00
|
|
|
isAdmin.hashCode ^
|
|
|
|
memoryEnabled.hashCode;
|
2023-02-06 09:13:32 +02:00
|
|
|
}
|