migrate: change settings from a store to a state

This commit is contained in:
Xylight committed 2024-10-25 21:09:32 -07:00
1 parent ffcd9faa96
commit d597349887
128 files changed
+1010 -1144

No files matched your search

@@ -5,10 +5,10 @@
return 'www.youtube-nocookie.com'
}
case 'invidious': {
return get(userSettings).embeds.invidious || 'yewtu.be'
return settings.embeds.invidious || 'yewtu.be'
}
case 'piped': {
return get(userSettings).embeds.piped || 'piped.video'
return settings.embeds.piped || 'piped.video'
}
}
}
@@ -34,7 +34,7 @@
type IconSource,
} from 'svelte-hero-icons'
import { optimizeImageURL, type IframeType, type MediaType } from '../helpers'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
import { get } from 'svelte/store'
const urlToEmbed = (inputUrl: string) => {
@@ -50,7 +50,7 @@
if (autoplay) url.searchParams.set('autoplay', '1')
return `https://${youtubeDomain(
$userSettings.embeds.youtube,
settings.embeds.youtube,
)}/embed/${videoID}?${url.searchParams.toString()}`
}
@@ -98,8 +98,8 @@
type = 'none',
thumbnail = undefined,
url,
opened = $bindable(!$userSettings.embeds.clickToView),
autoplay = $userSettings.embeds.clickToView,
opened = $bindable(!settings.embeds.clickToView),
autoplay = settings.embeds.clickToView,
class: clazz = '',
}: Props = $props()
@@ -1,7 +1,7 @@
<script lang="ts">
import { stopPropagation } from 'svelte/legacy'
import { userSettings, type View } from '$lib/settings'
import { settings, type View } from '$lib/settings.svelte'
import type { Post } from 'lemmy-js-client'
import { bestImageURL, postLink } from '../helpers'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
@@ -24,7 +24,7 @@
<!--disabled preloads here since most people will hover over every image while scrolling-->
<svelte:element
this={$userSettings.expandImages ? 'button' : 'a'}
this={settings.expandImages ? 'button' : 'a'}
href={postLink(post)}
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
data-sveltekit-preload-data="off"
@@ -10,7 +10,7 @@
import ExpandableImage, {
showImage,
} from '$lib/components/ui/ExpandableImage.svelte'
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
import type { Post } from 'lemmy-js-client'
import PostIframe from './PostIframe.svelte'
import { Button, Material, modal } from 'mono-svelte'
@@ -31,7 +31,7 @@
post,
type = 'none',
opened = undefined,
blur = post.nsfw && $userSettings.nsfwBlur,
blur = post.nsfw && settings.nsfwBlur,
}: Props = $props()
</script>
@@ -6,7 +6,7 @@
type MediaType,
} from '$lib/components/lemmy/post/helpers.js'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
import { userSettings, type View } from '$lib/settings.js'
import { settings, type View } from '$lib/settings.svelte.js'
import { isImage } from '$lib/ui/image'
import type { Post } from 'lemmy-js-client'
import { Material, Popover } from 'mono-svelte'
@@ -34,7 +34,7 @@
post,
type = 'none',
view = 'cozy',
blur = post.nsfw && $userSettings.nsfwBlur,
blur = post.nsfw && settings.nsfwBlur,
style = '',
class: clazz = '',
}: Props = $props()
@@ -50,7 +50,7 @@
{#if post.alt_text}
<Popover
openOnHover
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
placement={settings.leftAlign ? 'bottom-start' : 'bottom-end'}
>
{#snippet target()}
<Material
@@ -68,7 +68,7 @@
</Popover>
{/if}
<svelte:element
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
this={!settings.expandImages || type != 'image' ? 'a' : 'button'}
href={postLink(post)}
onclick={() => {
if (type == 'image') {