Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
martabal committed May 11, 2024
1 parent b1a867d commit 723c71b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
34 changes: 19 additions & 15 deletions web/src/lib/components/faces-page/show-hide.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
HIDE_UNNANEMD = 'hide-unnamed',
VIEW_ALL = 'view-all',
}
export const changeVisibility = (toggleVisibility: ToggleVisibilty) => {
if (toggleVisibility === ToggleVisibilty.VIEW_ALL) {
return ToggleVisibilty.HIDE_UNNANEMD;
} else if (toggleVisibility === ToggleVisibilty.HIDE_UNNANEMD) {
return ToggleVisibilty.HIDE_ALL;
} else {
return ToggleVisibilty.VIEW_ALL;
}
};
</script>

<script lang="ts">
Expand All @@ -29,10 +19,20 @@
export let toggleVisibility: ToggleVisibilty = ToggleVisibilty.VIEW_ALL;
export let screenHeight: number;
export let countTotalPeople: number;
export let onClose = () => {};
export let onReset = () => {};
export let onChange = () => {};
export let onDone = () => {};
export let onClose: () => void;
export let onReset: () => void;
export let onChange: (toggleVisibility: ToggleVisibilty) => void;
export let onDone: () => void;
const changeVisibility = (toggleVisibility: ToggleVisibilty) => {
if (toggleVisibility === ToggleVisibilty.VIEW_ALL) {
return ToggleVisibilty.HIDE_UNNANEMD;
} else if (toggleVisibility === ToggleVisibilty.HIDE_UNNANEMD) {
return ToggleVisibilty.HIDE_ALL;
} else {
return ToggleVisibilty.VIEW_ALL;
}
};
const toggleIconOptions: Record<ToggleVisibilty, string> = {
[ToggleVisibilty.HIDE_ALL]: mdiEyeOff,
Expand Down Expand Up @@ -60,7 +60,11 @@
<div class="flex items-center justify-end">
<div class="flex items-center md:mr-8">
<CircleIconButton title="Reset people visibility" icon={mdiRestart} on:click={onReset} />
<CircleIconButton title="Toggle visibility" icon={toggleIcon} on:click={onChange} />
<CircleIconButton
title="Toggle visibility"
icon={toggleIcon}
on:click={() => onChange(changeVisibility(toggleVisibility))}
/>
</div>
{#if !showLoadingSpinner}
<Button on:click={onDone} size="sm" rounded="lg">Done</Button>
Expand Down
5 changes: 2 additions & 3 deletions web/src/routes/(user)/people/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import MergeSuggestionModal from '$lib/components/faces-page/merge-suggestion-modal.svelte';
import PeopleCard from '$lib/components/faces-page/people-card.svelte';
import SetBirthDateModal from '$lib/components/faces-page/set-birth-date-modal.svelte';
import ShowHide, { changeVisibility, ToggleVisibilty } from '$lib/components/faces-page/show-hide.svelte';
import ShowHide, { ToggleVisibilty } from '$lib/components/faces-page/show-hide.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
import {
Expand Down Expand Up @@ -116,8 +116,7 @@
people = people;
};
const handleToggleVisibility = () => {
toggleVisibility = changeVisibility(toggleVisibility);
const handleToggleVisibility = (toggleVisibility: ToggleVisibilty) => {
for (const person of people) {
if (toggleVisibility == ToggleVisibilty.HIDE_ALL) {
person.isHidden = true;
Expand Down

0 comments on commit 723c71b

Please sign in to comment.