From 9e17769e7526d382608d68afab72fbeb2f9c8f04 Mon Sep 17 00:00:00 2001 From: Mikhail Netsvet Date: Sat, 11 May 2024 23:09:16 +0300 Subject: [PATCH 1/3] add preference to set high resolution in multi column mode --- .../fullscreen-post/FullscreenImage.svelte | 2 +- .../kurosearch/media-image/Image.svelte | 4 ++-- .../kurosearch/post/MosaicPost.svelte | 7 ++++++- ....ts => high-resolution-multi-col-enabled.ts} | 6 +++--- .../store/high-resolution-single-col-enabled.ts | 15 +++++++++++++++ src/lib/store/store-keys.ts | 3 ++- src/routes/preferences/+page.svelte | 17 ++++++++++++----- 7 files changed, 41 insertions(+), 13 deletions(-) rename src/lib/store/{high-resolution-enabled.ts => high-resolution-multi-col-enabled.ts} (65%) create mode 100644 src/lib/store/high-resolution-single-col-enabled.ts diff --git a/src/lib/components/kurosearch/fullscreen-post/FullscreenImage.svelte b/src/lib/components/kurosearch/fullscreen-post/FullscreenImage.svelte index d1f77f64..328a61a5 100644 --- a/src/lib/components/kurosearch/fullscreen-post/FullscreenImage.svelte +++ b/src/lib/components/kurosearch/fullscreen-post/FullscreenImage.svelte @@ -4,7 +4,7 @@ import LoadingAnimation from '$lib/components/pure/loading-animation/LoadingAnimation.svelte'; import { getGifSources } from '$lib/logic/media-utils'; import autoplayFullscreenEnabled from '$lib/store/autoplay-fullscreen-enabled-store'; - import highResolutionEnabled from '$lib/store/high-resolution-enabled'; + import highResolutionEnabled from '$lib/store/high-resolution-single-col-enabled'; import { createEventDispatcher, onDestroy, onMount } from 'svelte'; import { browser } from '$app/environment'; diff --git a/src/lib/components/kurosearch/media-image/Image.svelte b/src/lib/components/kurosearch/media-image/Image.svelte index 1f54070a..82eb493e 100644 --- a/src/lib/components/kurosearch/media-image/Image.svelte +++ b/src/lib/components/kurosearch/media-image/Image.svelte @@ -2,7 +2,7 @@ import { base } from '$app/paths'; import { clickOnEnter } from '$lib/logic/keyboard-utils'; import { postobserve } from '$lib/logic/use/postobserve'; - import highResolutionEnabled from '$lib/store/high-resolution-enabled'; + import highResolutionSingleColEnabled from '$lib/store/high-resolution-single-col-enabled'; import { calculateAspectRatio, calculateAspectRatioCss } from '../post/ratio'; export let post: kurosearch.Post; @@ -12,7 +12,7 @@ let open: boolean; - $: src = highResolutionEnabled ? post.file_url : post.sample_url; + $: src = highResolutionSingleColEnabled ? post.file_url : post.sample_url; diff --git a/src/lib/components/kurosearch/post/MosaicPost.svelte b/src/lib/components/kurosearch/post/MosaicPost.svelte index d3cdafee..36a25aed 100644 --- a/src/lib/components/kurosearch/post/MosaicPost.svelte +++ b/src/lib/components/kurosearch/post/MosaicPost.svelte @@ -3,6 +3,7 @@ import { getPostId } from '$lib/logic/id-utils'; import { isEnter } from '$lib/logic/keyboard-utils'; import { calculateAspectRatio } from './ratio'; + import highResolutionMultiColEnabled from "$lib/store/high-resolution-multi-col-enabled.js" export let post: kurosearch.Post; @@ -14,7 +15,11 @@ const isImage = (src: string) => src.endsWith('.jpg') || src.endsWith('.jpeg') || src.endsWith('.png') || src.endsWith('.webp'); - $: previewSrc = isImage(post.sample_url) ? post.sample_url : post.preview_url; + $: previewSrc = highResolutionMultiColEnabled + ? post.file_url + : isImage(post.sample_url) + ? post.sample_url + : post.preview_url; diff --git a/src/lib/store/high-resolution-enabled.ts b/src/lib/store/high-resolution-multi-col-enabled.ts similarity index 65% rename from src/lib/store/high-resolution-enabled.ts rename to src/lib/store/high-resolution-multi-col-enabled.ts index 783a8b90..49d3cd76 100644 --- a/src/lib/store/high-resolution-enabled.ts +++ b/src/lib/store/high-resolution-multi-col-enabled.ts @@ -1,10 +1,10 @@ import { boolParser, boolSerializer, persistentWritable } from './persistent-store'; import { StoreKey } from './store-keys'; -const createHighResolutionEnabledStore = () => { +const createHighResolutionMultiColEnabledStore = () => { const initial = false; const { subscribe, set } = persistentWritable( - StoreKey.HighResolutionEnabled, + StoreKey.HighResolutionMultiColEnabled, initial, boolSerializer, boolParser @@ -12,4 +12,4 @@ const createHighResolutionEnabledStore = () => { return { subscribe, set, reset: () => set(initial) }; }; -export default createHighResolutionEnabledStore(); +export default createHighResolutionMultiColEnabledStore(); diff --git a/src/lib/store/high-resolution-single-col-enabled.ts b/src/lib/store/high-resolution-single-col-enabled.ts new file mode 100644 index 00000000..f4eb03f7 --- /dev/null +++ b/src/lib/store/high-resolution-single-col-enabled.ts @@ -0,0 +1,15 @@ +import { boolParser, boolSerializer, persistentWritable } from './persistent-store'; +import { StoreKey } from './store-keys'; + +const createHighResolutionSingleColEnabledStore = () => { + const initial = false; + const { subscribe, set } = persistentWritable( + StoreKey.HighResolutionSingleColEnabled, + initial, + boolSerializer, + boolParser + ); + return { subscribe, set, reset: () => set(initial) }; +}; + +export default createHighResolutionSingleColEnabledStore(); diff --git a/src/lib/store/store-keys.ts b/src/lib/store/store-keys.ts index 0058984d..1137e206 100644 --- a/src/lib/store/store-keys.ts +++ b/src/lib/store/store-keys.ts @@ -11,7 +11,8 @@ export enum StoreKey { Theme = 'kurosearch:theme', AlwaysLoop = 'kurosearch:always-loop', CookiesAccepted = 'kurosearch:cookies-accepted', - HighResolutionEnabled = 'kurosearch:high-resolution-enabled', + HighResolutionSingleColEnabled = 'kurosearch:high-resolution-single-col-enabled', + HighResolutionMultiColEnabled = 'kurosearch:high-resolution-multi-col-enabled', WideLayoutEnabled = 'kurosearch:wide-layout-enabled', FullscreenHintDone = 'kurosearch:fullscreen-hint-done', AutoplayFullscreenEnabled = 'kurosearch:autoplay-fullscreen-enabled-done', diff --git a/src/routes/preferences/+page.svelte b/src/routes/preferences/+page.svelte index 833fea32..76c85941 100644 --- a/src/routes/preferences/+page.svelte +++ b/src/routes/preferences/+page.svelte @@ -28,7 +28,7 @@ import resultColumns from '$lib/store/result-columns-store'; import ConfirmDialog from '$lib/components/kurosearch/dialog-confirm/ConfirmDialog.svelte'; import cookiesAccepted from '$lib/store/cookies-accepted-store'; - import highResolutionEnabled from '$lib/store/high-resolution-enabled'; + import highResolutionSingleColEnabled from '$lib/store/high-resolution-single-col-enabled'; import resultsStore from '$lib/store/results-store'; import activeTagsStore from '$lib/store/active-tags-store'; import autoplayFullscreenEnabled from '$lib/store/autoplay-fullscreen-enabled-store'; @@ -38,6 +38,7 @@ import { addHistory } from '$lib/logic/use/onpopstate'; import NumberInput from '$lib/components/kurosearch/dialog-sort-filter/NumberInput.svelte'; import openTagsOnPostClick from '$lib/store/tags-shortcut-store'; + import highResolutionMultiColEnabled from "$lib/store/high-resolution-multi-col-enabled" let resetDialog: HTMLDialogElement; @@ -48,7 +49,7 @@ alwaysLoop.reset(); resultColumns.reset(); cookiesAccepted.reset(); - highResolutionEnabled.reset(); + highResolutionSingleColEnabled.reset(); wideLayoutEnabled.reset(); }; @@ -122,7 +123,7 @@ - +