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
+667 -801

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
// See https://kit.svelte.dev/docs/types#app // See https://kit.svelte.dev/docs/types#app
import type { Action } from '$lib/components/ui/navbar/commands/actions' import type { Action } from '$lib/components/ui/navbar/commands/actions.svelte'
import type { ComponentType, SvelteComponent } from 'svelte' import type { ComponentType, SvelteComponent } from 'svelte'
// for information about these interfaces // for information about these interfaces
+1 -1
View File
@@ -6,7 +6,7 @@ import { toast } from 'mono-svelte'
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.js' import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.js'
import { client, getClient } from '$lib/lemmy.js' import { client, getClient } from '$lib/lemmy.js'
import { site } from './lemmy' import { site } from './lemmy'
import { instanceToURL, moveItem } from '$lib/util.js' import { instanceToURL, moveItem } from '$lib/util.svelte'
import { import {
type GetSiteResponse, type GetSiteResponse,
type MyUserInfo, type MyUserInfo,
+4 -4
View File
@@ -19,7 +19,7 @@
import { userLink } from '$lib/lemmy/generic' import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import Entity from '../ui/Entity.svelte' import Entity from '../ui/Entity.svelte'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { optimizeImageURL } from './post/helpers' import { optimizeImageURL } from './post/helpers'
interface Props { interface Props {
@@ -100,7 +100,7 @@
{/if} {/if}
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={$userSettings.expand.about}> <Expandable bind:open={settings.expand.about}>
{#snippet title()} {#snippet title()}
<span class="flex items-center gap-1 py-1 px-2"> <span class="flex items-center gap-1 py-1 px-2">
<Icon src={InformationCircle} size="16" mini /> <Icon src={InformationCircle} size="16" mini />
@@ -113,7 +113,7 @@
</Expandable> </Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={$userSettings.expand.stats}> <Expandable bind:open={settings.expand.stats}>
{#snippet title()} {#snippet title()}
<span class="flex items-center gap-1 py-1 px-2"> <span class="flex items-center gap-1 py-1 px-2">
<Icon src={ChartBar} size="16" mini /> <Icon src={ChartBar} size="16" mini />
@@ -141,7 +141,7 @@
{#if admins} {#if admins}
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={$userSettings.expand.team}> <Expandable bind:open={settings.expand.team}>
{#snippet title()} {#snippet title()}
<span class="flex items-center gap-1 py-1 px-2"> <span class="flex items-center gap-1 py-1 px-2">
<Icon src={UserGroup} size="16" mini /> <Icon src={UserGroup} size="16" mini />
@@ -13,7 +13,7 @@
PlusCircle, PlusCircle,
MinusCircle, MinusCircle,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import type { CommentNodeI } from './comments' import type { CommentNodeI } from './comments.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte' import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import CommentForm from './CommentForm.svelte' import CommentForm from './CommentForm.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
@@ -21,7 +21,7 @@
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte' import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { Disclosure, toast } from 'mono-svelte' import { Disclosure, toast } from 'mono-svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { Button, Modal } from 'mono-svelte' import { Button, Modal } from 'mono-svelte'
import { publishedToDate } from '$lib/components/util/date.js' import { publishedToDate } from '$lib/components/util/date.js'
import ShieldIcon from '../moderation/ShieldIcon.svelte' import ShieldIcon from '../moderation/ShieldIcon.svelte'
@@ -110,7 +110,7 @@
<form onsubmit={preventDefault(save)} class="contents"> <form onsubmit={preventDefault(save)} class="contents">
<CommentForm <CommentForm
postId={node.comment_view.comment.id} postId={node.comment_view.comment.id}
bind:value={newComment} value={newComment}
actions={false} actions={false}
preview={true} preview={true}
on:confirm={save} on:confirm={save}
@@ -235,7 +235,7 @@
</div> </div>
{#if actions} {#if actions}
<CommentActions <CommentActions
bind:comment={node.comment_view} comment={node.comment_view}
bind:replying bind:replying
on:edit={() => (editing = true)} on:edit={() => (editing = true)}
disabled={node.comment_view.banned_from_community || disabled={node.comment_view.banned_from_community ||
@@ -259,7 +259,6 @@
children: [], children: [],
comment_view: e.detail.comment_view, comment_view: e.detail.comment_view,
depth: node.depth + 1, depth: node.depth + 1,
ui: {},
}, },
...node.children, ...node.children,
] ]
@@ -22,13 +22,13 @@
report, report,
} from '$lib/components/lemmy/moderation/moderation.js' } from '$lib/components/lemmy/moderation/moderation.js'
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte' import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { deleteItem, save } from '$lib/lemmy/contentview.js' import { deleteItem, save } from '$lib/lemmy/contentview.js'
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte' import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import Translation from '$lib/components/translate/Translation.svelte' import Translation from '$lib/components/translate/Translation.svelte'
import { text } from '$lib/components/translate/translation' import { text } from '$lib/components/translate/translation'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
interface Props { interface Props {
comment: CommentView comment: CommentView
@@ -54,12 +54,12 @@
<div <div
class="flex flex-row items-center gap-0.5 h-7 w-full" class="flex flex-row items-center gap-0.5 h-7 w-full"
class:flex-row-reverse={$userSettings.posts.reverseActions} class:flex-row-reverse={settings.posts.reverseActions}
> >
<CommentVote <CommentVote
bind:upvotes={comment.counts.upvotes} upvotes={comment.counts.upvotes}
bind:downvotes={comment.counts.downvotes} downvotes={comment.counts.downvotes}
bind:vote={comment.my_vote} vote={comment.my_vote}
commentId={comment.comment.id} commentId={comment.comment.id}
/> />
<Button <Button
@@ -101,7 +101,7 @@
<Icon src={Square2Stack} mini size="16" /> <Icon src={Square2Stack} mini size="16" />
<div>{$t('comment.actions.link')}</div> <div>{$t('comment.actions.link')}</div>
</MenuButton> </MenuButton>
{#if $userSettings.translator} {#if settings.translator}
<MenuButton <MenuButton
on:click={() => { on:click={() => {
// @ts-ignore // @ts-ignore
@@ -3,10 +3,10 @@
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { createEventDispatcher } from 'svelte' import { createEventDispatcher } from 'svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { placeholders } from '$lib/util.js' import { placeholders } from '$lib/util.svelte.js'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { errorMessage } from '$lib/lemmy/error' import { errorMessage } from '$lib/lemmy/error'
@@ -3,7 +3,7 @@
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte' import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { publishedToDate } from '$lib/components/util/date.js' import { publishedToDate } from '$lib/components/util/date.js'
import { getInstance } from '$lib/lemmy.js' import { getInstance } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import type { CommentView } from 'lemmy-js-client' import type { CommentView } from 'lemmy-js-client'
import { Button, Material } from 'mono-svelte' import { Button, Material } from 'mono-svelte'
@@ -20,7 +20,7 @@
let { let {
comment, comment,
view = $userSettings.view, view = settings.view,
community = false, community = false,
meta = true, meta = true,
class: clazz = '', class: clazz = '',
@@ -2,7 +2,7 @@
import { run } from 'svelte/legacy' import { run } from 'svelte/legacy'
import type { Post } from 'lemmy-js-client' import type { Post } from 'lemmy-js-client'
import type { CommentNodeI } from './comments' import type { CommentNodeI } from './comments.svelte'
import { createWindowVirtualizer } from '@tanstack/svelte-virtual' import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
import Comments from './Comments.svelte' import Comments from './Comments.svelte'
import { browser } from '$app/environment' import { browser } from '$app/environment'
@@ -24,7 +24,7 @@
estimateSize: () => 30, estimateSize: () => 30,
scrollMargin: virtualListEl?.offsetTop, scrollMargin: virtualListEl?.offsetTop,
initialRect: { initialRect: {
height: 1500, height: browser ? 1 : 1500,
width: 99999, width: 99999,
}, },
overscan: 5, overscan: 5,
@@ -35,9 +35,11 @@
let items = $derived($virtualizer.getVirtualItems()) let items = $derived($virtualizer.getVirtualItems())
run(() => { const updateItems = () =>
if (virtualItemEls.length)
virtualItemEls.forEach((el) => $virtualizer.measureElement(el)) virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
$effect(() => {
if (virtualItemEls) updateItems()
}) })
onMount(() => { onMount(() => {
@@ -8,8 +8,8 @@
Icon, Icon,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { getClient, site } from '$lib/lemmy' import { getClient, site } from '$lib/lemmy'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte' import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { Button, buttonColor, toast } from 'mono-svelte' import { Button, buttonColor, toast } from 'mono-svelte'
import { vote as voteItem } from '$lib/lemmy/contentview' import { vote as voteItem } from '$lib/lemmy/contentview'
@@ -1,22 +1,15 @@
<script lang="ts"> <script lang="ts">
import Comments from './Comments.svelte' import Comments from './Comments.svelte'
import Comment from './Comment.svelte' import Comment from './Comment.svelte'
import { buildCommentsTree, type CommentNodeI } from './comments' import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
import { page } from '$app/stores' import { page } from '$app/stores'
import { onMount, setContext } from 'svelte' import { onMount, setContext } from 'svelte'
import { import { Icon, ArrowDownCircle } from 'svelte-hero-icons'
ChevronDoubleDown,
ChevronDown,
Icon,
Plus,
PlusCircle,
ArrowDownCircle,
} from 'svelte-hero-icons'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import type { CommentView, Post } from 'lemmy-js-client' import type { CommentView, Post } from 'lemmy-js-client'
import { fly } from 'svelte/transition' import { fly } from 'svelte/transition'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { afterNavigate, goto } from '$app/navigation' import { afterNavigate, goto } from '$app/navigation'
import { backOut, expoOut } from 'svelte/easing' import { backOut, expoOut } from 'svelte/easing'
@@ -121,8 +114,7 @@
{#each nodes as node, index (node.comment_view.comment.id)} {#each nodes as node, index (node.comment_view.comment.id)}
<Comment <Comment
postId={post.id} postId={post.id}
bind:node={nodes[index]} node={nodes[index]}
bind:open={node.ui.open}
op={post.creator_id == node.comment_view.creator.id} op={post.creator_id == node.comment_view.creator.id}
contentClass="pl-3 {node.children.length > 0 || contentClass="pl-3 {node.children.length > 0 ||
node.comment_view.counts.child_count > 0 node.comment_view.counts.child_count > 0
@@ -130,7 +122,7 @@
: ''} ml-3 border-slate-200 dark:border-zinc-800" : ''} ml-3 border-slate-200 dark:border-zinc-800"
> >
{#if node.children?.length > 0} {#if node.children?.length > 0}
<Comments {post} bind:nodes={nodes[index].children} isParent={false} /> <Comments {post} nodes={nodes[index].children} isParent={false} />
{/if} {/if}
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0} {#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
<svelte:element <svelte:element
@@ -5,9 +5,6 @@ export interface CommentNodeI {
children: Array<CommentNodeI> children: Array<CommentNodeI>
depth: number depth: number
loading?: boolean loading?: boolean
ui: {
open?: boolean
}
} }
function getCommentParentId(comment?: Comment): number | undefined { function getCommentParentId(comment?: Comment): number | undefined {
@@ -40,10 +37,7 @@ export function buildCommentsTree(
const node: CommentNodeI = { const node: CommentNodeI = {
comment_view, comment_view,
children: [], children: [],
depth: depth, depth: depth
ui: {
open: true,
},
} }
min_depth = Math.min(min_depth, depth) min_depth = Math.min(min_depth, depth)
if (filter(comment_view)) { if (filter(comment_view)) {
@@ -109,7 +103,6 @@ export function insertCommentIntoTree(
comment_view: cv, comment_view: cv,
children: [], children: [],
depth: 0, depth: 0,
ui: {},
} }
const parentId = getCommentParentId(cv.comment) const parentId = getCommentParentId(cv.comment)
@@ -66,7 +66,7 @@
</script> </script>
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { import {
amMod, amMod,
isAdmin, isAdmin,
@@ -85,7 +85,7 @@
} from 'mono-svelte' } from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.js' import { client, getClient } from '$lib/lemmy.js'
import { addSubscription } from '$lib/lemmy/user.js' import { addSubscription } from '$lib/lemmy/user.js'
import { fullCommunityName } from '$lib/util.js' import { fullCommunityName } from '$lib/util.svelte.js'
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client' import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { import {
@@ -109,7 +109,7 @@
import { userLink } from '$lib/lemmy/generic' import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import Entity from '$lib/components/ui/Entity.svelte' import Entity from '$lib/components/ui/Entity.svelte'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
let loading = $state({ let loading = $state({
blocking: false, blocking: false,
@@ -170,7 +170,7 @@
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={$userSettings.expand.about} class="!pt-0"> <Expandable bind:open={settings.expand.about} class="!pt-0">
{#snippet title()} {#snippet title()}
<span class="py-1 px-1 flex gap-1 items-center"> <span class="py-1 px-1 flex gap-1 items-center">
<Icon src={InformationCircle} size="15" mini /> <Icon src={InformationCircle} size="15" mini />
@@ -181,7 +181,7 @@
</Expandable> </Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={$userSettings.expand.stats}> <Expandable bind:open={settings.expand.stats}>
{#snippet title()} {#snippet title()}
<span class="py-1 px-1 flex gap-1 items-center"> <span class="py-1 px-1 flex gap-1 items-center">
<Icon src={ChartBar} size="15" mini /> <Icon src={ChartBar} size="15" mini />
@@ -204,7 +204,7 @@
{#if moderators && moderators.length > 0} {#if moderators && moderators.length > 0}
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable bind:open={$userSettings.expand.team}> <Expandable bind:open={settings.expand.team}>
{#snippet title()} {#snippet title()}
<span class="py-1 px-1 flex gap-1 items-center"> <span class="py-1 px-1 flex gap-1 items-center">
<ShieldIcon width={15} filled /> <ShieldIcon width={15} filled />
@@ -2,13 +2,13 @@
import { preventDefault } from 'svelte/legacy' import { preventDefault } from 'svelte/legacy'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { ImageInput, Switch, toast } from 'mono-svelte' import { ImageInput, Switch, toast } from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.js' import { client, getClient } from '$lib/lemmy.js'
import { addSubscription } from '$lib/lemmy/user.js' import { addSubscription } from '$lib/lemmy/user.js'
import { Button, Checkbox, TextInput } from 'mono-svelte' import { Button, Checkbox, TextInput } from 'mono-svelte'
import { uploadImage } from '$lib/util.js' import { uploadImage } from '$lib/util.svelte.js'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import ImagePreviewInput from '$lib/components/input/ImagePreviewInput.svelte' import ImagePreviewInput from '$lib/components/input/ImagePreviewInput.svelte'
@@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/auth' import { profile } from '$lib/auth.svelte'
import EntityHeader from '$lib/components/ui/EntityHeader.svelte' import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { fullCommunityName } from '$lib/util' import { fullCommunityName } from '$lib/util.svelte'
import type { import type {
Community, Community,
CommunityAggregates, CommunityAggregates,
@@ -13,8 +13,8 @@
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte' import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { Button, Modal } from 'mono-svelte' import { Button, Modal } from 'mono-svelte'
import { fullCommunityName, isSubscribed } from '$lib/util.js' import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { addSubscription } from '$lib/lemmy/user.js' import { addSubscription } from '$lib/lemmy/user.js'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte' import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import type { Community } from 'lemmy-js-client' import type { Community } from 'lemmy-js-client'
import { ExclamationTriangle, Icon } from 'svelte-hero-icons' import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
@@ -23,7 +23,7 @@
avatar = false, avatar = false,
name = true, name = true,
avatarSize = 24, avatarSize = 24,
showInstance = $userSettings.showInstances.community, showInstance = settings.showInstances.community,
displayName = true, displayName = true,
badges = { badges = {
nsfw: false, nsfw: false,
@@ -1,10 +1,7 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'
import { page } from '$app/stores' import { page } from '$app/stores'
import { profile } from '$lib/auth' import { profile } from '$lib/auth.svelte'
import { userSettings } from '$lib/settings' import { searchParam } from '$lib/util.svelte'
import { searchParam } from '$lib/util'
import { Select } from 'mono-svelte' import { Select } from 'mono-svelte'
import { import {
GlobeAmericas, GlobeAmericas,
@@ -25,32 +22,19 @@
} }
let { let {
selected, selected = $bindable(),
navigate = true, navigate = true,
changeDefault = false, changeDefault = false,
showLabel = true, showLabel = true,
...rest ...rest
}: Props = $props() }: Props = $props()
let feed: string = $state(selected)
run(() => {
feed = selected
})
run(() => {
changeDefault
? ($userSettings.defaultSort.feed = selected as
| 'All'
| 'Subscribed'
| 'Local')
: undefined
})
</script> </script>
<Select <Select
{...rest} {...rest}
bind:value={feed} bind:value={selected}
on:change={() => { on:change={() => {
if (navigate) searchParam($page.url, 'type', feed, 'page', 'cursor') if (navigate) searchParam($page.url, 'type', selected, 'page', 'cursor')
}} }}
> >
{#snippet customLabel()} {#snippet customLabel()}
+4 -15
View File
@@ -2,9 +2,9 @@
import { run } from 'svelte/legacy' import { run } from 'svelte/legacy'
import { page } from '$app/stores' import { page } from '$app/stores'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.svelte.js'
import type { SortType } from 'lemmy-js-client' import type { SortType } from 'lemmy-js-client'
import { Select } from 'mono-svelte' import { Select } from 'mono-svelte'
import { import {
@@ -45,17 +45,6 @@
let sort: string = $state(selected?.startsWith('Top') ? 'TopAll' : selected) let sort: string = $state(selected?.startsWith('Top') ? 'TopAll' : selected)
const setSelected = () => (selected = sort) const setSelected = () => (selected = sort)
run(() => {
if (selected) {
sort = selected?.startsWith('Top') ? 'TopAll' : selected
}
})
run(() => {
changeDefault
? ($userSettings.defaultSort.sort = selected as SortType)
: undefined
})
</script> </script>
<div class="flex flex-row {clazz}"> <div class="flex flex-row {clazz}">
@@ -68,7 +57,7 @@
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor') if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
}} }}
> >
{#snippet label()} {#snippet customLabel()}
<span class="flex items-center gap-1"> <span class="flex items-center gap-1">
<Icon src={ChartBar} size="13" micro /> <Icon src={ChartBar} size="13" micro />
{$t('filter.sort.label')} {$t('filter.sort.label')}
@@ -167,7 +156,7 @@
searchParam($page.url, 'sort', selected, 'page', 'cursor') searchParam($page.url, 'sort', selected, 'page', 'cursor')
}} }}
> >
{#snippet label()} {#snippet customLabel()}
<span class="flex items-center gap-1"> <span class="flex items-center gap-1">
<Icon src={Clock} size="15" micro /> <Icon src={Clock} size="15" micro />
{$t('filter.sort.top.time.label')} {$t('filter.sort.top.time.label')}
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { Select } from 'mono-svelte' import { Select } from 'mono-svelte'
import { import {
@@ -21,7 +21,7 @@
let { showLabel = true, ...rest }: Props = $props() let { showLabel = true, ...rest }: Props = $props()
</script> </script>
<Select {...rest} bind:value={$userSettings.view}> <Select {...rest} bind:value={settings.view}>
{#snippet customLabel()} {#snippet customLabel()}
{#if showLabel} {#if showLabel}
<span class="flex items-center gap-1"> <span class="flex items-center gap-1">
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import type { PrivateMessageView } from 'lemmy-js-client' import type { PrivateMessageView } from 'lemmy-js-client'
@@ -1,11 +1,11 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy' import { preventDefault } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import ProgressBar from '$lib/components/ui/ProgressBar.svelte' import ProgressBar from '$lib/components/ui/ProgressBar.svelte'
import { errorMessage } from '$lib/lemmy/error' import { errorMessage } from '$lib/lemmy/error'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { uploadImage } from '$lib/util.js' import { uploadImage } from '$lib/util.svelte.js'
import { ImageInput, Spinner, toast } from 'mono-svelte' import { ImageInput, Spinner, toast } from 'mono-svelte'
import { Button, Modal } from 'mono-svelte' import { Button, Modal } from 'mono-svelte'
import { createEventDispatcher } from 'svelte' import { createEventDispatcher } from 'svelte'
@@ -73,7 +73,7 @@
</script> </script>
<Modal bind:open> <Modal bind:open>
{#snippet title()} {#snippet customTitle()}
<div class="flex items-center gap-2">Upload image</div> <div class="flex items-center gap-2">Upload image</div>
{/snippet} {/snippet}
{#if progress != 1} {#if progress != 1}
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy' import { preventDefault } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
@@ -5,7 +5,7 @@
import type { Community, Person, PersonView } from 'lemmy-js-client' import type { Community, Person, PersonView } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte' import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
@@ -9,7 +9,7 @@
Trash, Trash,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { isCommentView } from '$lib/lemmy/item.js' import { isCommentView } from '$lib/lemmy/item.js'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte' import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte' import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
@@ -13,7 +13,7 @@
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { isCommentView, isPostView } from '$lib/lemmy/item.js' import { isCommentView, isPostView } from '$lib/lemmy/item.js'
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte' import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import ShieldIcon from './ShieldIcon.svelte' import ShieldIcon from './ShieldIcon.svelte'
@@ -7,13 +7,13 @@
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { isCommentView, isPostView } from '$lib/lemmy/item.js' import { isCommentView, isPostView } from '$lib/lemmy/item.js'
import type { CommentView, PostView } from 'lemmy-js-client' import type { CommentView, PostView } from 'lemmy-js-client'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { Fire, Icon, Trash } from 'svelte-hero-icons' import { Fire, Icon, Trash } from 'svelte-hero-icons'
import MultiSelect from '$lib/components/input/Switch.svelte' import MultiSelect from '$lib/components/input/Switch.svelte'
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js' import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { fullCommunityName } from '$lib/util.js' import { fullCommunityName } from '$lib/util.svelte.js'
import { amMod, isAdmin } from './moderation' import { amMod, isAdmin } from './moderation'
import { Button, Checkbox, Modal } from 'mono-svelte' import { Button, Checkbox, Modal } from 'mono-svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
@@ -34,7 +34,7 @@
let commentReason: boolean = $state(false) let commentReason: boolean = $state(false)
let privateMessage: boolean = $state(false) let privateMessage: boolean = $state(false)
let loading = $state(false) let loading = $state(false)
let preset = $state($userSettings.moderation.presets[0]?.content ?? '') let preset = $state(settings.moderation.presets[0]?.content ?? '')
let removed = $derived( let removed = $derived(
item item
@@ -231,7 +231,7 @@
<div class="flex justify-between items-end mb-1"> <div class="flex justify-between items-end mb-1">
{$t('comment.reply')} {$t('comment.reply')}
<Select bind:value={preset} placeholder="No preset"> <Select bind:value={preset} placeholder="No preset">
{#each $userSettings.moderation.presets as preset} {#each settings.moderation.presets as preset}
<option value={preset.content}> <option value={preset.content}>
{preset.title} {preset.title}
</option> </option>
@@ -10,7 +10,7 @@
PostView, PostView,
PrivateMessageView, PrivateMessageView,
} from 'lemmy-js-client' } from 'lemmy-js-client'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { Button, Modal } from 'mono-svelte' import { Button, Modal } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { onMount } from 'svelte' import { onMount } from 'svelte'
+9 -10
View File
@@ -3,7 +3,7 @@
import { isImage, isVideo } from '$lib/ui/image.js' import { isImage, isVideo } from '$lib/ui/image.js'
import { getInstance } from '$lib/lemmy.js' import { getInstance } from '$lib/lemmy.js'
import PostActions from '$lib/components/lemmy/post/PostActions.svelte' import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte' import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
import PostMeta, { import PostMeta, {
parseTags, parseTags,
@@ -28,18 +28,17 @@
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte' import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte' import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
import PostBody from './PostBody.svelte' import PostBody from './PostBody.svelte'
import { profile } from '$lib/auth' import { profile } from '$lib/auth.svelte'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined { function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
const tagContent = tags.map((t) => t.content.toLowerCase()) const tagContent = tags.map((t) => t.content.toLowerCase())
let rule: 'blur' | 'hide' | undefined let rule: 'blur' | 'hide' | undefined
if ($userSettings.nsfwBlur && (post.post.nsfw || post.community.nsfw)) if (settings.nsfwBlur && (post.post.nsfw || post.community.nsfw))
rule = 'blur' rule = 'blur'
tagContent.forEach((tag) => { tagContent.forEach((tag) => {
if ($userSettings.tagRules?.[tag]) if (settings.tagRules?.[tag]) rule = settings.tagRules?.[tag] ?? rule
rule = $userSettings.tagRules?.[tag] ?? rule
if (rule == 'hide') return rule if (rule == 'hide') return rule
}) })
@@ -69,7 +68,7 @@
post, post,
actions = true, actions = true,
hideCommunity = false, hideCommunity = false,
view = $userSettings.view, view = settings.view,
style = '', style = '',
class: clazz = '', class: clazz = '',
badges, badges,
@@ -79,13 +78,13 @@
let type = $derived(mediaType(post.post.url, view)) let type = $derived(mediaType(post.post.url, view))
let rule = $derived(getTagRule(tags.tags)) let rule = $derived(getTagRule(tags.tags))
let hideTitle = $derived( let hideTitle = $derived(
$userSettings.posts.deduplicateEmbed && settings.posts.deduplicateEmbed &&
post.post.embed_title == post.post.name && post.post.embed_title == post.post.name &&
view != 'compact' && view != 'compact' &&
type != 'iframe', type != 'iframe',
) )
let hideBody = $derived( let hideBody = $derived(
$userSettings.posts.deduplicateEmbed && settings.posts.deduplicateEmbed &&
post.post.embed_description == post.post.body && post.post.embed_description == post.post.body &&
view != 'compact', view != 'compact',
) )
@@ -102,7 +101,7 @@
<div <div
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none
group group
{$userSettings.leftAlign ? 'left-align' : ''} {settings.leftAlign ? 'left-align' : ''}
{view == 'compact' ? 'py-3 list-type compact' : ''} {view == 'compact' ? 'py-3 list-type compact' : ''}
{view == 'list' ? 'py-5 list-type' : ''} {view == 'list' ? 'py-5 list-type' : ''}
{view == 'cozy' ? 'py-5 flex flex-col gap-2' : ''} {view == 'cozy' ? 'py-5 flex flex-col gap-2' : ''}
@@ -168,7 +167,7 @@
<PostMediaCompact <PostMediaCompact
post={post.post} post={post.post}
{type} {type}
class="{$userSettings.leftAlign class="{settings.leftAlign
? 'mr-3' ? 'mr-3'
: 'ml-3'} flex-shrink no-list-margin" : 'ml-3'} flex-shrink no-list-margin"
style="grid-area: media;" style="grid-area: media;"
@@ -39,11 +39,11 @@
report, report,
} from '$lib/components/lemmy/moderation/moderation.js' } from '$lib/components/lemmy/moderation/moderation.js'
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte' import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js' import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
import { setSessionStorage } from '$lib/session.js' import { setSessionStorage } from '$lib/session.js'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { userSettings, type View } from '$lib/settings.js' import { settings, type View } from '$lib/settings.svelte.js'
import { import {
Button, Button,
Menu, Menu,
@@ -59,7 +59,7 @@
import { hidePost, postLink } from './helpers' import { hidePost, postLink } from './helpers'
import { feature } from '$lib/version' import { feature } from '$lib/version'
import Switch from '$lib/components/input/Switch.svelte' import Switch from '$lib/components/input/Switch.svelte'
import { instanceId, instanceToURL } from '$lib/util' import { instanceId, instanceToURL } from '$lib/util.svelte'
import { publishedToDate } from '$lib/components/util/date' import { publishedToDate } from '$lib/components/util/date'
import TextProps from '$lib/components/ui/text/TextProps.svelte' import TextProps from '$lib/components/ui/text/TextProps.svelte'
import { communityLink, userLink } from '$lib/lemmy/generic' import { communityLink, userLink } from '$lib/lemmy/generic'
@@ -129,15 +129,15 @@
<footer <footer
class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}" class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}"
class:flex-row-reverse={$userSettings.posts.reverseActions} class:flex-row-reverse={settings.posts.reverseActions}
{style} {style}
> >
<PostVote <PostVote
post={post.post} post={post.post}
bind:vote={post.my_vote} vote={post.my_vote}
bind:score={post.counts.score} score={post.counts.score}
bind:upvotes={post.counts.upvotes} upvotes={post.counts.upvotes}
bind:downvotes={post.counts.downvotes} downvotes={post.counts.downvotes}
showCounts={$profile?.user?.local_user_view?.local_user?.show_scores ?? showCounts={$profile?.user?.local_user_view?.local_user?.show_scores ??
true} true}
/> />
@@ -148,7 +148,7 @@
class="!text-inherit h-full px-3 relative" class="!text-inherit h-full px-3 relative"
color="ghost" color="ghost"
rounding="pill" rounding="pill"
target={$userSettings.openLinksInNewTab ? '_blank' : ''} target={settings.openLinksInNewTab ? '_blank' : ''}
title={$t('post.actions.comments')} title={$t('post.actions.comments')}
animations={{ scale: true, large: false }} animations={{ scale: true, large: false }}
> >
@@ -163,7 +163,7 @@
</Button> </Button>
<div class="flex-1"></div> <div class="flex-1"></div>
{#if $userSettings.debugInfo} {#if settings.debugInfo}
{#if debug} {#if debug}
{#await import('$lib/components/util/debug/DebugObject.svelte') then { default: DebugObject }} {#await import('$lib/components/util/debug/DebugObject.svelte') then { default: DebugObject }}
<DebugObject object={post} bind:open={debug} /> <DebugObject object={post} bind:open={debug} />
@@ -378,7 +378,7 @@
</div> </div>
{/if} {/if}
</MenuButton> </MenuButton>
{#if post.post.body && $userSettings.translator} {#if post.post.body && settings.translator}
<MenuButton <MenuButton
on:click={() => { on:click={() => {
// @ts-ignore // @ts-ignore
@@ -397,7 +397,7 @@
on:click={() => { on:click={() => {
setSessionStorage('postDraft', { setSessionStorage('postDraft', {
body: `${ body: `${
$userSettings.crosspostOriginalLink settings.crosspostOriginalLink
? `cross-posted from: ${post.post.ap_id}` ? `cross-posted from: ${post.post.ap_id}`
: `` : ``
}\n${ }\n${
+7 -11
View File
@@ -1,22 +1,17 @@
<script lang="ts"> <script lang="ts">
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import type { View } from '$lib/settings' import type { View } from '$lib/settings.svelte'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { ChevronDown, Icon } from 'svelte-hero-icons' import { ChevronDown, Icon } from 'svelte-hero-icons'
let expanded = $state(false) let element: Element | undefined = $state()
let element: Element = $state()
function isOverflown(element: Element, body: string = '') { function isOverflown(element: Element, body: string = '') {
if (!element) return if (!element) return false
let overflows = return (
element.scrollHeight > element.clientHeight || element.scrollHeight > element.clientHeight ||
element.scrollWidth > element.clientWidth element.scrollWidth > element.clientWidth
)
if (!overflows) expanded = true
else expanded = false
return overflows
} }
interface Props { interface Props {
@@ -37,7 +32,8 @@
class: clazz = '', class: clazz = '',
}: Props = $props() }: Props = $props()
let overflows = $derived(isOverflown(element, body)) let overflows = $derived(element ? isOverflown(element, body) : false)
let expanded = $state(false)
</script> </script>
<svelte:element <svelte:element
@@ -65,7 +65,7 @@
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { getInstance } from '$lib/lemmy.js' import { getInstance } from '$lib/lemmy.js'
import ShieldIcon from '../moderation/ShieldIcon.svelte' import ShieldIcon from '../moderation/ShieldIcon.svelte'
import { userSettings, type View } from '$lib/settings' import { settings, type View } from '$lib/settings.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { Pencil, type IconSource } from 'svelte-hero-icons' import { Pencil, type IconSource } from 'svelte-hero-icons'
@@ -315,11 +315,11 @@
href="/post/{getInstance()}/{id}" href="/post/{getInstance()}/{id}"
class="inline hover:underline class="inline hover:underline
hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0 hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0
{$userSettings.font == 'satoshi/nunito' {settings.font == 'satoshi/nunito'
? 'font-display font-semibold' ? 'font-display font-semibold'
: 'font-medium'} {titleClass}" : 'font-medium'} {titleClass}"
class:text-slate-600={$userSettings.markReadPosts && read} class:text-slate-600={settings.markReadPosts && read}
class:dark:text-zinc-400={$userSettings.markReadPosts && read} class:dark:text-zinc-400={settings.markReadPosts && read}
class:text-base={view == 'compact'} class:text-base={view == 'compact'}
class:text-lg={view != 'compact'} class:text-lg={view != 'compact'}
style="grid-area: title;" style="grid-area: title;"
@@ -1,5 +1,5 @@
<script lang="ts" module> <script lang="ts" module>
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
export const voteColor = (vote: number, border: boolean = false) => export const voteColor = (vote: number, border: boolean = false) =>
vote == 1 vote == 1
? `bg-gradient-to-br from-blue-500 to-indigo-500 dark:from-blue-400 dark:to-indigo-500 text-slate-50 dark:text-zinc-900` ? `bg-gradient-to-br from-blue-500 to-indigo-500 dark:from-blue-400 dark:to-indigo-500 text-slate-50 dark:text-zinc-900`
@@ -20,7 +20,7 @@
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte' import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import type { Post } from 'lemmy-js-client' import type { Post } from 'lemmy-js-client'
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons' import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { vote as voteItem } from '$lib/lemmy/contentview.js' import { vote as voteItem } from '$lib/lemmy/contentview.js'
import { Button, Popover, buttonColor, toast } from 'mono-svelte' import { Button, Popover, buttonColor, toast } from 'mono-svelte'
import { site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'
@@ -1,13 +1,13 @@
<script lang="ts"> <script lang="ts">
import Post from '$lib/components/lemmy/post/Post.svelte' import Post from '$lib/components/lemmy/post/Post.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import type { PostView } from 'lemmy-js-client' import type { PostView } from 'lemmy-js-client'
import { Badge, Button } from 'mono-svelte' import { Badge, Button } from 'mono-svelte'
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons' import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing' import { expoOut } from 'svelte/easing'
import { fly, slide } from 'svelte/transition' import { fly, slide } from 'svelte/transition'
import { combineCrossposts } from './crosspost' import { combineCrossposts } from './crosspost.svelte'
interface Props { interface Props {
posts: PostView[] posts: PostView[]
@@ -32,7 +32,7 @@
</script> </script>
<ul <ul
class="flex flex-col list-none {$userSettings.view == 'card' class="flex flex-col list-none {settings.view == 'card'
? 'gap-3 md:gap-4' ? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800" : 'divide-y'} divide-slate-200 dark:divide-zinc-800"
> >
@@ -53,14 +53,14 @@
</div> </div>
{:else} {:else}
{#each combinedPosts as post, index} {#each combinedPosts as post, index}
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} {#if !(settings.hidePosts.deleted && post.post.deleted) && !(settings.hidePosts.removed && post.post.removed)}
<li class="relative post-container"> <li class="relative post-container">
<Post <Post
hideCommunity={community} hideCommunity={community}
view={(post.post.featured_community || post.post.featured_local) && view={(post.post.featured_community || post.post.featured_local) &&
$userSettings.posts.compactFeatured settings.posts.compactFeatured
? 'compact' ? 'compact'
: $userSettings.view} : settings.view}
{post} {post}
class="transition-all duration-250" class="transition-all duration-250"
on:hide={() => { on:hide={() => {
@@ -102,14 +102,14 @@
> >
<span <span
class="text-sm flex flex-row gap-2 items-center" class="text-sm flex flex-row gap-2 items-center"
class:my-4={$userSettings.view == 'card'} class:my-4={settings.view == 'card'}
> >
Crossposts <hr class="w-full dark:border-zinc-800" /> Crossposts <hr class="w-full dark:border-zinc-800" />
{post.crossposts.length} {post.crossposts.length}
</span> </span>
{#each post.crossposts as crosspost, index} {#each post.crossposts as crosspost, index}
<div class="w-full transition-all mb-4"> <div class="w-full transition-all mb-4">
<Post post={crosspost} view={$userSettings.view} /> <Post post={crosspost} view={settings.view} />
</div> </div>
{/each} {/each}
</div> </div>
@@ -3,7 +3,7 @@
import Post from '$lib/components/lemmy/post/Post.svelte' import Post from '$lib/components/lemmy/post/Post.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import type { import type {
GetPostsResponse, GetPostsResponse,
ListingType, ListingType,
@@ -29,7 +29,7 @@
type SvelteVirtualizer, type SvelteVirtualizer,
} from '@tanstack/svelte-virtual' } from '@tanstack/svelte-virtual'
import { afterNavigate, beforeNavigate } from '$app/navigation' import { afterNavigate, beforeNavigate } from '$app/navigation'
import { combineCrossposts } from './crosspost' import { combineCrossposts } from './crosspost.svelte'
import { client } from '$lib/lemmy' import { client } from '$lib/lemmy'
import { import {
postFeeds, postFeeds,
@@ -199,7 +199,7 @@
<!-- <svelte:window on:keydown={handleKeydown} /> --> <!-- <svelte:window on:keydown={handleKeydown} /> -->
<ul <ul
class="flex flex-col list-none {$userSettings.view == 'card' class="flex flex-col list-none {settings.view == 'card'
? 'gap-3 md:gap-4' ? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800" : 'divide-y'} divide-slate-200 dark:divide-zinc-800"
> >
@@ -247,9 +247,9 @@
hideCommunity={community} hideCommunity={community}
view={(posts[row.index]?.post.featured_community || view={(posts[row.index]?.post.featured_community ||
posts[row.index]?.post.featured_local) && posts[row.index]?.post.featured_local) &&
$userSettings.posts.compactFeatured settings.posts.compactFeatured
? 'compact' ? 'compact'
: $userSettings.view} : settings.view}
{post} {post}
class="transition-all duration-250" class="transition-all duration-250"
on:hide={() => { on:hide={() => {
@@ -263,7 +263,7 @@
</div> </div>
{/if} {/if}
{#if $userSettings.infiniteScroll && browser} {#if settings.infiniteScroll && browser}
{#if error} {#if error}
<div <div
class="flex flex-col justify-center items-center class="flex flex-col justify-center items-center
@@ -1,4 +1,4 @@
import { userSettings } from '$lib/settings.svelte' import { settings } from '$lib/settings.svelte'
import type { PostView } from 'lemmy-js-client' import type { PostView } from 'lemmy-js-client'
import { get } from 'svelte/store' import { get } from 'svelte/store'
@@ -29,8 +29,8 @@ export const combineCrossposts = (
posts?.forEach((post) => { posts?.forEach((post) => {
if ( if (
!post || !post ||
(get(userSettings).hidePosts.deleted && post.post.deleted) || (settings.hidePosts.deleted && post.post.deleted) ||
(get(userSettings).hidePosts.removed && post.post.removed) (settings.hidePosts.removed && post.post.removed)
) )
return return
if (!post?.post?.url) { if (!post?.post?.url) {
@@ -16,9 +16,9 @@
Link, Link,
XMark, XMark,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { placeholders, uploadImage } from '$lib/util.js' import { placeholders, uploadImage } from '$lib/util.svelte.js'
import { Checkbox, TextInput } from 'mono-svelte' import { Checkbox, TextInput } from 'mono-svelte'
import { getSessionStorage, setSessionStorage } from '$lib/session.js' import { getSessionStorage, setSessionStorage } from '$lib/session.js'
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte' import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
import { client, getInstance } from '$lib/lemmy.js' import { client, getInstance } from '$lib/lemmy.js'
import type { View } from '$lib/settings.svelte' import type { View } from '$lib/settings.svelte'
import { isImage, isVideo } from '$lib/ui/image' import { isImage, isVideo } from '$lib/ui/image'
import { canParseUrl, findClosestNumber } from '$lib/util' import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client' import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
export const isCommentMutable = (comment: CommentView, me: PersonView) => export const isCommentMutable = (comment: CommentView, me: PersonView) =>
@@ -10,7 +10,7 @@
import { optimizeImageURL } from '../helpers' import { optimizeImageURL } from '../helpers'
import PostLinkSources from './PostLinkSources.svelte' import PostLinkSources from './PostLinkSources.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import type { View } from '$lib/settings' import type { View } from '$lib/settings.svelte'
interface Props { interface Props {
url: string url: string
@@ -5,10 +5,10 @@
return 'www.youtube-nocookie.com' return 'www.youtube-nocookie.com'
} }
case 'invidious': { case 'invidious': {
return get(userSettings).embeds.invidious || 'yewtu.be' return settings.embeds.invidious || 'yewtu.be'
} }
case 'piped': { case 'piped': {
return get(userSettings).embeds.piped || 'piped.video' return settings.embeds.piped || 'piped.video'
} }
} }
} }
@@ -34,7 +34,7 @@
type IconSource, type IconSource,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { optimizeImageURL, type IframeType, type MediaType } from '../helpers' import { optimizeImageURL, type IframeType, type MediaType } from '../helpers'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { get } from 'svelte/store' import { get } from 'svelte/store'
const urlToEmbed = (inputUrl: string) => { const urlToEmbed = (inputUrl: string) => {
@@ -50,7 +50,7 @@
if (autoplay) url.searchParams.set('autoplay', '1') if (autoplay) url.searchParams.set('autoplay', '1')
return `https://${youtubeDomain( return `https://${youtubeDomain(
$userSettings.embeds.youtube, settings.embeds.youtube,
)}/embed/${videoID}?${url.searchParams.toString()}` )}/embed/${videoID}?${url.searchParams.toString()}`
} }
@@ -98,8 +98,8 @@
type = 'none', type = 'none',
thumbnail = undefined, thumbnail = undefined,
url, url,
opened = $bindable(!$userSettings.embeds.clickToView), opened = $bindable(!settings.embeds.clickToView),
autoplay = $userSettings.embeds.clickToView, autoplay = settings.embeds.clickToView,
class: clazz = '', class: clazz = '',
}: Props = $props() }: Props = $props()
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { stopPropagation } from 'svelte/legacy' 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 type { Post } from 'lemmy-js-client'
import { bestImageURL, postLink } from '../helpers' import { bestImageURL, postLink } from '../helpers'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte' 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--> <!--disabled preloads here since most people will hover over every image while scrolling-->
<svelte:element <svelte:element
this={$userSettings.expandImages ? 'button' : 'a'} this={settings.expandImages ? 'button' : 'a'}
href={postLink(post)} href={postLink(post)}
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900" 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" data-sveltekit-preload-data="off"
@@ -10,7 +10,7 @@
import ExpandableImage, { import ExpandableImage, {
showImage, showImage,
} from '$lib/components/ui/ExpandableImage.svelte' } 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 type { Post } from 'lemmy-js-client'
import PostIframe from './PostIframe.svelte' import PostIframe from './PostIframe.svelte'
import { Button, Material, modal } from 'mono-svelte' import { Button, Material, modal } from 'mono-svelte'
@@ -31,7 +31,7 @@
post, post,
type = 'none', type = 'none',
opened = undefined, opened = undefined,
blur = post.nsfw && $userSettings.nsfwBlur, blur = post.nsfw && settings.nsfwBlur,
}: Props = $props() }: Props = $props()
</script> </script>
@@ -6,7 +6,7 @@
type MediaType, type MediaType,
} from '$lib/components/lemmy/post/helpers.js' } from '$lib/components/lemmy/post/helpers.js'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte' 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 { isImage } from '$lib/ui/image'
import type { Post } from 'lemmy-js-client' import type { Post } from 'lemmy-js-client'
import { Material, Popover } from 'mono-svelte' import { Material, Popover } from 'mono-svelte'
@@ -34,7 +34,7 @@
post, post,
type = 'none', type = 'none',
view = 'cozy', view = 'cozy',
blur = post.nsfw && $userSettings.nsfwBlur, blur = post.nsfw && settings.nsfwBlur,
style = '', style = '',
class: clazz = '', class: clazz = '',
}: Props = $props() }: Props = $props()
@@ -50,7 +50,7 @@
{#if post.alt_text} {#if post.alt_text}
<Popover <Popover
openOnHover openOnHover
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'} placement={settings.leftAlign ? 'bottom-start' : 'bottom-end'}
> >
{#snippet target()} {#snippet target()}
<Material <Material
@@ -68,7 +68,7 @@
</Popover> </Popover>
{/if} {/if}
<svelte:element <svelte:element
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'} this={!settings.expandImages || type != 'image' ? 'a' : 'button'}
href={postLink(post)} href={postLink(post)}
onclick={() => { onclick={() => {
if (type == 'image') { if (type == 'image') {
@@ -50,7 +50,7 @@
<script lang="ts"> <script lang="ts">
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import Logo from '$lib/components/ui/Logo.svelte' import Logo from '$lib/components/ui/Logo.svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import type { Person } from 'lemmy-js-client' import type { Person } from 'lemmy-js-client'
import { Icon, Language, NoSymbol } from 'svelte-hero-icons' import { Icon, Language, NoSymbol } from 'svelte-hero-icons'
@@ -74,9 +74,9 @@
avatarSize = 24, avatarSize = 24,
badges = true, badges = true,
inComment = false, inComment = false,
showInstance = $userSettings.showInstances.user || showInstance = settings.showInstances.user ||
($userSettings.showInstances.comments && inComment), (settings.showInstances.comments && inComment),
displayName = $userSettings.displayNames, displayName = settings.displayNames,
instanceClass = '', instanceClass = '',
class: clazz = '', class: clazz = '',
children, children,
+4 -7
View File
@@ -92,8 +92,6 @@
import SvelteMarkdown from 'svelte-markdown' import SvelteMarkdown from 'svelte-markdown'
options.inline = inline
interface Props { interface Props {
source?: string source?: string
inline?: boolean inline?: boolean
@@ -110,10 +108,9 @@
class: clazz = '', class: clazz = '',
}: Props = $props() }: Props = $props()
let tokens options.inline = inline
run(() => {
tokens = marked.lexer(source) let tokens = $derived.by(() => marked.lexer(source))
})
</script> </script>
<div <div
@@ -123,7 +120,7 @@
{style} {style}
> >
<SvelteMarkdown <SvelteMarkdown
bind:source={tokens} source={tokens}
{renderers} {renderers}
{options} {options}
isInline={inline || undefined} isInline={inline || undefined}
@@ -1,11 +1,11 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy' import { run } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import MultiSelect from '$lib/components/input/Switch.svelte' import MultiSelect from '$lib/components/input/Switch.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { uploadImage } from '$lib/util.js' import { uploadImage } from '$lib/util.svelte.js'
import { ImageInput, toast } from 'mono-svelte' import { ImageInput, toast } from 'mono-svelte'
import { Button, Label, Modal, TextArea } from 'mono-svelte' import { Button, Label, Modal, TextArea } from 'mono-svelte'
import { createEventDispatcher, tick } from 'svelte' import { createEventDispatcher, tick } from 'svelte'
@@ -4,7 +4,7 @@
import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte' import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte'
import { text } from './translation' import { text } from './translation'
import { locale, t } from '$lib/translations' import { locale, t } from '$lib/translations'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { ArrowRight, Icon } from 'svelte-hero-icons' import { ArrowRight, Icon } from 'svelte-hero-icons'
import MarkdownEditor from '../markdown/MarkdownEditor.svelte' import MarkdownEditor from '../markdown/MarkdownEditor.svelte'
@@ -30,7 +30,7 @@
let to = $state($locale) let to = $state($locale)
async function translate(text: string) { async function translate(text: string) {
const url = $userSettings.translator const url = settings.translator
if (!url) { if (!url) {
return return
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { findClosestNumber } from '$lib/util.js' import { findClosestNumber } from '$lib/util.svelte.js'
import { createAvatar } from '@dicebear/core' import { createAvatar } from '@dicebear/core'
import * as initials from '@dicebear/initials' import * as initials from '@dicebear/initials'
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
interface Props { interface Props {
width?: number width?: number
+6 -9
View File
@@ -65,12 +65,9 @@
export let screenWidth = writable(1000) export let screenWidth = writable(1000)
export let dockProps: Readable<ReturnType<typeof calculateDockProperties>> = export let dockProps: Readable<ReturnType<typeof calculateDockProperties>> =
derivedStore( derivedStore([screenWidth], ([$screenWidth], set) => {
[userSettings, screenWidth], set(calculateDockProperties(settings.dock, $screenWidth))
([$settings, $screenWidth], set) => { })
set(calculateDockProperties($settings.dock, $screenWidth))
},
)
export let contentPadding: Readable<ReturnType<typeof calculatePadding>> = export let contentPadding: Readable<ReturnType<typeof calculatePadding>> =
derivedStore(dockProps, ($dockProps, set) => derivedStore(dockProps, ($dockProps, set) =>
set(calculatePadding($dockProps.noGap, $dockProps.top, true)), set(calculatePadding($dockProps.noGap, $dockProps.top, true)),
@@ -78,9 +75,9 @@
</script> </script>
<script lang="ts"> <script lang="ts">
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { themeVars } from '$lib/ui/colors' import { themeVars } from '$lib/ui/colors'
import { routes } from '$lib/util.js' import { routes } from '$lib/util.svelte.js'
import { writable, type Readable, type Writable } from 'svelte/store' import { writable, type Readable, type Writable } from 'svelte/store'
interface Props { interface Props {
@@ -155,7 +152,7 @@
})} })}
</div> </div>
<div <div
class="content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen {$userSettings.newWidth class="content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen {settings.newWidth
? 'limit-width' ? 'limit-width'
: ''}" : ''}"
> >
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { contentPadding } from '../Shell.svelte' import { contentPadding } from '../Shell.svelte'
interface Props { interface Props {
@@ -35,7 +35,7 @@
> >
<h1 <h1
class="text-3xl font-medium flex gap-2 w-full class="text-3xl font-medium flex gap-2 w-full
{$userSettings.font == 'satoshi/nunito' ? 'font-display' : ''} {clazz ?? ''}" {settings.font == 'satoshi/nunito' ? 'font-display' : ''} {clazz ?? ''}"
> >
{@render children?.()} {@render children?.()}
</h1> </h1>
+3 -3
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { notifications, profile } from '$lib/auth.js' import { notifications, profile } from '$lib/auth.svelte.js'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte' import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
import { import {
amModOfAny, amModOfAny,
@@ -36,7 +36,7 @@
import { t } from '$lib/translations' import { t } from '$lib/translations'
import CommandsWrapper from './commands/CommandsWrapper.svelte' import CommandsWrapper from './commands/CommandsWrapper.svelte'
import { optimizeImageURL } from '$lib/components/lemmy/post/helpers' import { optimizeImageURL } from '$lib/components/lemmy/post/helpers'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { dockProps } from '../layout/Shell.svelte' import { dockProps } from '../layout/Shell.svelte'
let promptOpen: boolean = $state(false) let promptOpen: boolean = $state(false)
@@ -67,7 +67,7 @@
class="ml-2 logo" class="ml-2 logo"
adaptive={false} adaptive={false}
> >
{#snippet icon()} {#snippet customIcon()}
{#if LINKED_INSTANCE_URL} {#if LINKED_INSTANCE_URL}
{#if $site} {#if $site}
<Avatar <Avatar
+3 -3
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { stopPropagation } from 'svelte/legacy' import { stopPropagation } from 'svelte/legacy'
import { notifications, profile } from '$lib/auth' import { notifications, profile } from '$lib/auth.svelte'
import { import {
Badge, Badge,
@@ -34,7 +34,7 @@
UserGroup, UserGroup,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { colorScheme } from '$lib/ui/colors' import { colorScheme } from '$lib/ui/colors'
import { userSettings } from '$lib/settings' import { settings } from '$lib/settings.svelte'
import { site } from '$lib/lemmy' import { site } from '$lib/lemmy'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte' import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
@@ -185,7 +185,7 @@
{/snippet} {/snippet}
{$t('nav.menu.theme')} {$t('nav.menu.theme')}
</MenuButton> </MenuButton>
{#if $userSettings.debugInfo} {#if settings.debugInfo}
<MenuButton link href="/util"> <MenuButton link href="/util">
{#snippet prefix()} {#snippet prefix()}
<Icon src={BugAnt} mini width={16} /> <Icon src={BugAnt} mini width={16} />
@@ -7,16 +7,15 @@
type IconSource, type IconSource,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import Avatar from '../../Avatar.svelte' import Avatar from '../../Avatar.svelte'
import type { Action } from './actions' import type { Action } from './actions.svelte'
interface Props { interface Props {
action: Action; action: Action
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { action, class: clazz = '', children }: Props = $props(); let { action, class: clazz = '', children }: Props = $props()
</script> </script>
<Button <Button
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'; import { run } from 'svelte/legacy'
import { resumables } from '$lib/lemmy/item' import { resumables } from '$lib/lemmy/item'
import { TextInput } from 'mono-svelte' import { TextInput } from 'mono-svelte'
@@ -9,19 +9,17 @@
import CommandItem from './CommandItem.svelte' import CommandItem from './CommandItem.svelte'
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { afterNavigate, goto } from '$app/navigation' import { afterNavigate, goto } from '$app/navigation'
import { profile, profileData } from '$lib/auth' import { profile, profileData } from '$lib/auth.svelte'
import { getGroups, type Action, type Group } from './actions' import { getGroups, type Action, type Group } from './actions.svelte'
import { themeData } from '$lib/ui/colors' import { themeData } from '$lib/ui/colors'
import { page } from '$app/stores' import { page } from '$app/stores'
interface Props { interface Props {
open?: boolean; open?: boolean
groups?: Group[]; groups?: Group[]
} }
let { open = $bindable(false), groups = $bindable([]) }: Props = $props(); let { open = $bindable(false), groups = $bindable([]) }: Props = $props()
let search = $state('') let search = $state('')
let container: HTMLElement = $state() let container: HTMLElement = $state()
@@ -87,7 +85,7 @@
score: Math.max( score: Math.max(
fuzzySearch(action.name, term), fuzzySearch(action.name, term),
fuzzySearch(group.name, term), fuzzySearch(group.name, term),
action.detail ? fuzzySearch(action.detail, term) : -1 action.detail ? fuzzySearch(action.detail, term) : -1,
), ),
})) }))
.filter((action) => action.score > 0) .filter((action) => action.score > 0)
@@ -98,7 +96,7 @@
actions: scoredActions, actions: scoredActions,
score: Math.max( score: Math.max(
fuzzySearch(group.name, term), fuzzySearch(group.name, term),
...scoredActions.map((a) => a.score) ...scoredActions.map((a) => a.score),
), ),
} }
}) })
@@ -130,10 +128,9 @@
updateFilteredGroups() updateFilteredGroups()
} }
function flattenActions( function flattenActions(
actions: Action[], actions: Action[],
subaction: boolean = true subaction: boolean = true,
): Action[] { ): Action[] {
return actions.flatMap((action) => [ return actions.flatMap((action) => [
action, action,
@@ -230,20 +227,22 @@
}) })
run(() => { run(() => {
if (open) search = '' if (open) search = ''
}); })
run(() => { run(() => {
groups = getGroups( groups = getGroups(
$resumables, $resumables,
$profile, $profile,
$profileData.profiles, $profileData.profiles,
$themeData, $themeData,
$page.data.contextual?.actions $page.data.contextual?.actions,
)
})
let flattenedActions = $derived(
filteredGroups.flatMap((group) => group.actions),
) )
});
let flattenedActions = $derived(filteredGroups.flatMap((group) => group.actions))
run(() => { run(() => {
debouncedSearch(search) debouncedSearch(search)
}); })
</script> </script>
<svelte:window onkeydown={handleKeydown} /> <svelte:window onkeydown={handleKeydown} />
@@ -5,10 +5,10 @@
import { CommandLine, Icon } from 'svelte-hero-icons' import { CommandLine, Icon } from 'svelte-hero-icons'
interface Props { interface Props {
open?: boolean; open?: boolean
} }
let { open = $bindable(false) }: Props = $props(); let { open = $bindable(false) }: Props = $props()
function handleKeydown(event: KeyboardEvent) { function handleKeydown(event: KeyboardEvent) {
if ( if (
@@ -25,7 +25,7 @@
{#if open} {#if open}
<Modal bind:open> <Modal bind:open>
{#snippet title()} {#snippet customTitle()}
<span class="flex items-center gap-1"> <span class="flex items-center gap-1">
<svg <svg
width="24" width="24"
@@ -1,15 +1,15 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/stores' import { page } from '$app/stores'
import { setUserID, type Profile } from '$lib/auth' import { setUserID, type Profile } from '$lib/auth.svelte'
import { import {
amModOfAny, amModOfAny,
isAdmin, isAdmin,
} from '$lib/components/lemmy/moderation/moderation' } from '$lib/components/lemmy/moderation/moderation'
import { resumables, type ResumableItem } from '$lib/lemmy/item' import { resumables, type ResumableItem } from '$lib/lemmy/item'
import { userSettings } from '$lib/settings.svelte' import { settings } from '$lib/settings.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { colorScheme, theme, themeData, type ThemeData } from '$lib/ui/colors' import { colorScheme, theme, themeData, type ThemeData } from '$lib/ui/colors'
import { fullCommunityName } from '$lib/util' import { fullCommunityName } from '$lib/util.svelte'
import { import {
ArrowRightOnRectangle, ArrowRightOnRectangle,
Bookmark, Bookmark,
@@ -339,10 +339,7 @@ export function getGroups(
}), }),
icon: ViewColumns, icon: ViewColumns,
handle: () => handle: () =>
userSettings.update((s) => ({ settings.view = 'compact'
...s,
view: 'compact',
})),
}, },
{ {
name: t.get('nav.commands.setViewTo', { name: t.get('nav.commands.setViewTo', {
@@ -350,10 +347,7 @@ export function getGroups(
}), }),
icon: ViewColumns, icon: ViewColumns,
handle: () => handle: () =>
userSettings.update((s) => ({ settings.view = 'cozy'
...s,
view: 'cozy',
})),
}, },
{ {
name: t.get('nav.commands.setViewTo', { name: t.get('nav.commands.setViewTo', {
@@ -361,21 +355,7 @@ export function getGroups(
}), }),
icon: ViewColumns, icon: ViewColumns,
handle: () => handle: () =>
userSettings.update((s) => ({ settings.view = 'list'
...s,
view: 'list',
})),
},
{
name: t.get('nav.commands.setViewTo', {
default: t.get('filter.view.legacy'),
}),
icon: ViewColumns,
handle: () =>
userSettings.update((s) => ({
...s,
view: 'card',
})),
}, },
], ],
}, },
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/auth' import { profile } from '$lib/auth.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte' import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { addFavorite } from '$lib/lemmy/item' import { addFavorite } from '$lib/lemmy/item'
@@ -11,11 +11,11 @@
import { expoOut } from 'svelte/easing' import { expoOut } from 'svelte/easing'
interface Props { interface Props {
items: Community[]; items: Community[]
isFavorites?: boolean; isFavorites?: boolean
} }
let { items, isFavorites = false }: Props = $props(); let { items, isFavorites = false }: Props = $props()
</script> </script>
{#each items.sort( (a, b) => a.title.localeCompare(b.title), ) as follow (follow.id)} {#each items.sort( (a, b) => a.title.localeCompare(b.title), ) as follow (follow.id)}
@@ -1,22 +1,21 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/stores' import { page } from '$app/stores'
import { profile, setUserID, type Profile } from '$lib/auth.js' import { profile, setUserID, type Profile } from '$lib/auth.svelte.js'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte' import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance' import { LINKED_INSTANCE_URL } from '$lib/instance'
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte' import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons' import { Icon, QuestionMarkCircle } from 'svelte-hero-icons'
let switching: boolean = $state(false) let switching: boolean = $state(false)
interface Props { interface Props {
prof: Profile; prof: Profile
index: number; index: number
guest?: boolean; guest?: boolean
} }
let { prof, index, guest = false }: Props = $props(); let { prof, index, guest = false }: Props = $props()
</script> </script>
<SidebarButton <SidebarButton
@@ -48,7 +47,6 @@
{index} {index}
{guest} {guest}
selected={$profile?.id == prof.id} selected={$profile?.id == prof.id}
/> />
{/snippet} {/snippet}
<span <span
+13 -13
View File
@@ -8,8 +8,8 @@
UserCircle, UserCircle,
UserGroup, UserGroup,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { notifications, profile, profileData } from '$lib/auth.js' import { notifications, profile, profileData } from '$lib/auth.svelte.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte' import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte' import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte' import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
@@ -36,9 +36,9 @@
gap-1 h-fit max-h-screen {clazz}" gap-1 h-fit max-h-screen {clazz}"
{style} {style}
> >
{#if $userSettings.dock.pins?.length ?? 0 > 0} {#if settings.dock.pins?.length ?? 0 > 0}
<div class="flex items-center flex-wrap gap-2 pl-1.5"> <div class="flex items-center flex-wrap gap-2 pl-1.5">
{#each $userSettings.dock.pins as pin} {#each settings.dock.pins as pin}
<SidebarButton <SidebarButton
icon={iconOfLink(pin.url)} icon={iconOfLink(pin.url)}
on:click={() => goto(pin.url)} on:click={() => goto(pin.url)}
@@ -46,8 +46,8 @@
selected={`${$page.url.pathname}${$page.url.search}` == pin.url} selected={`${$page.url.pathname}${$page.url.search}` == pin.url}
on:contextmenu={(e) => { on:contextmenu={(e) => {
e.preventDefault() e.preventDefault()
$userSettings.dock.pins = $userSettings.dock.pins.toSpliced( settings.dock.pins = settings.dock.pins.toSpliced(
$userSettings.dock.pins.findLastIndex((p) => pin.url == p.url), settings.dock.pins.findLastIndex((p) => pin.url == p.url),
1, 1,
) )
return false return false
@@ -120,7 +120,7 @@
<Expandable <Expandable
class="max-w-full min-w-0 w-full" class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.accounts} bind:open={settings.expand.accounts}
> >
{#snippet title()} {#snippet title()}
<span class="px-2 py-1 w-full"> <span class="px-2 py-1 w-full">
@@ -148,11 +148,11 @@
{#if $profile?.favorites && $profile?.favorites.length > 0} {#if $profile?.favorites && $profile?.favorites.length > 0}
<Expandable <Expandable
class="max-w-full min-w-0 w-full" class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.favorites} bind:open={settings.expand.favorites}
> >
{#snippet title()} {#snippet title()}
<span <span
class="px-2 py-1 w-full {$userSettings.expandSidebar class="px-2 py-1 w-full {settings.expandSidebar
? '' ? ''
: '//max-lg:hidden'}" : '//max-lg:hidden'}"
> >
@@ -174,11 +174,11 @@
{#if $profile?.user.moderates.length > 0} {#if $profile?.user.moderates.length > 0}
<Expandable <Expandable
class="max-w-full min-w-0 w-full" class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.moderates} bind:open={settings.expand.moderates}
> >
{#snippet title()} {#snippet title()}
<span <span
class="px-2 py-1 w-full {$userSettings.expandSidebar class="px-2 py-1 w-full {settings.expandSidebar
? '' ? ''
: '//max-lg:hidden'}" : '//max-lg:hidden'}"
> >
@@ -201,11 +201,11 @@
<Expandable <Expandable
class="max-w-full min-w-0 w-full" class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.communities} bind:open={settings.expand.communities}
> >
{#snippet title()} {#snippet title()}
<span <span
class="px-2 py-1 w-full {$userSettings.expandSidebar class="px-2 py-1 w-full {settings.expandSidebar
? '' ? ''
: '//max-lg:hidden'}" : '//max-lg:hidden'}"
> >
@@ -2,7 +2,7 @@
import { run } from 'svelte/legacy' import { run } from 'svelte/legacy'
import { page } from '$app/stores' import { page } from '$app/stores'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons' import { Icon, type IconSource } from 'svelte-hero-icons'
+2 -2
View File
@@ -2,8 +2,8 @@ import { type GetSiteResponse, LemmyHttp } from 'lemmy-js-client'
import { get, writable } from 'svelte/store' import { get, writable } from 'svelte/store'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
import { instance } from '$lib/instance.js' import { instance } from '$lib/instance.js'
import { instanceToURL } from '$lib/util.js' import { instanceToURL } from '$lib/util.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
export const site = writable<GetSiteResponse | undefined>(undefined) export const site = writable<GetSiteResponse | undefined>(undefined)
+8 -8
View File
@@ -1,13 +1,13 @@
<script lang="ts"> <script lang="ts">
import type { Profile } from '$lib/auth.js' import type { Profile } from '$lib/auth.svelte.js'
import { Icon, UserCircle } from 'svelte-hero-icons' import { Icon, UserCircle } from 'svelte-hero-icons'
interface Props { interface Props {
profile?: Profile | undefined; profile?: Profile | undefined
selected?: boolean; selected?: boolean
index?: number; index?: number
size?: number; size?: number
guest?: boolean; guest?: boolean
} }
let { let {
@@ -15,8 +15,8 @@
selected = false, selected = false,
index = 0, index = 0,
size = 20, size = 20,
guest = false guest = false,
}: Props = $props(); }: Props = $props()
</script> </script>
{#if profile} {#if profile}
+1 -1
View File
@@ -1,4 +1,4 @@
import { fullCommunityName } from '$lib/util' import { fullCommunityName } from '$lib/util.svelte'
import type { Community, Person } from 'lemmy-js-client' import type { Community, Person } from 'lemmy-js-client'
export const communityLink = (community: Community, prefix: string = '') => export const communityLink = (community: Community, prefix: string = '') =>
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile, profileData } from '$lib/auth' import { profile, profileData } from '$lib/auth.svelte'
import type { import type {
CommentReportView, CommentReportView,
CommentView, CommentView,
+2 -2
View File
@@ -1,6 +1,6 @@
import { profile, profileData, type Profile } from '$lib/auth.js' import { profile, profileData, type Profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { trycatch } from '$lib/util.js' import { trycatch } from '$lib/util.svelte'
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client' import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
import { get } from 'svelte/store' import { get } from 'svelte/store'
-3
View File
@@ -8,7 +8,6 @@ export { default as Spinner } from './loader/Spinner.svelte'
export { default as Routebar } from './nav/Routebar.svelte' export { default as Routebar } from './nav/Routebar.svelte'
export { default as Material } from './materials/Material.svelte' export { default as Material } from './materials/Material.svelte'
export { default as Form } from './forms/Form.svelte'
export { default as Label } from './forms/Label.svelte' export { default as Label } from './forms/Label.svelte'
export { default as FileInput } from './forms/FileInput.svelte' export { default as FileInput } from './forms/FileInput.svelte'
export { default as TextInput } from './forms/TextInput.svelte' export { default as TextInput } from './forms/TextInput.svelte'
@@ -21,8 +20,6 @@ export { default as Switch } from './forms/Switch.svelte'
export { default as Radio } from './forms/Radio.svelte' export { default as Radio } from './forms/Radio.svelte'
export { default as RadioGroup } from './forms/RadioGroup.svelte' export { default as RadioGroup } from './forms/RadioGroup.svelte'
export { default as Choicebox } from './forms/Choicebox.svelte'
export { default as ChoiceboxGroup } from './forms/ChoiceboxGroup.svelte'
export { default as Popover } from './popover/Popover.svelte' export { default as Popover } from './popover/Popover.svelte'
export { default as Menu } from './popover/Menu.svelte' export { default as Menu } from './popover/Menu.svelte'
+11 -13
View File
@@ -6,15 +6,15 @@
import { Icon, type IconSource } from 'svelte-hero-icons' import { Icon, type IconSource } from 'svelte-hero-icons'
interface Props { interface Props {
color?: ButtonColor; color?: ButtonColor
alignment?: ButtonAlignment; alignment?: ButtonAlignment
href?: string | undefined; href?: string | undefined
disabled?: boolean; disabled?: boolean
class?: string; class?: string
icon?: IconSource; icon?: IconSource
prefix?: import('svelte').Snippet; prefix?: import('svelte').Snippet
children?: import('svelte').Snippet; children?: import('svelte').Snippet
suffix?: import('svelte').Snippet; suffix?: import('svelte').Snippet
[key: string]: any [key: string]: any
} }
@@ -29,8 +29,7 @@
children, children,
suffix, suffix,
...rest ...rest
}: Props = $props(); }: Props = $props()
</script> </script>
<Button <Button
@@ -53,9 +52,8 @@
? 'text-slate-600 dark:text-zinc-400' ? 'text-slate-600 dark:text-zinc-400'
: ''} : ''}
flex-shrink-0" flex-shrink-0"
> >
{#if !icon} {#if icon}
<Icon src={icon} micro size="16" /> <Icon src={icon} micro size="16" />
{:else} {:else}
{@render prefix?.()} {@render prefix?.()}
+27 -29
View File
@@ -29,6 +29,33 @@
import { focusTrap } from 'svelte-focus-trap' import { focusTrap } from 'svelte-focus-trap'
import { tick } from 'svelte' import { tick } from 'svelte'
interface Props {
openOnHover?: boolean
open?: boolean
placement?: Placement
middleware?: Middleware[]
strategy?: Strategy
manual?: boolean
popoverClass?: string
class?: string
target?: import('svelte').Snippet
popover?: import('svelte').Snippet
children?: import('svelte').Snippet
}
let {
openOnHover = false,
open = $bindable(false),
placement = 'bottom-start',
middleware = [offset(6), shift(), flip()],
strategy = 'fixed',
manual = false,
popoverClass = '',
class: clazz = '',
target,
popover,
children,
}: Props = $props()
let canUseContents = $state(true) let canUseContents = $state(true)
@@ -56,35 +83,6 @@
floatingRef(node) floatingRef(node)
} }
} }
interface Props {
openOnHover?: boolean;
open?: boolean;
placement?: Placement;
middleware?: Middleware[];
strategy?: Strategy;
manual?: boolean;
popoverClass?: string;
class?: string;
target?: import('svelte').Snippet;
popover?: import('svelte').Snippet;
children?: import('svelte').Snippet;
}
let {
openOnHover = false,
open = $bindable(false),
placement = 'bottom-start',
middleware = [offset(6), shift(), flip()],
strategy = 'fixed',
manual = false,
popoverClass = '',
class: clazz = '',
target,
popover,
children
}: Props = $props();
</script> </script>
<svelte:body <svelte:body
@@ -1,4 +1,4 @@
import type { CommentSortType, SortType } from 'lemmy-js-client' import type { CommentSortType, ListingType, SortType } from 'lemmy-js-client'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { locale } from './translations' import { locale } from './translations'
@@ -40,7 +40,7 @@ interface Settings {
defaultSort: { defaultSort: {
sort: SortType sort: SortType
feed: 'All' | 'Subscribed' | 'Local' feed: ListingType
comments: CommentSortType comments: CommentSortType
} }
hidePosts: { hidePosts: {
@@ -191,37 +191,27 @@ export const defaultSettings: Settings = {
logoColorMonth: null, logoColorMonth: null,
} }
export const userSettings = writable(defaultSettings) function createSettingsState(initial: Settings) {
let settings = $state(initial)
const migrate = (settings: any): Settings => {
if (typeof settings?.moderation?.removalReasonPreset == 'string') {
settings.moderation.presets = [
{
title: 'Preset 1',
content: settings.moderation.removalReasonPreset,
},
]
settings.moderation.removalReasonPreset = undefined
}
return settings return settings
} }
export let settings = createSettingsState(defaultSettings)
if (typeof window != 'undefined') { if (typeof window != 'undefined') {
let oldUserSettings = JSON.parse( let oldUserSettings = JSON.parse(
localStorage.getItem('settings') ?? JSON.stringify(defaultSettings) localStorage.getItem('settings') ?? JSON.stringify(defaultSettings)
) )
oldUserSettings = migrate(oldUserSettings) // settings = {
// ...defaultSettings,
userSettings.set({ // ...oldUserSettings,
...defaultSettings, // settingsVer: defaultSettings.settingsVer,
...oldUserSettings, // }
settingsVer: defaultSettings.settingsVer,
})
} }
userSettings.subscribe((settings) => { $effect.root(() => {
if (typeof window != 'undefined') { if (typeof window != 'undefined') {
localStorage.setItem('settings', JSON.stringify(settings)) localStorage.setItem('settings', JSON.stringify(settings))
} }
+2 -2
View File
@@ -1,6 +1,6 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte'
import { get } from 'svelte/store' import { get } from 'svelte/store'
import type { SubscribedType } from 'lemmy-js-client' import type { SubscribedType } from 'lemmy-js-client'
import { page } from '$app/stores' import { page } from '$app/stores'
@@ -53,7 +53,7 @@ export const placeholders = {
'hello user i am a sentient placeholder. please dont type anything or i disappear forever. thanks', 'hello user i am a sentient placeholder. please dont type anything or i disappear forever. thanks',
], ],
get: (type: 'url' | 'post' | 'comment') => { get: (type: 'url' | 'post' | 'comment') => {
return get(userSettings)?.randomPlaceholders return settings.randomPlaceholders
? placeholders[type][ ? placeholders[type][
Math.floor(Math.random() * placeholders[type].length) Math.floor(Math.random() * placeholders[type].length)
] ]
+32 -42
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'; import { run } from 'svelte/legacy'
import Navbar from '$lib/components/ui/navbar/Navbar.svelte' import Navbar from '$lib/components/ui/navbar/Navbar.svelte'
import '../style/app.css' import '../style/app.css'
@@ -15,7 +15,7 @@
theme, theme,
themeVars, themeVars,
} from '$lib/ui/colors.js' } from '$lib/ui/colors.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { import {
Button, Button,
ModalContainer, ModalContainer,
@@ -26,7 +26,7 @@
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { Forward, Icon } from 'svelte-hero-icons' import { Forward, Icon } from 'svelte-hero-icons'
import { routes } from '$lib/util.js' import { routes } from '$lib/util.svelte.js'
import Shell from '$lib/components/ui/layout/Shell.svelte' import Shell from '$lib/components/ui/layout/Shell.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte' import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'
@@ -35,10 +35,10 @@
import { locale } from '$lib/translations' import { locale } from '$lib/translations'
import { getDefaultColors } from '$lib/ui/presets' import { getDefaultColors } from '$lib/ui/presets'
interface Props { interface Props {
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { children }: Props = $props(); let { children }: Props = $props()
nProgress.configure({ nProgress.configure({
minimum: 0.4, minimum: 0.4,
@@ -62,7 +62,7 @@
nProgress.done() nProgress.done()
} }
} }
}); })
onMount(() => { onMount(() => {
if (browser) { if (browser) {
@@ -70,31 +70,33 @@
history.replaceState( history.replaceState(
null, null,
'', '',
window.location.toString().replace('#main', '') window.location.toString().replace('#main', ''),
) )
} }
document.body.querySelector('.loader')?.classList.add('hidden') document.body.querySelector('.loader')?.classList.add('hidden')
themeVars.subscribe((vars) => { themeVars.subscribe((vars) => {
document.body.setAttribute('style', vars) document.body.setAttribute('style', vars)
}) })
userSettings.subscribe((settings) => { // $effect(() => {
document.body.classList.remove( // if (settings) {
'font-display', // document.body.classList.remove(
'font-inter', // 'font-display',
'font-sans', // 'font-inter',
'font-system', // 'font-sans',
'font-nunito' // 'font-system',
) // 'font-nunito',
document.body.classList.add( // )
settings.font == 'inter' // document.body.classList.add(
? 'font-inter' // settings.font == 'inter'
: $userSettings.font == 'system' // ? 'font-inter'
? 'font-system' // : settings.font == 'system'
: $userSettings.font == 'satoshi/nunito' // ? 'font-system'
? 'font-nunito' // : settings.font == 'satoshi/nunito'
: 'font-sans' // ? 'font-nunito'
) // : 'font-sans',
}) // )
// }
// })
} }
}) })
</script> </script>
@@ -106,8 +108,8 @@
name="theme-color" name="theme-color"
content={rgbToHex( content={rgbToHex(
$colorScheme && inDarkColorScheme() $colorScheme && inDarkColorScheme()
? $theme.colors.zinc?.[925] ?? getDefaultColors().zinc[925] ? ($theme.colors.zinc?.[925] ?? getDefaultColors().zinc[925])
: $theme.colors.slate?.[25] ?? getDefaultColors().slate[25] : ($theme.colors.slate?.[25] ?? getDefaultColors().slate[25]),
)} )}
/> />
{#if LINKED_INSTANCE_URL} {#if LINKED_INSTANCE_URL}
@@ -129,7 +131,7 @@
Skip Navigation Skip Navigation
</Button> </Button>
<Shell <Shell
dir={$locale == 'he' && $userSettings.useRtl ? 'rtl' : 'ltr'} dir={$locale == 'he' && settings.useRtl ? 'rtl' : 'ltr'}
class="min-h-screen " class="min-h-screen "
route={$page.route} route={$page.route}
> >
@@ -139,20 +141,10 @@
<ModalContainer /> <ModalContainer />
{#snippet sidebar({ style: s, class: c })} {#snippet sidebar({ style: s, class: c })}
<Sidebar <Sidebar class={c} style={s} />
route={$page.route.id ?? ''}
class={c}
style={s}
/>
{/snippet} {/snippet}
{#snippet main({ style: s, class: c })} {#snippet main({ style: s, class: c })}
<main <main
class="p-4 sm:p-6 min-w-0 w-full flex flex-col h-full relative {c}" class="p-4 sm:p-6 min-w-0 w-full flex flex-col h-full relative {c}"
style={s} style={s}
id="main" id="main"
@@ -167,9 +159,7 @@
<div class={c} style={s}> <div class={c} style={s}>
{#if $page.data.slots?.sidebar?.component} {#if $page.data.slots?.sidebar?.component}
{@const SvelteComponent = $page.data.slots.sidebar.component} {@const SvelteComponent = $page.data.slots.sidebar.component}
<SvelteComponent <SvelteComponent {...$page.data.slots.sidebar.props} />
{...$page.data.slots.sidebar.props}
/>
{:else if $site} {:else if $site}
<SiteCard <SiteCard
site={$site.site_view} site={$site.site_view}
+2 -2
View File
@@ -1,6 +1,6 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte'
import { aliases, loadTranslations } from '$lib/translations.js' import { aliases, loadTranslations } from '$lib/translations.js'
import { get } from 'svelte/store' import { get } from 'svelte/store'
@@ -9,7 +9,7 @@ export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
export const load = async ({}) => { export const load = async ({}) => {
if (browser) { if (browser) {
const initLocale = const initLocale =
get(userSettings)?.language ?? navigator?.language ?? 'en' settings.language ?? navigator?.language ?? 'en'
console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`) console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`)
+20 -20
View File
@@ -1,29 +1,35 @@
<script lang="ts" module>
</script>
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores' import { page } from '$app/stores'
import Pageination from '$lib/components/ui/Pageination.svelte' import Pageination from '$lib/components/ui/Pageination.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte' import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte' import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.svelte.js'
import { ChartBar, Icon } from 'svelte-hero-icons' import { ChartBar, Icon } from 'svelte-hero-icons'
import { site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'
import Location from '$lib/components/lemmy/dropdowns/Location.svelte' import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { browser } from '$app/environment' import { browser } from '$app/environment'
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte' import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte' import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
import type { ListingType } from 'lemmy-js-client'
import { get } from 'svelte/store'
let { data = $bindable() } = $props(); let { data = $bindable() } = $props()
const SvelteComponent = $derived($userSettings.infiniteScroll && let type = $state(data.type_)
browser && let sort = $state(data.sort)
!$userSettings.posts.noVirtualize
$effect(() => {
if (sort) settings.defaultSort.sort = sort
})
const FeedComponent = $derived(
settings.infiniteScroll && browser && !settings.posts.noVirtualize
? VirtualFeed ? VirtualFeed
: PostFeed); : PostFeed,
)
</script> </script>
<div class="flex flex-col gap-2 max-w-full w-full min-w-0"> <div class="flex flex-col gap-2 max-w-full w-full min-w-0">
@@ -33,23 +39,17 @@
{#snippet extended()} {#snippet extended()}
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
{#if data.type_} <Location bind:selected={type} />
<Location changeDefault selected={data.type_} /> <Sort bind:selected={sort} />
{/if}
<Sort changeDefault selected={data.sort} />
<ViewSelect /> <ViewSelect />
</div> </div>
{/snippet} {/snippet}
</Header> </Header>
</header> </header>
<SvelteComponent <FeedComponent posts={data.posts.posts} feedData={data} feedId="main" />
posts={data.posts.posts}
bind:feedData={data}
feedId="main"
/>
<svelte:element <svelte:element
this={$userSettings.infiniteScroll && !$userSettings.posts.noVirtualize this={settings.infiniteScroll && !settings.posts.noVirtualize
? 'noscript' ? 'noscript'
: 'div'} : 'div'}
class="mt-auto" class="mt-auto"
+1 -3
View File
@@ -1,5 +1,5 @@
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte'
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client' import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
import { get, writable } from 'svelte/store' import { get, writable } from 'svelte/store'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
@@ -13,8 +13,6 @@ export async function load({ url, fetch }) {
const cursor = url.searchParams.get('cursor') as string | undefined const cursor = url.searchParams.get('cursor') as string | undefined
const prevCursor = url.searchParams.get('prevCursor') as string | undefined const prevCursor = url.searchParams.get('prevCursor') as string | undefined
const settings = get(userSettings)
const sort: SortType = const sort: SortType =
(url.searchParams.get('sort') as SortType) || settings.defaultSort.sort (url.searchParams.get('sort') as SortType) || settings.defaultSort.sort
const listingType: ListingType = const listingType: ListingType =
+11 -15
View File
@@ -7,13 +7,13 @@
moveProfile, moveProfile,
type Profile, type Profile,
profile, profile,
} from '$lib/auth.js' } from '$lib/auth.svelte.js'
import EditableList from '$lib/components/ui/list/EditableList.svelte' import EditableList from '$lib/components/ui/list/EditableList.svelte'
import { Menu, MenuButton, Modal } from 'mono-svelte' import { Menu, MenuButton, Modal } from 'mono-svelte'
import DebugObject from '$lib/components/util/debug/DebugObject.svelte' import DebugObject from '$lib/components/util/debug/DebugObject.svelte'
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js' import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte' import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { Button, TextInput } from 'mono-svelte' import { Button, TextInput } from 'mono-svelte'
import { import {
ArrowLeftOnRectangle, ArrowLeftOnRectangle,
@@ -70,7 +70,7 @@
{#if removing.shown && removing.account} {#if removing.shown && removing.account}
<Modal bind:open={removing.shown}> <Modal bind:open={removing.shown}>
{#snippet title()} {#snippet customTitle()}
<span>Removing Account</span> <span>Removing Account</span>
{/snippet} {/snippet}
<div class="flex flex-row items-center gap-2"> <div class="flex flex-row items-center gap-2">
@@ -170,7 +170,6 @@
removing.account = acc.detail removing.account = acc.detail
removing.shown = !removing.shown removing.shown = !removing.shown
}} }}
> >
{#snippet children({ action })} {#snippet children({ action })}
{#each items as profile, index (profile.id)} {#each items as profile, index (profile.id)}
@@ -180,7 +179,9 @@
animate:flip={{ duration: 500, easing: expoOut }} animate:flip={{ duration: 500, easing: expoOut }}
> >
<Button <Button
title={profile.id == $currentProfile?.id ? 'Switch' : 'Current'} title={profile.id == $currentProfile?.id
? 'Switch'
: 'Current'}
on:click={async () => { on:click={async () => {
if (profile.id != $currentProfile?.id) { if (profile.id != $currentProfile?.id) {
switching = profile.id switching = profile.id
@@ -189,19 +190,19 @@
} }
}} }}
size="square-md" size="square-md"
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'} color={profile.id == $currentProfile?.id
? 'primary'
: 'ghost'}
loading={switching == profile.id} loading={switching == profile.id}
disabled={switching == profile.id} disabled={switching == profile.id}
rounding="pill" rounding="pill"
> >
{#snippet prefix()} {#snippet prefix()}
{#if profile.id == $currentProfile?.id} {#if profile.id == $currentProfile?.id}
<Icon src={Check} mini size="16" /> <Icon src={Check} mini size="16" />
{:else} {:else}
<Icon src={ArrowsRightLeft} size="16" mini /> <Icon src={ArrowsRightLeft} size="16" mini />
{/if} {/if}
{/snippet} {/snippet}
</Button> </Button>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
@@ -273,7 +274,7 @@
{/snippet} {/snippet}
{$t('account.resetColor')} {$t('account.resetColor')}
</MenuButton> </MenuButton>
{#if $userSettings.debugInfo} {#if settings.debugInfo}
<MenuButton <MenuButton
on:click={() => { on:click={() => {
debugProfile = profile debugProfile = profile
@@ -292,12 +293,7 @@
color="danger-subtle" color="danger-subtle"
> >
{#snippet prefix()} {#snippet prefix()}
<Icon <Icon src={ArrowRightOnRectangle} size="16" mini />
src={ArrowRightOnRectangle}
size="16"
mini
/>
{/snippet} {/snippet}
{$t('account.logout')} {$t('account.logout')}
</MenuButton> </MenuButton>
+2 -2
View File
@@ -1,5 +1,5 @@
<script> <script>
import { notifications } from '$lib/auth' import { notifications } from '$lib/auth.svelte'
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte' import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte' import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
@@ -10,7 +10,7 @@
*/ */
/** @type {Props} */ /** @type {Props} */
let { children } = $props(); let { children } = $props()
</script> </script>
{#if $notifications.applications > 0} {#if $notifications.applications > 0}
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { get } from 'svelte/store' import { get } from 'svelte/store'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { site as siteStore } from '$lib/lemmy' import { site as siteStore } from '$lib/lemmy'
+2 -2
View File
@@ -2,14 +2,14 @@
import { page } from '$app/stores' import { page } from '$app/stores'
import Pageination from '$lib/components/ui/Pageination.svelte' import Pageination from '$lib/components/ui/Pageination.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.svelte.js'
import { ClipboardDocumentCheck, Icon } from 'svelte-hero-icons' import { ClipboardDocumentCheck, Icon } from 'svelte-hero-icons'
import Application from './Application.svelte' import Application from './Application.svelte'
import MultiSelect from '$lib/components/input/Switch.svelte' import MultiSelect from '$lib/components/input/Switch.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data } = $props(); let { data } = $props()
</script> </script>
<Header pageHeader>{$t('routes.admin.applications.title')}</Header> <Header pageHeader>{$t('routes.admin.applications.title')}</Header>
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { get } from 'svelte/store' import { get } from 'svelte/store'
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { notifications, profile } from '$lib/auth.js' import { notifications, profile } from '$lib/auth.svelte.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte' import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { Material, toast } from 'mono-svelte' import { Material, toast } from 'mono-svelte'
@@ -16,10 +16,10 @@
import { t } from '$lib/translations' import { t } from '$lib/translations'
interface Props { interface Props {
application: RegistrationApplicationView; application: RegistrationApplicationView
} }
let { application = $bindable() }: Props = $props(); let { application = $bindable() }: Props = $props()
let approving = $state(false) let approving = $state(false)
let denying = $state(false) let denying = $state(false)
@@ -52,7 +52,7 @@
try { try {
await getClient().approveRegistrationApplication( await getClient().approveRegistrationApplication(
registrationApplicationAnswer registrationApplicationAnswer,
) )
toast({ toast({
content: approve content: approve
+8 -6
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { Label, Switch, toast } from 'mono-svelte' import { Label, Switch, toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
@@ -14,17 +14,19 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
interface Props { interface Props {
data: PageData; data: PageData
} }
let { data }: Props = $props(); let { data }: Props = $props()
const formData: Omit<EditSite, 'auth'> | undefined = $state(data.site const formData: Omit<EditSite, 'auth'> | undefined = $state(
data.site
? { ? {
...data.site.site_view.local_site, ...data.site.site_view.local_site,
...data.site.site_view.site, ...data.site.site_view.site,
} }
: undefined) : undefined,
)
async function save() { async function save() {
if (!$profile?.jwt) return if (!$profile?.jwt) return
+18 -19
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { run, preventDefault } from 'svelte/legacy'; import { run, preventDefault } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte' import EditableList from '$lib/components/ui/list/EditableList.svelte'
@@ -9,7 +9,7 @@
import { publishedToDate } from '$lib/components/util/date.js' import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
import { trycatch } from '$lib/util.js' import { trycatch } from '$lib/util.svelte.js'
import type { Instance } from 'lemmy-js-client' import type { Instance } from 'lemmy-js-client'
import { import {
Button, Button,
@@ -31,7 +31,7 @@
import { expoInOut, expoOut } from 'svelte/easing' import { expoInOut, expoOut } from 'svelte/easing'
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
let { data = $bindable() } = $props(); let { data = $bindable() } = $props()
let blockInstance = $state({ let blockInstance = $state({
instance: '', instance: '',
@@ -58,12 +58,12 @@
const blockedInstances = const blockedInstances =
data.federated_instances.federated_instances.blocked.map( data.federated_instances.federated_instances.blocked.map(
(i) => i.domain (i) => i.domain,
) )
const allowedInstances = const allowedInstances =
data.federated_instances.federated_instances.allowed.map( data.federated_instances.federated_instances.allowed.map(
(i) => i.domain (i) => i.domain,
) )
if (blocked) blockedInstances.push(instance) if (blocked) blockedInstances.push(instance)
@@ -97,11 +97,11 @@
const blockedInstances = const blockedInstances =
data.federated_instances.federated_instances.blocked.map( data.federated_instances.federated_instances.blocked.map(
(i) => i.domain (i) => i.domain,
) )
const allowedInstances = const allowedInstances =
data.federated_instances.federated_instances.allowed.map( data.federated_instances.federated_instances.allowed.map(
(i) => i.domain (i) => i.domain,
) )
return await getClient().editSite({ return await getClient().editSite({
@@ -166,7 +166,7 @@
run(() => { run(() => {
if (csv) parseCsv(csv) if (csv) parseCsv(csv)
}); })
</script> </script>
<svelte:head> <svelte:head>
@@ -190,9 +190,7 @@
</Button> </Button>
{/snippet} {/snippet}
{#snippet choose()} {#snippet choose()}
{''} {''}
{/snippet} {/snippet}
</FileInput> </FileInput>
<div class="flex flex-col md:flex-row gap-4"> <div class="flex flex-col md:flex-row gap-4">
@@ -200,7 +198,8 @@
<h2 class="font-bold text-lg">{$t('routes.admin.federation.blocked')}</h2> <h2 class="font-bold text-lg">{$t('routes.admin.federation.blocked')}</h2>
<form <form
onsubmit={preventDefault(() => onsubmit={preventDefault(() =>
moderateInstance(blockInstance.instance, true))} moderateInstance(blockInstance.instance, true),
)}
class="flex flex-row gap-2" class="flex flex-row gap-2"
> >
<TextInput <TextInput
@@ -223,7 +222,7 @@
: ''}" : ''}"
> >
{#if data.federated_instances.federated_instances.blocked.length > 0} {#if data.federated_instances.federated_instances.blocked.length > 0}
{#each data.federated_instances.federated_instances.blocked.sort( (b, a) => b.domain.localeCompare(a.domain) ) as instance (instance.id)} {#each data.federated_instances.federated_instances.blocked.sort( (b, a) => b.domain.localeCompare(a.domain), ) as instance (instance.id)}
<div <div
animate:flip={{ duration: 300, easing: expoOut }} animate:flip={{ duration: 300, easing: expoOut }}
class="flex justify-between items-center first:pt-0 last:pb-0" class="flex justify-between items-center first:pt-0 last:pb-0"
@@ -246,7 +245,7 @@
data.federated_instances.federated_instances.blocked = data.federated_instances.federated_instances.blocked =
data.federated_instances?.federated_instances?.blocked.filter( data.federated_instances?.federated_instances?.blocked.filter(
(i) => i.id != instance.id (i) => i.id != instance.id,
) )
}} }}
> >
@@ -276,7 +275,6 @@
src={ExclamationTriangle} src={ExclamationTriangle}
solid solid
class="text-yellow-500" class="text-yellow-500"
size="20" size="20"
/> />
{/snippet} {/snippet}
@@ -288,7 +286,8 @@
</h2> </h2>
<form <form
onsubmit={preventDefault(() => onsubmit={preventDefault(() =>
moderateInstance(allowInstance.instance, false))} moderateInstance(allowInstance.instance, false),
)}
class="flex flex-row gap-2" class="flex flex-row gap-2"
> >
<TextInput <TextInput
@@ -307,7 +306,7 @@
<Material class="h-full overflow-auto" color="distinct"> <Material class="h-full overflow-auto" color="distinct">
<EditableList class="[&>*]:py-3 dark:!divide-zinc-800 "> <EditableList class="[&>*]:py-3 dark:!divide-zinc-800 ">
{#if data.federated_instances.federated_instances.allowed.length > 0} {#if data.federated_instances.federated_instances.allowed.length > 0}
{#each data.federated_instances.federated_instances.allowed.sort( (b, a) => b.domain.localeCompare(a.domain) ) as instance (instance.id)} {#each data.federated_instances.federated_instances.allowed.sort( (b, a) => b.domain.localeCompare(a.domain), ) as instance (instance.id)}
<div <div
animate:flip={{ duration: 300, easing: expoOut }} animate:flip={{ duration: 300, easing: expoOut }}
class="flex justify-between items-center first:pt-0 last:pb-0" class="flex justify-between items-center first:pt-0 last:pb-0"
@@ -330,7 +329,7 @@
data.federated_instances.federated_instances.allowed = data.federated_instances.federated_instances.allowed =
data.federated_instances?.federated_instances?.allowed.filter( data.federated_instances?.federated_instances?.allowed.filter(
(i) => i.id != instance.id (i) => i.id != instance.id,
) )
}} }}
> >
@@ -346,7 +345,7 @@
icon={Check} icon={Check}
title={$t('routes.admin.federation.emptyAllow.title')} title={$t('routes.admin.federation.emptyAllow.title')}
description={$t( description={$t(
'routes.admin.federation.emptyAllow.description' 'routes.admin.federation.emptyAllow.description',
)} )}
/> />
</div> </div>
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { get } from 'svelte/store' import { get } from 'svelte/store'
+7 -6
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
@@ -14,9 +14,11 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
let { data } = $props(); let { data } = $props()
let taglines = $state([...(data.site?.taglines.map((t: Tagline) => t.content) ?? [])]) let taglines = $state([
...(data.site?.taglines.map((t: Tagline) => t.content) ?? []),
])
let newTagline = $state('') let newTagline = $state('')
let saving = $state(false) let saving = $state(false)
@@ -60,11 +62,10 @@
</Header> </Header>
<EditableList <EditableList
on:action={(e) => { on:action={(e) => {
taglines.splice( taglines.splice(
taglines.findIndex((i) => i == e.detail), taglines.findIndex((i) => i == e.detail),
1 1,
) )
// hack for reactivity // hack for reactivity
+5 -5
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte' import EditableList from '$lib/components/ui/list/EditableList.svelte'
@@ -9,13 +9,13 @@
import { instance } from '$lib/instance.js' import { instance } from '$lib/instance.js'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { addAdmin } from '$lib/lemmy/user.js' import { addAdmin } from '$lib/lemmy/user.js'
import { removeItem, trycatch } from '$lib/util.js' import { removeItem, trycatch } from '$lib/util.svelte.js'
import { Button, TextInput } from 'mono-svelte' import { Button, TextInput } from 'mono-svelte'
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons' import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
let { data = $bindable() } = $props(); let { data = $bindable() } = $props()
let newAdmin: string = $state(''), let newAdmin: string = $state(''),
adding: boolean = $state(false) adding: boolean = $state(false)
@@ -33,7 +33,7 @@
getClient().addAdmin({ getClient().addAdmin({
added: false, added: false,
person_id: id, person_id: id,
}) }),
) )
if (result) { if (result) {
+15 -20
View File
@@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'; import { run } from 'svelte/legacy'
import { navigating, page } from '$app/stores' import { navigating, page } from '$app/stores'
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte' import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte' import Pageination from '$lib/components/ui/Pageination.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte' import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import { fullCommunityName, searchParam } from '$lib/util.js' import { fullCommunityName, searchParam } from '$lib/util.svelte.js'
import { onDestroy, onMount } from 'svelte' import { onDestroy, onMount } from 'svelte'
import { setSessionStorage } from '$lib/session.js' import { setSessionStorage } from '$lib/session.js'
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte' import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
@@ -27,18 +27,13 @@
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte.js'
import { site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'
import { resumables } from '$lib/lemmy/item' import { resumables } from '$lib/lemmy/item'
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte' import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data = $bindable() } = $props(); let { data = $bindable() } = $props()
let community;
run(() => {
community = data.community.community_view
});
let sidebar: boolean = $state(false) let sidebar: boolean = $state(false)
@@ -46,14 +41,14 @@
if (browser) if (browser)
setSessionStorage( setSessionStorage(
'lastSeenCommunity', 'lastSeenCommunity',
data.community.community_view.community data.community.community_view.community,
) )
resumables.add({ resumables.add({
name: community.community.title, name: data.community.community_view.community.title,
type: 'community', type: 'community',
url: $page.url.toString(), url: $page.url.toString(),
avatar: community.community.icon, avatar: data.community.community_view.community.icon,
}) })
}) })
@@ -68,12 +63,12 @@
{#if sidebar} {#if sidebar}
<Modal bind:open={sidebar}> <Modal bind:open={sidebar}>
{#snippet title()} {#snippet customTitle()}
<span>About</span> <span>About</span>
{/snippet} {/snippet}
<div> <div>
<CommunityCard <CommunityCard
bind:community_view={community} bind:community_view={data.community.community_view}
moderators={data.community.moderators} moderators={data.community.moderators}
/> />
</div> </div>
@@ -83,18 +78,18 @@
<div class="flex flex-col gap-4 max-w-full w-full min-w-0"> <div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<Header pageHeader> <Header pageHeader>
<CommunityHeader <CommunityHeader
bind:community={community.community} bind:community={data.community.community_view.community}
bind:subscribed={community.subscribed} bind:subscribed={data.community.community_view.subscribed}
bind:blocked={community.blocked} blocked={data.community.community_view.blocked}
moderators={data.community.moderators} moderators={data.community.moderators}
counts={community.counts} counts={data.community.community_view.counts}
class="w-full relative" class="w-full relative"
/> />
{#snippet extended()} {#snippet extended()}
<Sort selected={data.sort} /> <Sort selected={data.sort} />
{/snippet} {/snippet}
</Header> </Header>
{#if community.blocked} {#if data.community.community_view.blocked}
<Placeholder <Placeholder
icon={XMark} icon={XMark}
title="Blocked" title="Blocked"
@@ -118,7 +113,7 @@
{/if} {/if}
<svelte:element <svelte:element
this={$userSettings.infiniteScroll ? 'noscript' : 'div'} this={settings.infiniteScroll ? 'noscript' : 'div'}
class="mt-auto" class="mt-auto"
> >
<Pageination <Pageination
+2 -2
View File
@@ -1,5 +1,5 @@
import { postFeed } from '$lib/lemmy/postfeed.js' import { postFeed } from '$lib/lemmy/postfeed.js'
import { userSettings } from '$lib/settings.js' import { settings } from '$lib/settings.svelte'
import type { SortType } from 'lemmy-js-client' import type { SortType } from 'lemmy-js-client'
import { get } from 'svelte/store' import { get } from 'svelte/store'
@@ -11,7 +11,7 @@ export async function load({ params, fetch, url }) {
const sort: SortType = const sort: SortType =
(url.searchParams.get('sort') as SortType) || (url.searchParams.get('sort') as SortType) ||
get(userSettings).defaultSort.sort settings.defaultSort.sort
return await postFeed({ return await postFeed({
id: 'community', id: 'community',
+9 -7
View File
@@ -5,20 +5,22 @@
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte' import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte' import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
import { fullCommunityName } from '$lib/util.js' import { fullCommunityName } from '$lib/util.svelte.js'
import type { PageData } from './$types.js' import type { PageData } from './$types.js'
interface Props { interface Props {
data: PageData; data: PageData
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { data, children }: Props = $props(); let { data, children }: Props = $props()
let communityUrl = $derived(`/c/${fullCommunityName( let communityUrl = $derived(
`/c/${fullCommunityName(
data.community.community_view.community.name, data.community.community_view.community.name,
data.community.community_view.community.actor_id data.community.community_view.community.actor_id,
)}`) )}`,
)
</script> </script>
<div class="flex flex-col gap-4 h-full"> <div class="flex flex-col gap-4 h-full">
@@ -1,12 +1,12 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte' import EditableList from '$lib/components/ui/list/EditableList.svelte'
import { Icon, Plus, Trash } from 'svelte-hero-icons' import { Icon, Plus, Trash } from 'svelte-hero-icons'
import type { PageData } from './$types.js' import type { PageData } from './$types.js'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.js' import { client, getClient } from '$lib/lemmy.js'
import { flip } from 'svelte/animate' import { flip } from 'svelte/animate'
@@ -15,10 +15,10 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
interface Props { interface Props {
data: PageData; data: PageData
} }
let { data = $bindable() }: Props = $props(); let { data = $bindable() }: Props = $props()
let formData = $state({ let formData = $state({
newModerator: '', newModerator: '',
@@ -109,7 +109,6 @@
<Header pageHeader>Moderators</Header> <Header pageHeader>Moderators</Header>
<EditableList <EditableList
on:action={(e) => { on:action={(e) => {
toast({ toast({
content: `Are you sure you want to remove ${e.detail.name} as a moderator?`, content: `Are you sure you want to remove ${e.detail.name} as a moderator?`,
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { client } from '$lib/lemmy.js' import { client } from '$lib/lemmy.js'
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
import { get } from 'svelte/store' import { get } from 'svelte/store'
+10 -12
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { navigating, page } from '$app/stores' import { navigating, page } from '$app/stores'
import { import {
@@ -10,7 +10,7 @@
QuestionMarkCircle, QuestionMarkCircle,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import Pageination from '$lib/components/ui/Pageination.svelte' import Pageination from '$lib/components/ui/Pageination.svelte'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.svelte.js'
import { import {
Button, Button,
Material, Material,
@@ -31,21 +31,18 @@
import { fly } from 'svelte/transition' import { fly } from 'svelte/transition'
import { backOut, expoOut } from 'svelte/easing' import { backOut, expoOut } from 'svelte/easing'
let { data } = $props(); let { data } = $props()
let search = $state(data.query || '') let search = $state(data.query || '')
let searchElement: HTMLInputElement = $state() let searchElement: HTMLInputElement | undefined = $state()
let instance = '' let instance = ''
let virtualList: HTMLDivElement = $state() let showTop = $derived(
let offset: number = $state(0) (data.query ?? '' != '') && data.communities.length > 0 && data.page == 1,
)
let showTop =
$derived((data.query ?? '' != '') && data.communities.length > 0 && data.page == 1)
</script> </script>
<svelte:window <svelte:window
bind:scrollY={offset}
onkeydown={(e) => { onkeydown={(e) => {
if (e.target == document.body) searchElement?.focus() if (e.target == document.body) searchElement?.focus()
}} }}
@@ -65,7 +62,8 @@
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70 shadow-md shadow-black/5"> <Tabs routes={[]} class="p-2 dark:bg-zinc-925/70 shadow-md shadow-black/5">
<form <form
onsubmit={preventDefault(() => onsubmit={preventDefault(() =>
searchParam($page.url, 'q', search, 'page'))} searchParam($page.url, 'q', search, 'page'),
)}
class="flex gap-2 flex-row items-center w-full text-base h-10" class="flex gap-2 flex-row items-center w-full text-base h-10"
> >
<TextInput <TextInput
@@ -149,7 +147,7 @@
{/if} {/if}
{#if data.communities} {#if data.communities}
{@const sliced = data.communities.slice(showTop ? 3 : 0)} {@const sliced = data.communities.slice(showTop ? 3 : 0)}
<div class="-mx-4 sm:-mx-6 h-full" bind:this={virtualList}> <div class="-mx-4 sm:-mx-6 h-full">
{#each sliced as community, index (community.community.id)} {#each sliced as community, index (community.community.id)}
<div <div
class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance.js' import { LINKED_INSTANCE_URL } from '$lib/instance.js'
import { client, getClient } from '$lib/lemmy.js' import { client, getClient } from '$lib/lemmy.js'
import { import {
+5 -5
View File
@@ -1,15 +1,15 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import type { CommunityView, SubscribedType } from 'lemmy-js-client' import type { CommunityView, SubscribedType } from 'lemmy-js-client'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
interface Props { interface Props {
community?: CommunityView | undefined; community?: CommunityView | undefined
children?: import('svelte').Snippet<[any]>; children?: import('svelte').Snippet<[any]>
} }
let { community = undefined, children }: Props = $props(); let { community = undefined, children }: Props = $props()
let subscribing = $state(false) let subscribing = $state(false)
@@ -38,4 +38,4 @@
} }
</script> </script>
{@render children?.({ subscribe, subscribing, })} {@render children?.({ subscribe, subscribing })}
+5 -3
View File
@@ -1,15 +1,17 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import PostForm from '$lib/components/lemmy/post/form/PostForm.svelte' import PostForm from '$lib/components/lemmy/post/form/PostForm.svelte'
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte.js'
import { onDestroy, onMount } from 'svelte' import { onDestroy, onMount } from 'svelte'
import { getSessionStorage, setSessionStorage } from '$lib/session.js' import { getSessionStorage, setSessionStorage } from '$lib/session.js'
import { t } from '$lib/translations.js' import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data = { let {
data = {
crosspost: false, crosspost: false,
} } = $props(); },
} = $props()
onMount(() => { onMount(() => {
if (!$profile?.jwt) { if (!$profile?.jwt) {
+2 -2
View File
@@ -13,10 +13,10 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/stores' import { page } from '$app/stores'
import Pageination from '$lib/components/ui/Pageination.svelte' import Pageination from '$lib/components/ui/Pageination.svelte'
import { notifications, profile } from '$lib/auth.js' import { notifications, profile } from '$lib/auth.svelte.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { fly } from 'svelte/transition' import { fly } from 'svelte/transition'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.svelte.js'
import { Button, Select } from 'mono-svelte' import { Button, Select } from 'mono-svelte'
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte' import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { publishedToDate } from '$lib/components/util/date.js' import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { import {
+8 -6
View File
@@ -2,7 +2,7 @@
import Comment from '$lib/components/lemmy/comment/Comment.svelte' import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { notifications, profile } from '$lib/auth.js' import { notifications, profile } from '$lib/auth.svelte.js'
import { import {
ArrowUturnLeft, ArrowUturnLeft,
ArrowUturnUp, ArrowUturnUp,
@@ -29,10 +29,10 @@
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
interface Props { interface Props {
item: InboxItem; item: InboxItem
} }
let { item = $bindable() }: Props = $props(); let { item = $bindable() }: Props = $props()
let replying = $state(false) let replying = $state(false)
let reply = '' let reply = ''
@@ -181,14 +181,17 @@
: $t('post.actions.more.markRead')} : $t('post.actions.more.markRead')}
</Button> </Button>
{#if item.type == 'comment_reply' || item.type == 'person_mention'} {#if item.type == 'comment_reply' || item.type == 'person_mention'}
<Button href="/comment/{item.item.comment.id}" size="sm" rounding="pill"> <Button
href="/comment/{item.item.comment.id}"
size="sm"
rounding="pill"
>
{$t('common.jump')} {$t('common.jump')}
</Button> </Button>
{/if} {/if}
</div> </div>
{/snippet} {/snippet}
{#snippet content()} {#snippet content()}
{#if item.type == 'comment_reply' || item.type == 'person_mention'} {#if item.type == 'comment_reply' || item.type == 'person_mention'}
<CommentItem <CommentItem
comment={item.item} comment={item.item}
@@ -200,7 +203,6 @@
{:else} {:else}
<PrivateMessage message={item.item} meta={false} /> <PrivateMessage message={item.item} meta={false} />
{/if} {/if}
{/snippet} {/snippet}
</Expandable> </Expandable>
+5 -5
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/auth' import { profile } from '$lib/auth.svelte.js'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { publishedToDate } from '$lib/components/util/date.js' import { publishedToDate } from '$lib/components/util/date.js'
@@ -35,11 +35,11 @@
} }
function conversationPreviews( function conversationPreviews(
conversations: PrivateMessageView[] conversations: PrivateMessageView[],
): ConversationPreview[] { ): ConversationPreview[] {
const deduplicated = filterDuplicates( const deduplicated = filterDuplicates(
conversations.toReversed(), conversations.toReversed(),
(i) => i.creator.id (i) => i.creator.id,
) )
return deduplicated.map((i) => ({ return deduplicated.map((i) => ({
@@ -51,7 +51,7 @@
})) }))
} }
let { data } = $props(); let { data } = $props()
</script> </script>
<Header pageHeader> <Header pageHeader>
@@ -64,7 +64,7 @@
{:then data} {:then data}
{@const conversations = data.private_messages} {@const conversations = data.private_messages}
{@const previews = conversationPreviews(conversations).filter( {@const previews = conversationPreviews(conversations).filter(
(c) => c.user.id != $profile?.user?.local_user_view.person.id (c) => c.user.id != $profile?.user?.local_user_view.person.id,
)} )}
<ul <ul
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { get } from 'svelte/store' import { get } from 'svelte/store'
+7 -7
View File
@@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { setUser } from '$lib/auth.js' import { setUser } from '$lib/auth.svelte.js'
import { Note, toast } from 'mono-svelte' import { Note, toast } from 'mono-svelte'
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js' import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
import { import {
@@ -18,7 +18,7 @@
QuestionMarkCircle, QuestionMarkCircle,
UserCircle, UserCircle,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { DOMAIN_REGEX_FORMS } from '$lib/util.js' import { DOMAIN_REGEX_FORMS } from '$lib/util.svelte.js'
import { MINIMUM_VERSION } from '$lib/version.js' import { MINIMUM_VERSION } from '$lib/version.js'
import { t } from '$lib/translations' import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
@@ -30,11 +30,11 @@
import { page } from '$app/stores' import { page } from '$app/stores'
interface Props { interface Props {
ref?: string; ref?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { ref = '/', children }: Props = $props(); let { ref = '/', children }: Props = $props()
let data = $state({ let data = $state({
instance: DEFAULT_INSTANCE_URL, instance: DEFAULT_INSTANCE_URL,
@@ -80,7 +80,7 @@
'incorrect_login' + 'incorrect_login' +
(data.attempts == 0 || data.attempts >= 12 (data.attempts == 0 || data.attempts >= 12
? '' ? ''
: `_${data.attempts + 1}`) : `_${data.attempts + 1}`),
) )
: errorMessage(error), : errorMessage(error),
scope: $page.route.id!, scope: $page.route.id!,
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff. Show more