Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): move enum out of .svelte file #14144

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading