Skip to content

Commit

Permalink
Adds setting to disable sorting of face in merge screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasdotcom committed Dec 20, 2024
1 parent 79a780e commit 3824f10
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 11 deletions.
2 changes: 2 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@
"people_edits_count": "Edited {count, plural, one {# person} other {# people}}",
"people_feature_description": "Browsing photos and videos grouped by people",
"people_sidebar_description": "Display a link to People in the sidebar",
"people_sort_merge_faces": "Sort Merge Faces",
"people_sort_merge_faces_description": "Sorts faces by similarity in people merge screens",
"permanent_deletion_warning": "Permanent deletion warning",
"permanent_deletion_warning_setting_description": "Show a warning when permanently deleting assets",
"permanently_delete": "Permanently delete",
Expand Down
14 changes: 11 additions & 3 deletions mobile/openapi/lib/model/people_response.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions mobile/openapi/lib/model/people_update.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion open-api/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10107,11 +10107,16 @@
"sidebarWeb": {
"default": false,
"type": "boolean"
},
"sortMergeFaces": {
"default": true,
"type": "boolean"
}
},
"required": [
"enabled",
"sidebarWeb"
"sidebarWeb",
"sortMergeFaces"
],
"type": "object"
},
Expand Down Expand Up @@ -10148,6 +10153,9 @@
},
"sidebarWeb": {
"type": "boolean"
},
"sortMergeFaces": {
"type": "boolean"
}
},
"type": "object"
Expand Down
2 changes: 2 additions & 0 deletions open-api/typescript-sdk/src/fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export type MemoriesResponse = {
export type PeopleResponse = {
enabled: boolean;
sidebarWeb: boolean;
sortMergeFaces: boolean;
};
export type PurchaseResponse = {
hideBuyButtonUntil: string;
Expand Down Expand Up @@ -150,6 +151,7 @@ export type MemoriesUpdate = {
export type PeopleUpdate = {
enabled?: boolean;
sidebarWeb?: boolean;
sortMergeFaces?: boolean;
};
export type PurchaseUpdate = {
hideBuyButtonUntil?: string;
Expand Down
4 changes: 4 additions & 0 deletions server/src/dtos/user-preferences.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class PeopleUpdate {

@ValidateBoolean({ optional: true })
sidebarWeb?: boolean;

@ValidateBoolean({ optional: true })
sortMergeFaces?: boolean;
}

class TagsUpdate {
Expand Down Expand Up @@ -145,6 +148,7 @@ class FoldersResponse {
class PeopleResponse {
enabled: boolean = true;
sidebarWeb: boolean = false;
sortMergeFaces: boolean = true;
}

class TagsResponse {
Expand Down
2 changes: 2 additions & 0 deletions server/src/entities/user-metadata.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface UserPreferences {
people: {
enabled: boolean;
sidebarWeb: boolean;
sortMergeFaces: boolean;
};
ratings: {
enabled: boolean;
Expand Down Expand Up @@ -72,6 +73,7 @@ export const getDefaultPreferences = (user: { email: string }): UserPreferences
people: {
enabled: true,
sidebarWeb: false,
sortMergeFaces: true,
},
ratings: {
enabled: false,
Expand Down
1 change: 0 additions & 1 deletion server/src/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class UserService extends BaseService {

async updateMyPreferences({ user }: AuthDto, dto: UserPreferencesUpdateDto) {
const preferences = mergePreferences(user, dto);

await this.userRepository.upsertMetadata(user.id, {
key: UserMetadataKey.PREFERENCES,
value: getPreferencesPartial(user, preferences),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { t } from 'svelte-i18n';
import { handleError } from '$lib/utils/handle-error';
import { onMount } from 'svelte';
import { preferences } from '$lib/stores/user.store';
interface Props {
editedFace: AssetFaceResponseDto;
Expand All @@ -34,7 +35,10 @@
async function loadPeople() {
const timeout = setTimeout(() => (isShowLoadingPeople = true), timeBeforeShowLoadingSpinner);
try {
const { people } = await getAllPeople({ withHidden: true, closestAssetId: editedFace.id });
const { people } = await getAllPeople({
withHidden: true,
closestAssetId: $preferences.people.sortMergeFaces ? editedFace.id : undefined,
});
allPeople = people;
} catch (error) {
handleError(error, $t('errors.cant_get_faces'));
Expand Down
6 changes: 5 additions & 1 deletion web/src/lib/components/faces-page/merge-face-selector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import PeopleList from './people-list.svelte';
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
import { t } from 'svelte-i18n';
import { preferences } from '$lib/stores/user.store';
interface Props {
person: PersonResponseDto;
Expand All @@ -35,7 +36,10 @@
let peopleToNotShow = $derived([...selectedPeople, person]);
onMount(async () => {
const data = await getAllPeople({ withHidden: false, closestPersonId: person.id });
const data = await getAllPeople({
withHidden: false,
closestPersonId: $preferences.people.sortMergeFaces ? person.id : undefined,
});
people = data.people;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// People
let peopleEnabled = $state($preferences?.people?.enabled ?? false);
let peopleSidebar = $state($preferences?.people?.sidebarWeb ?? false);
let peopleSortMergeFaces = $state($preferences?.people?.sortMergeFaces ?? false);
// Ratings
let ratingsEnabled = $state($preferences?.ratings?.enabled ?? false);
Expand All @@ -37,7 +38,7 @@
userPreferencesUpdateDto: {
folders: { enabled: foldersEnabled, sidebarWeb: foldersSidebar },
memories: { enabled: memoriesEnabled },
people: { enabled: peopleEnabled, sidebarWeb: peopleSidebar },
people: { enabled: peopleEnabled, sidebarWeb: peopleSidebar, sortMergeFaces: peopleSortMergeFaces },
ratings: { enabled: ratingsEnabled },
tags: { enabled: tagsEnabled, sidebarWeb: tagsSidebar },
},
Expand Down Expand Up @@ -95,6 +96,13 @@
bind:checked={peopleSidebar}
/>
</div>
<div class="ml-4 mt-6">
<SettingSwitch
title={$t('people_sort_merge_faces')}
subtitle={$t('people_sort_merge_faces_description')}
bind:checked={peopleSortMergeFaces}
/>
</div>
{/if}
</SettingAccordion>

Expand Down

0 comments on commit 3824f10

Please sign in to comment.