Skip to content

Commit

Permalink
chore(web): move enum out of .svelte file (immich-app#14144)
Browse files Browse the repository at this point in the history
* chore(web): clean up todo task

* chore(web): move enums out of .svelte file
  • Loading branch information
alextran1502 authored and yosit committed Nov 21, 2024
1 parent 484ef45 commit 8c65452
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 31 deletions.
3 changes: 2 additions & 1 deletion web/src/lib/components/asset-viewer/slideshow-bar.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script lang="ts">
import { shortcuts } from '$lib/actions/shortcut';
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
import ProgressBar, { ProgressBarStatus } from '$lib/components/shared-components/progress-bar/progress-bar.svelte';
import ProgressBar from '$lib/components/shared-components/progress-bar/progress-bar.svelte';
import SlideshowSettings from '$lib/components/slideshow-settings.svelte';
import { ProgressBarStatus } from '$lib/constants';
import { SlideshowNavigation, slideshowStore } from '$lib/stores/slideshow.store';
import { mdiChevronLeft, mdiChevronRight, mdiClose, mdiCog, mdiFullscreen, mdiPause, mdiPlay } from '@mdi/js';
import { onDestroy, onMount } from 'svelte';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<script lang="ts" module>
const enum ToggleVisibility {
HIDE_ALL = 'hide-all',
HIDE_UNNANEMD = 'hide-unnamed',
SHOW_ALL = 'show-all',
}
</script>

<script lang="ts">
import { shortcut } from '$lib/actions/shortcut';
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
Expand All @@ -23,6 +15,7 @@
import { mdiClose, mdiEye, mdiEyeOff, mdiEyeSettings, mdiRestart } from '@mdi/js';
import { t } from 'svelte-i18n';
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
import { ToggleVisibility } from '$lib/constants';
interface Props {
people: PersonResponseDto[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<script module lang="ts">
export enum ProgressBarStatus {
Playing = 'playing',
Paused = 'paused',
}
</script>

<script lang="ts">
import { ProgressBarStatus } from '$lib/constants';
import { handlePromiseError } from '$lib/utils';
import { onMount } from 'svelte';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
import type { SearchLocationFilter } from './search-location-section.svelte';
import type { SearchDisplayFilters } from './search-display-section.svelte';
import type { SearchDateFilter } from './search-date-section.svelte';
export enum MediaType {
All = 'all',
Image = 'image',
Video = 'video',
}
import { MediaType } from '$lib/constants';
export type SearchFilter = {
query: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import RadioButton from '$lib/components/elements/radio-button.svelte';
import { MediaType } from './search-filter-modal.svelte';
import { MediaType } from '$lib/constants';
import { t } from 'svelte-i18n';
interface Props {
Expand Down
17 changes: 17 additions & 0 deletions web/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,20 @@ export enum PersonPageViewMode {
BIRTH_DATE = 'birth-date',
UNASSIGN_ASSETS = 'unassign-faces',
}

export enum MediaType {
All = 'all',
Image = 'image',
Video = 'video',
}

export enum ProgressBarStatus {
Playing = 'playing',
Paused = 'paused',
}

export enum ToggleVisibility {
HIDE_ALL = 'hide-all',
HIDE_UNNANEMD = 'hide-unnamed',
SHOW_ALL = 'show-all',
}
8 changes: 2 additions & 6 deletions web/src/routes/(user)/explore/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@
let { data }: Props = $props();
enum Field {
CITY = 'exifInfo.city',
}
const getFieldItems = (items: SearchExploreResponseDto[], field: Field) => {
const getFieldItems = (items: SearchExploreResponseDto[], field: string) => {
const targetField = items.find((item) => item.fieldName === field);
return targetField?.items || [];
};
let places = $derived(getFieldItems(data.items, Field.CITY));
let places = $derived(getFieldItems(data.items, 'exifInfo.city'));
let people = $state(data.response.people);
let hasPeople = $derived(data.response.total > 0);
Expand Down
3 changes: 1 addition & 2 deletions web/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ process.env.PUBLIC_IMMICH_PAY_HOST = process.env.PUBLIC_IMMICH_PAY_HOST || 'http

/** @type {import('@sveltejs/kit').Config} */
const config = {
// TODO: migrate all enums to .ts files and remove `{script: true}` once
preprocess: vitePreprocess({ script: true }),
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
fallback: 'index.html',
Expand Down

0 comments on commit 8c65452

Please sign in to comment.