migrate: change settings from a store to a state

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

No files matched your search

+4 -4
View File
@@ -19,7 +19,7 @@
import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations'
import Entity from '../ui/Entity.svelte'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
import { optimizeImageURL } from './post/helpers'
interface Props {
@@ -100,7 +100,7 @@
{/if}
<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()}
<span class="flex items-center gap-1 py-1 px-2">
<Icon src={InformationCircle} size="16" mini />
@@ -113,7 +113,7 @@
</Expandable>
<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()}
<span class="flex items-center gap-1 py-1 px-2">
<Icon src={ChartBar} size="16" mini />
@@ -141,7 +141,7 @@
{#if admins}
<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()}
<span class="flex items-center gap-1 py-1 px-2">
<Icon src={UserGroup} size="16" mini />
@@ -13,7 +13,7 @@
PlusCircle,
MinusCircle,
} from 'svelte-hero-icons'
import type { CommentNodeI } from './comments'
import type { CommentNodeI } from './comments.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import CommentForm from './CommentForm.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
@@ -21,7 +21,7 @@
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
import { getClient } from '$lib/lemmy.js'
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 { publishedToDate } from '$lib/components/util/date.js'
import ShieldIcon from '../moderation/ShieldIcon.svelte'
@@ -110,7 +110,7 @@
<form onsubmit={preventDefault(save)} class="contents">
<CommentForm
postId={node.comment_view.comment.id}
bind:value={newComment}
value={newComment}
actions={false}
preview={true}
on:confirm={save}
@@ -235,7 +235,7 @@
</div>
{#if actions}
<CommentActions
bind:comment={node.comment_view}
comment={node.comment_view}
bind:replying
on:edit={() => (editing = true)}
disabled={node.comment_view.banned_from_community ||
@@ -259,7 +259,6 @@
children: [],
comment_view: e.detail.comment_view,
depth: node.depth + 1,
ui: {},
},
...node.children,
]
@@ -22,13 +22,13 @@
report,
} from '$lib/components/lemmy/moderation/moderation.js'
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 { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
import { t } from '$lib/translations'
import Translation from '$lib/components/translate/Translation.svelte'
import { text } from '$lib/components/translate/translation'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
interface Props {
comment: CommentView
@@ -54,12 +54,12 @@
<div
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
bind:upvotes={comment.counts.upvotes}
bind:downvotes={comment.counts.downvotes}
bind:vote={comment.my_vote}
upvotes={comment.counts.upvotes}
downvotes={comment.counts.downvotes}
vote={comment.my_vote}
commentId={comment.comment.id}
/>
<Button
@@ -101,7 +101,7 @@
<Icon src={Square2Stack} mini size="16" />
<div>{$t('comment.actions.link')}</div>
</MenuButton>
{#if $userSettings.translator}
{#if settings.translator}
<MenuButton
on:click={() => {
// @ts-ignore
@@ -3,10 +3,10 @@
import { getClient } from '$lib/lemmy.js'
import { createEventDispatcher } from '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 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 { t } from '$lib/translations'
import { errorMessage } from '$lib/lemmy/error'
@@ -3,7 +3,7 @@
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { publishedToDate } from '$lib/components/util/date.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 type { CommentView } from 'lemmy-js-client'
import { Button, Material } from 'mono-svelte'
@@ -20,7 +20,7 @@
let {
comment,
view = $userSettings.view,
view = settings.view,
community = false,
meta = true,
class: clazz = '',
@@ -2,7 +2,7 @@
import { run } from 'svelte/legacy'
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 Comments from './Comments.svelte'
import { browser } from '$app/environment'
@@ -24,7 +24,7 @@
estimateSize: () => 30,
scrollMargin: virtualListEl?.offsetTop,
initialRect: {
height: 1500,
height: browser ? 1 : 1500,
width: 99999,
},
overscan: 5,
@@ -35,9 +35,11 @@
let items = $derived($virtualizer.getVirtualItems())
run(() => {
if (virtualItemEls.length)
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
const updateItems = () =>
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
$effect(() => {
if (virtualItemEls) updateItems()
})
onMount(() => {
@@ -8,8 +8,8 @@
Icon,
} from 'svelte-hero-icons'
import { getClient, site } from '$lib/lemmy'
import { userSettings } from '$lib/settings'
import { profile } from '$lib/auth.js'
import { settings } from '$lib/settings.svelte'
import { profile } from '$lib/auth.svelte.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { Button, buttonColor, toast } from 'mono-svelte'
import { vote as voteItem } from '$lib/lemmy/contentview'
@@ -1,22 +1,15 @@
<script lang="ts">
import Comments from './Comments.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 { onMount, setContext } from 'svelte'
import {
ChevronDoubleDown,
ChevronDown,
Icon,
Plus,
PlusCircle,
ArrowDownCircle,
} from 'svelte-hero-icons'
import { Icon, ArrowDownCircle } from 'svelte-hero-icons'
import { getClient } from '$lib/lemmy.js'
import type { CommentView, Post } from 'lemmy-js-client'
import { fly } from 'svelte/transition'
import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.js'
import { profile } from '$lib/auth.svelte.js'
import { Button } from 'mono-svelte'
import { afterNavigate, goto } from '$app/navigation'
import { backOut, expoOut } from 'svelte/easing'
@@ -121,8 +114,7 @@
{#each nodes as node, index (node.comment_view.comment.id)}
<Comment
postId={post.id}
bind:node={nodes[index]}
bind:open={node.ui.open}
node={nodes[index]}
op={post.creator_id == node.comment_view.creator.id}
contentClass="pl-3 {node.children.length > 0 ||
node.comment_view.counts.child_count > 0
@@ -130,7 +122,7 @@
: ''} ml-3 border-slate-200 dark:border-zinc-800"
>
{#if node.children?.length > 0}
<Comments {post} bind:nodes={nodes[index].children} isParent={false} />
<Comments {post} nodes={nodes[index].children} isParent={false} />
{/if}
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
<svelte:element
@@ -5,9 +5,6 @@ export interface CommentNodeI {
children: Array<CommentNodeI>
depth: number
loading?: boolean
ui: {
open?: boolean
}
}
function getCommentParentId(comment?: Comment): number | undefined {
@@ -40,10 +37,7 @@ export function buildCommentsTree(
const node: CommentNodeI = {
comment_view,
children: [],
depth: depth,
ui: {
open: true,
},
depth: depth
}
min_depth = Math.min(min_depth, depth)
if (filter(comment_view)) {
@@ -109,7 +103,6 @@ export function insertCommentIntoTree(
comment_view: cv,
children: [],
depth: 0,
ui: {},
}
const parentId = getCommentParentId(cv.comment)
@@ -66,7 +66,7 @@
</script>
<script lang="ts">
import { profile } from '$lib/auth.js'
import { profile } from '$lib/auth.svelte.js'
import {
amMod,
isAdmin,
@@ -85,7 +85,7 @@
} from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.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 { Button } from 'mono-svelte'
import {
@@ -109,7 +109,7 @@
import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations'
import Entity from '$lib/components/ui/Entity.svelte'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
let loading = $state({
blocking: false,
@@ -170,7 +170,7 @@
<div class="flex flex-col gap-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()}
<span class="py-1 px-1 flex gap-1 items-center">
<Icon src={InformationCircle} size="15" mini />
@@ -181,7 +181,7 @@
</Expandable>
<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()}
<span class="py-1 px-1 flex gap-1 items-center">
<Icon src={ChartBar} size="15" mini />
@@ -204,7 +204,7 @@
{#if moderators && moderators.length > 0}
<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()}
<span class="py-1 px-1 flex gap-1 items-center">
<ShieldIcon width={15} filled />
@@ -2,13 +2,13 @@
import { preventDefault } from 'svelte/legacy'
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 { ImageInput, Switch, toast } from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.js'
import { addSubscription } from '$lib/lemmy/user.js'
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 Header from '$lib/components/ui/layout/pages/Header.svelte'
import ImagePreviewInput from '$lib/components/input/ImagePreviewInput.svelte'
@@ -1,8 +1,8 @@
<script lang="ts">
import { profile } from '$lib/auth'
import { profile } from '$lib/auth.svelte'
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
import { t } from '$lib/translations'
import { fullCommunityName } from '$lib/util'
import { fullCommunityName } from '$lib/util.svelte'
import type {
Community,
CommunityAggregates,
@@ -13,8 +13,8 @@
} from 'svelte-hero-icons'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { Button, Modal } from 'mono-svelte'
import { fullCommunityName, isSubscribed } from '$lib/util.js'
import { profile } from '$lib/auth.js'
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
import { profile } from '$lib/auth.svelte.js'
import { addSubscription } from '$lib/lemmy/user.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
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 type { Community } from 'lemmy-js-client'
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
@@ -23,7 +23,7 @@
avatar = false,
name = true,
avatarSize = 24,
showInstance = $userSettings.showInstances.community,
showInstance = settings.showInstances.community,
displayName = true,
badges = {
nsfw: false,
@@ -1,10 +1,7 @@
<script lang="ts">
import { run } from 'svelte/legacy'
import { page } from '$app/stores'
import { profile } from '$lib/auth'
import { userSettings } from '$lib/settings'
import { searchParam } from '$lib/util'
import { profile } from '$lib/auth.svelte'
import { searchParam } from '$lib/util.svelte'
import { Select } from 'mono-svelte'
import {
GlobeAmericas,
@@ -25,32 +22,19 @@
}
let {
selected,
selected = $bindable(),
navigate = true,
changeDefault = false,
showLabel = true,
...rest
}: Props = $props()
let feed: string = $state(selected)
run(() => {
feed = selected
})
run(() => {
changeDefault
? ($userSettings.defaultSort.feed = selected as
| 'All'
| 'Subscribed'
| 'Local')
: undefined
})
</script>
<Select
{...rest}
bind:value={feed}
bind:value={selected}
on:change={() => {
if (navigate) searchParam($page.url, 'type', feed, 'page', 'cursor')
if (navigate) searchParam($page.url, 'type', selected, 'page', 'cursor')
}}
>
{#snippet customLabel()}
+4 -15
View File
@@ -2,9 +2,9 @@
import { run } from 'svelte/legacy'
import { page } from '$app/stores'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
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 { Select } from 'mono-svelte'
import {
@@ -45,17 +45,6 @@
let sort: string = $state(selected?.startsWith('Top') ? 'TopAll' : selected)
const setSelected = () => (selected = sort)
run(() => {
if (selected) {
sort = selected?.startsWith('Top') ? 'TopAll' : selected
}
})
run(() => {
changeDefault
? ($userSettings.defaultSort.sort = selected as SortType)
: undefined
})
</script>
<div class="flex flex-row {clazz}">
@@ -68,7 +57,7 @@
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
}}
>
{#snippet label()}
{#snippet customLabel()}
<span class="flex items-center gap-1">
<Icon src={ChartBar} size="13" micro />
{$t('filter.sort.label')}
@@ -167,7 +156,7 @@
searchParam($page.url, 'sort', selected, 'page', 'cursor')
}}
>
{#snippet label()}
{#snippet customLabel()}
<span class="flex items-center gap-1">
<Icon src={Clock} size="15" micro />
{$t('filter.sort.top.time.label')}
@@ -1,5 +1,5 @@
<script lang="ts">
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
import { t } from '$lib/translations'
import { Select } from 'mono-svelte'
import {
@@ -21,7 +21,7 @@
let { showLabel = true, ...rest }: Props = $props()
</script>
<Select {...rest} bind:value={$userSettings.view}>
<Select {...rest} bind:value={settings.view}>
{#snippet customLabel()}
{#if showLabel}
<span class="flex items-center gap-1">
@@ -1,5 +1,5 @@
<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 Markdown from '$lib/components/markdown/Markdown.svelte'
import type { PrivateMessageView } from 'lemmy-js-client'
@@ -1,11 +1,11 @@
<script lang="ts">
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 { errorMessage } from '$lib/lemmy/error'
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 { Button, Modal } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
@@ -73,7 +73,7 @@
</script>
<Modal bind:open>
{#snippet title()}
{#snippet customTitle()}
<div class="flex items-center gap-2">Upload image</div>
{/snippet}
{#if progress != 1}
@@ -1,7 +1,7 @@
<script lang="ts">
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 MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { getClient } from '$lib/lemmy.js'
@@ -5,7 +5,7 @@
import type { Community, Person, PersonView } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js'
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 MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { t } from '$lib/translations'
@@ -9,7 +9,7 @@
Trash,
} from 'svelte-hero-icons'
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 { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
import { t } from '$lib/translations'
@@ -13,7 +13,7 @@
} from 'svelte-hero-icons'
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
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 { t } from '$lib/translations'
import ShieldIcon from './ShieldIcon.svelte'
@@ -7,13 +7,13 @@
import { getClient } from '$lib/lemmy.js'
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
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 { Fire, Icon, Trash } from 'svelte-hero-icons'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { removalTemplate } from '$lib/components/lemmy/moderation/moderation.js'
import { userSettings } from '$lib/settings.js'
import { fullCommunityName } from '$lib/util.js'
import { settings } from '$lib/settings.svelte.js'
import { fullCommunityName } from '$lib/util.svelte.js'
import { amMod, isAdmin } from './moderation'
import { Button, Checkbox, Modal } from 'mono-svelte'
import { t } from '$lib/translations'
@@ -34,7 +34,7 @@
let commentReason: boolean = $state(false)
let privateMessage: boolean = $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(
item
@@ -231,7 +231,7 @@
<div class="flex justify-between items-end mb-1">
{$t('comment.reply')}
<Select bind:value={preset} placeholder="No preset">
{#each $userSettings.moderation.presets as preset}
{#each settings.moderation.presets as preset}
<option value={preset.content}>
{preset.title}
</option>
@@ -10,7 +10,7 @@
PostView,
PrivateMessageView,
} from 'lemmy-js-client'
import { profile } from '$lib/auth.js'
import { profile } from '$lib/auth.svelte.js'
import { Button, Modal } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { onMount } from 'svelte'
+9 -10
View File
@@ -3,7 +3,7 @@
import { isImage, isVideo } from '$lib/ui/image.js'
import { getInstance } from '$lib/lemmy.js'
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 PostMeta, {
parseTags,
@@ -28,18 +28,17 @@
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte'
import PostBody from './PostBody.svelte'
import { profile } from '$lib/auth'
import { profile } from '$lib/auth.svelte'
import { goto } from '$app/navigation'
function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
const tagContent = tags.map((t) => t.content.toLowerCase())
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'
tagContent.forEach((tag) => {
if ($userSettings.tagRules?.[tag])
rule = $userSettings.tagRules?.[tag] ?? rule
if (settings.tagRules?.[tag]) rule = settings.tagRules?.[tag] ?? rule
if (rule == 'hide') return rule
})
@@ -69,7 +68,7 @@
post,
actions = true,
hideCommunity = false,
view = $userSettings.view,
view = settings.view,
style = '',
class: clazz = '',
badges,
@@ -79,13 +78,13 @@
let type = $derived(mediaType(post.post.url, view))
let rule = $derived(getTagRule(tags.tags))
let hideTitle = $derived(
$userSettings.posts.deduplicateEmbed &&
settings.posts.deduplicateEmbed &&
post.post.embed_title == post.post.name &&
view != 'compact' &&
type != 'iframe',
)
let hideBody = $derived(
$userSettings.posts.deduplicateEmbed &&
settings.posts.deduplicateEmbed &&
post.post.embed_description == post.post.body &&
view != 'compact',
)
@@ -102,7 +101,7 @@
<div
class="post relative max-w-full min-w-0 w-full cursor-pointer outline-none
group
{$userSettings.leftAlign ? 'left-align' : ''}
{settings.leftAlign ? 'left-align' : ''}
{view == 'compact' ? 'py-3 list-type compact' : ''}
{view == 'list' ? 'py-5 list-type' : ''}
{view == 'cozy' ? 'py-5 flex flex-col gap-2' : ''}
@@ -168,7 +167,7 @@
<PostMediaCompact
post={post.post}
{type}
class="{$userSettings.leftAlign
class="{settings.leftAlign
? 'mr-3'
: 'ml-3'} flex-shrink no-list-margin"
style="grid-area: media;"
@@ -39,11 +39,11 @@
report,
} from '$lib/components/lemmy/moderation/moderation.js'
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 { setSessionStorage } from '$lib/session.js'
import { goto } from '$app/navigation'
import { userSettings, type View } from '$lib/settings.js'
import { settings, type View } from '$lib/settings.svelte.js'
import {
Button,
Menu,
@@ -59,7 +59,7 @@
import { hidePost, postLink } from './helpers'
import { feature } from '$lib/version'
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 TextProps from '$lib/components/ui/text/TextProps.svelte'
import { communityLink, userLink } from '$lib/lemmy/generic'
@@ -129,15 +129,15 @@
<footer
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}
>
<PostVote
post={post.post}
bind:vote={post.my_vote}
bind:score={post.counts.score}
bind:upvotes={post.counts.upvotes}
bind:downvotes={post.counts.downvotes}
vote={post.my_vote}
score={post.counts.score}
upvotes={post.counts.upvotes}
downvotes={post.counts.downvotes}
showCounts={$profile?.user?.local_user_view?.local_user?.show_scores ??
true}
/>
@@ -148,7 +148,7 @@
class="!text-inherit h-full px-3 relative"
color="ghost"
rounding="pill"
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
target={settings.openLinksInNewTab ? '_blank' : ''}
title={$t('post.actions.comments')}
animations={{ scale: true, large: false }}
>
@@ -163,7 +163,7 @@
</Button>
<div class="flex-1"></div>
{#if $userSettings.debugInfo}
{#if settings.debugInfo}
{#if debug}
{#await import('$lib/components/util/debug/DebugObject.svelte') then { default: DebugObject }}
<DebugObject object={post} bind:open={debug} />
@@ -378,7 +378,7 @@
</div>
{/if}
</MenuButton>
{#if post.post.body && $userSettings.translator}
{#if post.post.body && settings.translator}
<MenuButton
on:click={() => {
// @ts-ignore
@@ -397,7 +397,7 @@
on:click={() => {
setSessionStorage('postDraft', {
body: `${
$userSettings.crosspostOriginalLink
settings.crosspostOriginalLink
? `cross-posted from: ${post.post.ap_id}`
: ``
}\n${
+7 -11
View File
@@ -1,22 +1,17 @@
<script lang="ts">
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 { ChevronDown, Icon } from 'svelte-hero-icons'
let expanded = $state(false)
let element: Element = $state()
let element: Element | undefined = $state()
function isOverflown(element: Element, body: string = '') {
if (!element) return
let overflows =
if (!element) return false
return (
element.scrollHeight > element.clientHeight ||
element.scrollWidth > element.clientWidth
if (!overflows) expanded = true
else expanded = false
return overflows
)
}
interface Props {
@@ -37,7 +32,8 @@
class: clazz = '',
}: Props = $props()
let overflows = $derived(isOverflown(element, body))
let overflows = $derived(element ? isOverflown(element, body) : false)
let expanded = $state(false)
</script>
<svelte:element
@@ -65,7 +65,7 @@
} from 'svelte-hero-icons'
import { getInstance } from '$lib/lemmy.js'
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 { t } from '$lib/translations'
import { Pencil, type IconSource } from 'svelte-hero-icons'
@@ -315,11 +315,11 @@
href="/post/{getInstance()}/{id}"
class="inline hover:underline
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-medium'} {titleClass}"
class:text-slate-600={$userSettings.markReadPosts && read}
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
class:text-slate-600={settings.markReadPosts && read}
class:dark:text-zinc-400={settings.markReadPosts && read}
class:text-base={view == 'compact'}
class:text-lg={view != 'compact'}
style="grid-area: title;"
@@ -1,5 +1,5 @@
<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) =>
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`
@@ -20,7 +20,7 @@
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import type { Post } from 'lemmy-js-client'
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 { Button, Popover, buttonColor, toast } from 'mono-svelte'
import { site } from '$lib/lemmy.js'
@@ -1,13 +1,13 @@
<script lang="ts">
import Post from '$lib/components/lemmy/post/Post.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 { Badge, Button } from 'mono-svelte'
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { fly, slide } from 'svelte/transition'
import { combineCrossposts } from './crosspost'
import { combineCrossposts } from './crosspost.svelte'
interface Props {
posts: PostView[]
@@ -32,7 +32,7 @@
</script>
<ul
class="flex flex-col list-none {$userSettings.view == 'card'
class="flex flex-col list-none {settings.view == 'card'
? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
>
@@ -53,14 +53,14 @@
</div>
{:else}
{#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">
<Post
hideCommunity={community}
view={(post.post.featured_community || post.post.featured_local) &&
$userSettings.posts.compactFeatured
settings.posts.compactFeatured
? 'compact'
: $userSettings.view}
: settings.view}
{post}
class="transition-all duration-250"
on:hide={() => {
@@ -102,14 +102,14 @@
>
<span
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" />
{post.crossposts.length}
</span>
{#each post.crossposts as crosspost, index}
<div class="w-full transition-all mb-4">
<Post post={crosspost} view={$userSettings.view} />
<Post post={crosspost} view={settings.view} />
</div>
{/each}
</div>
@@ -3,7 +3,7 @@
import Post from '$lib/components/lemmy/post/Post.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
import type {
GetPostsResponse,
ListingType,
@@ -29,7 +29,7 @@
type SvelteVirtualizer,
} from '@tanstack/svelte-virtual'
import { afterNavigate, beforeNavigate } from '$app/navigation'
import { combineCrossposts } from './crosspost'
import { combineCrossposts } from './crosspost.svelte'
import { client } from '$lib/lemmy'
import {
postFeeds,
@@ -199,7 +199,7 @@
<!-- <svelte:window on:keydown={handleKeydown} /> -->
<ul
class="flex flex-col list-none {$userSettings.view == 'card'
class="flex flex-col list-none {settings.view == 'card'
? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
>
@@ -247,9 +247,9 @@
hideCommunity={community}
view={(posts[row.index]?.post.featured_community ||
posts[row.index]?.post.featured_local) &&
$userSettings.posts.compactFeatured
settings.posts.compactFeatured
? 'compact'
: $userSettings.view}
: settings.view}
{post}
class="transition-all duration-250"
on:hide={() => {
@@ -263,7 +263,7 @@
</div>
{/if}
{#if $userSettings.infiniteScroll && browser}
{#if settings.infiniteScroll && browser}
{#if error}
<div
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 { get } from 'svelte/store'
@@ -29,8 +29,8 @@ export const combineCrossposts = (
posts?.forEach((post) => {
if (
!post ||
(get(userSettings).hidePosts.deleted && post.post.deleted) ||
(get(userSettings).hidePosts.removed && post.post.removed)
(settings.hidePosts.deleted && post.post.deleted) ||
(settings.hidePosts.removed && post.post.removed)
)
return
if (!post?.post?.url) {
@@ -16,9 +16,9 @@
Link,
XMark,
} 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 { placeholders, uploadImage } from '$lib/util.js'
import { placeholders, uploadImage } from '$lib/util.svelte.js'
import { Checkbox, TextInput } from 'mono-svelte'
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
import { client, getInstance } from '$lib/lemmy.js'
import type { View } from '$lib/settings.svelte'
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'
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
@@ -10,7 +10,7 @@
import { optimizeImageURL } from '../helpers'
import PostLinkSources from './PostLinkSources.svelte'
import { t } from '$lib/translations'
import type { View } from '$lib/settings'
import type { View } from '$lib/settings.svelte'
interface Props {
url: string
@@ -5,10 +5,10 @@
return 'www.youtube-nocookie.com'
}
case 'invidious': {
return get(userSettings).embeds.invidious || 'yewtu.be'
return settings.embeds.invidious || 'yewtu.be'
}
case 'piped': {
return get(userSettings).embeds.piped || 'piped.video'
return settings.embeds.piped || 'piped.video'
}
}
}
@@ -34,7 +34,7 @@
type IconSource,
} from 'svelte-hero-icons'
import { optimizeImageURL, type IframeType, type MediaType } from '../helpers'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
import { get } from 'svelte/store'
const urlToEmbed = (inputUrl: string) => {
@@ -50,7 +50,7 @@
if (autoplay) url.searchParams.set('autoplay', '1')
return `https://${youtubeDomain(
$userSettings.embeds.youtube,
settings.embeds.youtube,
)}/embed/${videoID}?${url.searchParams.toString()}`
}
@@ -98,8 +98,8 @@
type = 'none',
thumbnail = undefined,
url,
opened = $bindable(!$userSettings.embeds.clickToView),
autoplay = $userSettings.embeds.clickToView,
opened = $bindable(!settings.embeds.clickToView),
autoplay = settings.embeds.clickToView,
class: clazz = '',
}: Props = $props()
@@ -1,7 +1,7 @@
<script lang="ts">
import { stopPropagation } from 'svelte/legacy'
import { userSettings, type View } from '$lib/settings'
import { settings, type View } from '$lib/settings.svelte'
import type { Post } from 'lemmy-js-client'
import { bestImageURL, postLink } from '../helpers'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
@@ -24,7 +24,7 @@
<!--disabled preloads here since most people will hover over every image while scrolling-->
<svelte:element
this={$userSettings.expandImages ? 'button' : 'a'}
this={settings.expandImages ? 'button' : 'a'}
href={postLink(post)}
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
data-sveltekit-preload-data="off"
@@ -10,7 +10,7 @@
import ExpandableImage, {
showImage,
} from '$lib/components/ui/ExpandableImage.svelte'
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
import type { Post } from 'lemmy-js-client'
import PostIframe from './PostIframe.svelte'
import { Button, Material, modal } from 'mono-svelte'
@@ -31,7 +31,7 @@
post,
type = 'none',
opened = undefined,
blur = post.nsfw && $userSettings.nsfwBlur,
blur = post.nsfw && settings.nsfwBlur,
}: Props = $props()
</script>
@@ -6,7 +6,7 @@
type MediaType,
} from '$lib/components/lemmy/post/helpers.js'
import { showImage } from '$lib/components/ui/ExpandableImage.svelte'
import { userSettings, type View } from '$lib/settings.js'
import { settings, type View } from '$lib/settings.svelte.js'
import { isImage } from '$lib/ui/image'
import type { Post } from 'lemmy-js-client'
import { Material, Popover } from 'mono-svelte'
@@ -34,7 +34,7 @@
post,
type = 'none',
view = 'cozy',
blur = post.nsfw && $userSettings.nsfwBlur,
blur = post.nsfw && settings.nsfwBlur,
style = '',
class: clazz = '',
}: Props = $props()
@@ -50,7 +50,7 @@
{#if post.alt_text}
<Popover
openOnHover
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
placement={settings.leftAlign ? 'bottom-start' : 'bottom-end'}
>
{#snippet target()}
<Material
@@ -68,7 +68,7 @@
</Popover>
{/if}
<svelte:element
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
this={!settings.expandImages || type != 'image' ? 'a' : 'button'}
href={postLink(post)}
onclick={() => {
if (type == 'image') {
@@ -50,7 +50,7 @@
<script lang="ts">
import Avatar from '$lib/components/ui/Avatar.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 { Icon, Language, NoSymbol } from 'svelte-hero-icons'
@@ -74,9 +74,9 @@
avatarSize = 24,
badges = true,
inComment = false,
showInstance = $userSettings.showInstances.user ||
($userSettings.showInstances.comments && inComment),
displayName = $userSettings.displayNames,
showInstance = settings.showInstances.user ||
(settings.showInstances.comments && inComment),
displayName = settings.displayNames,
instanceClass = '',
class: clazz = '',
children,
+4 -7
View File
@@ -92,8 +92,6 @@
import SvelteMarkdown from 'svelte-markdown'
options.inline = inline
interface Props {
source?: string
inline?: boolean
@@ -110,10 +108,9 @@
class: clazz = '',
}: Props = $props()
let tokens
run(() => {
tokens = marked.lexer(source)
})
options.inline = inline
let tokens = $derived.by(() => marked.lexer(source))
</script>
<div
@@ -123,7 +120,7 @@
{style}
>
<SvelteMarkdown
bind:source={tokens}
source={tokens}
{renderers}
{options}
isInline={inline || undefined}
@@ -1,11 +1,11 @@
<script lang="ts">
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 Markdown from '$lib/components/markdown/Markdown.svelte'
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 { Button, Label, Modal, TextArea } from 'mono-svelte'
import { createEventDispatcher, tick } from 'svelte'
@@ -4,7 +4,7 @@
import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte'
import { text } from './translation'
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 MarkdownEditor from '../markdown/MarkdownEditor.svelte'
@@ -30,7 +30,7 @@
let to = $state($locale)
async function translate(text: string) {
const url = $userSettings.translator
const url = settings.translator
if (!url) {
return
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { findClosestNumber } from '$lib/util.js'
import { findClosestNumber } from '$lib/util.svelte.js'
import { createAvatar } from '@dicebear/core'
import * as initials from '@dicebear/initials'
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
interface Props {
width?: number
+6 -9
View File
@@ -65,12 +65,9 @@
export let screenWidth = writable(1000)
export let dockProps: Readable<ReturnType<typeof calculateDockProperties>> =
derivedStore(
[userSettings, screenWidth],
([$settings, $screenWidth], set) => {
set(calculateDockProperties($settings.dock, $screenWidth))
},
)
derivedStore([screenWidth], ([$screenWidth], set) => {
set(calculateDockProperties(settings.dock, $screenWidth))
})
export let contentPadding: Readable<ReturnType<typeof calculatePadding>> =
derivedStore(dockProps, ($dockProps, set) =>
set(calculatePadding($dockProps.noGap, $dockProps.top, true)),
@@ -78,9 +75,9 @@
</script>
<script lang="ts">
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
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'
interface Props {
@@ -155,7 +152,7 @@
})}
</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'
: ''}"
>
@@ -1,5 +1,5 @@
<script lang="ts">
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
import { contentPadding } from '../Shell.svelte'
interface Props {
@@ -35,7 +35,7 @@
>
<h1
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?.()}
</h1>
+3 -3
View File
@@ -1,5 +1,5 @@
<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 {
amModOfAny,
@@ -36,7 +36,7 @@
import { t } from '$lib/translations'
import CommandsWrapper from './commands/CommandsWrapper.svelte'
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'
let promptOpen: boolean = $state(false)
@@ -67,7 +67,7 @@
class="ml-2 logo"
adaptive={false}
>
{#snippet icon()}
{#snippet customIcon()}
{#if LINKED_INSTANCE_URL}
{#if $site}
<Avatar
+3 -3
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { stopPropagation } from 'svelte/legacy'
import { notifications, profile } from '$lib/auth'
import { notifications, profile } from '$lib/auth.svelte'
import {
Badge,
@@ -34,7 +34,7 @@
UserGroup,
} from 'svelte-hero-icons'
import { colorScheme } from '$lib/ui/colors'
import { userSettings } from '$lib/settings'
import { settings } from '$lib/settings.svelte'
import { site } from '$lib/lemmy'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations'
@@ -185,7 +185,7 @@
{/snippet}
{$t('nav.menu.theme')}
</MenuButton>
{#if $userSettings.debugInfo}
{#if settings.debugInfo}
<MenuButton link href="/util">
{#snippet prefix()}
<Icon src={BugAnt} mini width={16} />
@@ -7,16 +7,15 @@
type IconSource,
} from 'svelte-hero-icons'
import Avatar from '../../Avatar.svelte'
import type { Action } from './actions'
import type { Action } from './actions.svelte'
interface Props {
action: Action;
class?: string;
children?: import('svelte').Snippet;
action: Action
class?: string
children?: import('svelte').Snippet
}
let { action, class: clazz = '', children }: Props = $props();
let { action, class: clazz = '', children }: Props = $props()
</script>
<Button
@@ -1,5 +1,5 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import { run } from 'svelte/legacy'
import { resumables } from '$lib/lemmy/item'
import { TextInput } from 'mono-svelte'
@@ -9,19 +9,17 @@
import CommandItem from './CommandItem.svelte'
import { browser } from '$app/environment'
import { afterNavigate, goto } from '$app/navigation'
import { profile, profileData } from '$lib/auth'
import { getGroups, type Action, type Group } from './actions'
import { profile, profileData } from '$lib/auth.svelte'
import { getGroups, type Action, type Group } from './actions.svelte'
import { themeData } from '$lib/ui/colors'
import { page } from '$app/stores'
interface Props {
open?: boolean;
groups?: Group[];
open?: boolean
groups?: Group[]
}
let { open = $bindable(false), groups = $bindable([]) }: Props = $props();
let { open = $bindable(false), groups = $bindable([]) }: Props = $props()
let search = $state('')
let container: HTMLElement = $state()
@@ -87,7 +85,7 @@
score: Math.max(
fuzzySearch(action.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)
@@ -98,7 +96,7 @@
actions: scoredActions,
score: Math.max(
fuzzySearch(group.name, term),
...scoredActions.map((a) => a.score)
...scoredActions.map((a) => a.score),
),
}
})
@@ -130,10 +128,9 @@
updateFilteredGroups()
}
function flattenActions(
actions: Action[],
subaction: boolean = true
subaction: boolean = true,
): Action[] {
return actions.flatMap((action) => [
action,
@@ -230,20 +227,22 @@
})
run(() => {
if (open) search = ''
});
})
run(() => {
groups = getGroups(
$resumables,
$profile,
$profileData.profiles,
$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(() => {
debouncedSearch(search)
});
})
</script>
<svelte:window onkeydown={handleKeydown} />
@@ -5,10 +5,10 @@
import { CommandLine, Icon } from 'svelte-hero-icons'
interface Props {
open?: boolean;
open?: boolean
}
let { open = $bindable(false) }: Props = $props();
let { open = $bindable(false) }: Props = $props()
function handleKeydown(event: KeyboardEvent) {
if (
@@ -25,8 +25,8 @@
{#if open}
<Modal bind:open>
{#snippet title()}
<span class="flex items-center gap-1">
{#snippet customTitle()}
<span class="flex items-center gap-1">
<svg
width="24"
height="24"
@@ -40,7 +40,7 @@
</svg>
{$t('nav.commands.prompt')}
</span>
{/snippet}
{/snippet}
{#await import('./Commands.svelte')}
<div class="h-96 flex flex-col gap-2 items-center justify-center">
<Spinner width={32} />
@@ -1,15 +1,15 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { setUserID, type Profile } from '$lib/auth'
import { setUserID, type Profile } from '$lib/auth.svelte'
import {
amModOfAny,
isAdmin,
} from '$lib/components/lemmy/moderation/moderation'
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 { colorScheme, theme, themeData, type ThemeData } from '$lib/ui/colors'
import { fullCommunityName } from '$lib/util'
import { fullCommunityName } from '$lib/util.svelte'
import {
ArrowRightOnRectangle,
Bookmark,
@@ -339,10 +339,7 @@ export function getGroups(
}),
icon: ViewColumns,
handle: () =>
userSettings.update((s) => ({
...s,
view: 'compact',
})),
settings.view = 'compact'
},
{
name: t.get('nav.commands.setViewTo', {
@@ -350,10 +347,7 @@ export function getGroups(
}),
icon: ViewColumns,
handle: () =>
userSettings.update((s) => ({
...s,
view: 'cozy',
})),
settings.view = 'cozy'
},
{
name: t.get('nav.commands.setViewTo', {
@@ -361,21 +355,7 @@ export function getGroups(
}),
icon: ViewColumns,
handle: () =>
userSettings.update((s) => ({
...s,
view: 'list',
})),
},
{
name: t.get('nav.commands.setViewTo', {
default: t.get('filter.view.legacy'),
}),
icon: ViewColumns,
handle: () =>
userSettings.update((s) => ({
...s,
view: 'card',
})),
settings.view = 'list'
},
],
},
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/auth'
import { profile } from '$lib/auth.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { addFavorite } from '$lib/lemmy/item'
@@ -11,11 +11,11 @@
import { expoOut } from 'svelte/easing'
interface Props {
items: Community[];
isFavorites?: boolean;
items: Community[]
isFavorites?: boolean
}
let { items, isFavorites = false }: Props = $props();
let { items, isFavorites = false }: Props = $props()
</script>
{#each items.sort( (a, b) => a.title.localeCompare(b.title), ) as follow (follow.id)}
@@ -65,13 +65,13 @@
href="/c/{follow.name}@{new URL(follow.actor_id).hostname}"
>
{#snippet label()}
<div class="flex flex-col max-w-full break-words" >
<div class="flex flex-col max-w-full break-words">
<span>{follow.title}</span>
<span class="text-xs text-slate-600 dark:text-zinc-400">
{new URL(follow.actor_id).hostname}
</span>
</div>
{/snippet}
{/snippet}
</SidebarButton>
</div>
{/each}
@@ -1,22 +1,21 @@
<script lang="ts">
import { goto } from '$app/navigation'
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 { LINKED_INSTANCE_URL } from '$lib/instance'
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
import { Button } from 'mono-svelte'
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons'
let switching: boolean = $state(false)
interface Props {
prof: Profile;
index: number;
guest?: boolean;
prof: Profile
index: number
guest?: boolean
}
let { prof, index, guest = false }: Props = $props();
let { prof, index, guest = false }: Props = $props()
</script>
<SidebarButton
@@ -48,7 +47,6 @@
{index}
{guest}
selected={$profile?.id == prof.id}
/>
{/snippet}
<span
+13 -13
View File
@@ -8,8 +8,8 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { notifications, profile, profileData } from '$lib/auth.js'
import { userSettings } from '$lib/settings.js'
import { notifications, profile, profileData } from '$lib/auth.svelte.js'
import { settings } from '$lib/settings.svelte.js'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
@@ -36,9 +36,9 @@
gap-1 h-fit max-h-screen {clazz}"
{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">
{#each $userSettings.dock.pins as pin}
{#each settings.dock.pins as pin}
<SidebarButton
icon={iconOfLink(pin.url)}
on:click={() => goto(pin.url)}
@@ -46,8 +46,8 @@
selected={`${$page.url.pathname}${$page.url.search}` == pin.url}
on:contextmenu={(e) => {
e.preventDefault()
$userSettings.dock.pins = $userSettings.dock.pins.toSpliced(
$userSettings.dock.pins.findLastIndex((p) => pin.url == p.url),
settings.dock.pins = settings.dock.pins.toSpliced(
settings.dock.pins.findLastIndex((p) => pin.url == p.url),
1,
)
return false
@@ -120,7 +120,7 @@
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.accounts}
bind:open={settings.expand.accounts}
>
{#snippet title()}
<span class="px-2 py-1 w-full">
@@ -148,11 +148,11 @@
{#if $profile?.favorites && $profile?.favorites.length > 0}
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.favorites}
bind:open={settings.expand.favorites}
>
{#snippet title()}
<span
class="px-2 py-1 w-full {$userSettings.expandSidebar
class="px-2 py-1 w-full {settings.expandSidebar
? ''
: '//max-lg:hidden'}"
>
@@ -174,11 +174,11 @@
{#if $profile?.user.moderates.length > 0}
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.moderates}
bind:open={settings.expand.moderates}
>
{#snippet title()}
<span
class="px-2 py-1 w-full {$userSettings.expandSidebar
class="px-2 py-1 w-full {settings.expandSidebar
? ''
: '//max-lg:hidden'}"
>
@@ -201,11 +201,11 @@
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={$userSettings.expand.communities}
bind:open={settings.expand.communities}
>
{#snippet title()}
<span
class="px-2 py-1 w-full {$userSettings.expandSidebar
class="px-2 py-1 w-full {settings.expandSidebar
? ''
: '//max-lg:hidden'}"
>
@@ -2,7 +2,7 @@
import { run } from 'svelte/legacy'
import { page } from '$app/stores'
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'