mirror of
https://github.com/immich-app/immich.git
synced 2024-11-28 09:33:27 +02:00
refactor: deduplicate MemoryType and ReactionType enums (#11479)
* refactor: deduplicate memorytype and reactiontype enums * fix mobile
This commit is contained in:
parent
281cfc95a4
commit
b73f7fe16f
@ -43,7 +43,7 @@ class Activity {
|
||||
assetId = dto.assetId,
|
||||
comment = dto.comment,
|
||||
createdAt = dto.createdAt,
|
||||
type = dto.type == ActivityResponseDtoTypeEnum.comment
|
||||
type = dto.type == ReactionType.comment
|
||||
? ActivityType.comment
|
||||
: ActivityType.like,
|
||||
user = User.fromSimpleUserDto(dto.user);
|
||||
|
BIN
mobile/openapi/lib/model/activity_response_dto.dart
generated
BIN
mobile/openapi/lib/model/activity_response_dto.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/memory_response_dto.dart
generated
BIN
mobile/openapi/lib/model/memory_response_dto.dart
generated
Binary file not shown.
@ -7216,11 +7216,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"comment",
|
||||
"like"
|
||||
],
|
||||
"type": "string"
|
||||
"$ref": "#/components/schemas/ReactionType"
|
||||
},
|
||||
"user": {
|
||||
"$ref": "#/components/schemas/UserResponseDto"
|
||||
@ -9311,10 +9307,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"enum": [
|
||||
"on_this_day"
|
||||
],
|
||||
"type": "string"
|
||||
"$ref": "#/components/schemas/MemoryType"
|
||||
},
|
||||
"updatedAt": {
|
||||
"format": "date-time",
|
||||
|
@ -26,7 +26,7 @@ export type ActivityResponseDto = {
|
||||
comment?: string | null;
|
||||
createdAt: string;
|
||||
id: string;
|
||||
"type": Type;
|
||||
"type": ReactionType;
|
||||
user: UserResponseDto;
|
||||
};
|
||||
export type ActivityCreateDto = {
|
||||
@ -572,7 +572,7 @@ export type MemoryResponseDto = {
|
||||
memoryAt: string;
|
||||
ownerId: string;
|
||||
seenAt?: string;
|
||||
"type": Type2;
|
||||
"type": MemoryType;
|
||||
updatedAt: string;
|
||||
};
|
||||
export type MemoryCreateDto = {
|
||||
@ -3065,10 +3065,6 @@ export enum ReactionType {
|
||||
Comment = "comment",
|
||||
Like = "like"
|
||||
}
|
||||
export enum Type {
|
||||
Comment = "comment",
|
||||
Like = "like"
|
||||
}
|
||||
export enum UserAvatarColor {
|
||||
Primary = "primary",
|
||||
Pink = "pink",
|
||||
@ -3164,9 +3160,6 @@ export enum MapTheme {
|
||||
Light = "light",
|
||||
Dark = "dark"
|
||||
}
|
||||
export enum Type2 {
|
||||
OnThisDay = "on_this_day"
|
||||
}
|
||||
export enum MemoryType {
|
||||
OnThisDay = "on_this_day"
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ export type MaybeDuplicate<T> = { duplicate: boolean; value: T };
|
||||
export class ActivityResponseDto {
|
||||
id!: string;
|
||||
createdAt!: Date;
|
||||
@ApiProperty({ enumName: 'ReactionType', enum: ReactionType })
|
||||
type!: ReactionType;
|
||||
user!: UserResponseDto;
|
||||
assetId!: string | null;
|
||||
@ -53,7 +54,7 @@ export class ActivitySearchDto extends ActivityDto {
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
const isComment = (dto: ActivityCreateDto) => dto.type === 'comment';
|
||||
const isComment = (dto: ActivityCreateDto) => dto.type === ReactionType.COMMENT;
|
||||
|
||||
export class ActivityCreateDto extends ActivityDto {
|
||||
@IsEnum(ReactionType)
|
||||
|
@ -61,6 +61,7 @@ export class MemoryResponseDto {
|
||||
memoryAt!: Date;
|
||||
seenAt?: Date;
|
||||
ownerId!: string;
|
||||
@ApiProperty({ enumName: 'MemoryType', enum: MemoryType })
|
||||
type!: MemoryType;
|
||||
data!: MemoryData;
|
||||
isSaved!: boolean;
|
||||
|
@ -8,7 +8,6 @@
|
||||
import { isTenMinutesApart } from '$lib/utils/timesince';
|
||||
import {
|
||||
ReactionType,
|
||||
Type,
|
||||
createActivity,
|
||||
deleteActivity,
|
||||
getActivities,
|
||||
@ -111,15 +110,15 @@
|
||||
await deleteActivity({ id: reaction.id });
|
||||
reactions.splice(index, 1);
|
||||
reactions = reactions;
|
||||
if (isLiked && reaction.type === 'like' && reaction.id == isLiked.id) {
|
||||
if (isLiked && reaction.type === ReactionType.Like && reaction.id == isLiked.id) {
|
||||
dispatch('deleteLike');
|
||||
} else {
|
||||
dispatch('deleteComment');
|
||||
}
|
||||
|
||||
const deleteMessages: Record<Type, string> = {
|
||||
[Type.Comment]: $t('comment_deleted'),
|
||||
[Type.Like]: $t('like_deleted'),
|
||||
const deleteMessages: Record<ReactionType, string> = {
|
||||
[ReactionType.Comment]: $t('comment_deleted'),
|
||||
[ReactionType.Like]: $t('like_deleted'),
|
||||
};
|
||||
notificationController.show({
|
||||
message: deleteMessages[reaction.type],
|
||||
@ -172,7 +171,7 @@
|
||||
style="height: {divHeight}px;padding-bottom: {chatHeight}px"
|
||||
>
|
||||
{#each reactions as reaction, index (reaction.id)}
|
||||
{#if reaction.type === 'comment'}
|
||||
{#if reaction.type === ReactionType.Comment}
|
||||
<div class="flex dark:bg-gray-800 bg-gray-200 py-3 pl-3 mt-3 rounded-lg gap-4 justify-start">
|
||||
<div class="flex items-center">
|
||||
<UserAvatar user={reaction.user} size="sm" />
|
||||
@ -216,7 +215,7 @@
|
||||
{timeSince(luxon.DateTime.fromISO(reaction.createdAt, { locale: $locale }))}
|
||||
</div>
|
||||
{/if}
|
||||
{:else if reaction.type === 'like'}
|
||||
{:else if reaction.type === ReactionType.Like}
|
||||
<div class="relative">
|
||||
<div class="flex py-3 pl-3 mt-3 gap-4 items-center text-sm">
|
||||
<div class="text-red-600"><Icon path={mdiHeart} size={20} /></div>
|
||||
|
Loading…
Reference in New Issue
Block a user