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

+1 -1
View File
@@ -1,6 +1,6 @@
// 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'
// 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 { client, getClient } from '$lib/lemmy.js'
import { site } from './lemmy'
import { instanceToURL, moveItem } from '$lib/util.js'
import { instanceToURL, moveItem } from '$lib/util.svelte'
import {
type GetSiteResponse,
type MyUserInfo,
+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'
+2 -2
View File
@@ -2,8 +2,8 @@ import { type GetSiteResponse, LemmyHttp } from 'lemmy-js-client'
import { get, writable } from 'svelte/store'
import { error } from '@sveltejs/kit'
import { instance } from '$lib/instance.js'
import { instanceToURL } from '$lib/util.js'
import { profile } from '$lib/auth.js'
import { instanceToURL } from '$lib/util.svelte'
import { profile } from '$lib/auth.svelte'
import { toast } from 'mono-svelte'
export const site = writable<GetSiteResponse | undefined>(undefined)
+10 -10
View File
@@ -1,13 +1,13 @@
<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'
interface Props {
profile?: Profile | undefined;
selected?: boolean;
index?: number;
size?: number;
guest?: boolean;
profile?: Profile | undefined
selected?: boolean
index?: number
size?: number
guest?: boolean
}
let {
@@ -15,8 +15,8 @@
selected = false,
index = 0,
size = 20,
guest = false
}: Props = $props();
guest = false,
}: Props = $props()
</script>
{#if profile}
@@ -40,8 +40,8 @@
style={guest
? `color: gray`
: profile.color
? `color: ${profile.color}`
: `filter: hue-rotate(${index * 50}deg)`}
? `color: ${profile.color}`
: `filter: hue-rotate(${index * 50}deg)`}
/>
{/if}
</div>
+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'
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 {
CommentReportView,
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 { trycatch } from '$lib/util.js'
import { trycatch } from '$lib/util.svelte'
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
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 Material } from './materials/Material.svelte'
export { default as Form } from './forms/Form.svelte'
export { default as Label } from './forms/Label.svelte'
export { default as FileInput } from './forms/FileInput.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 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 Menu } from './popover/Menu.svelte'
+12 -14
View File
@@ -3,18 +3,18 @@
type ButtonAlignment,
type ButtonColor,
} from '../button/Button.svelte'
import { Icon, type IconSource} from 'svelte-hero-icons'
import { Icon, type IconSource } from 'svelte-hero-icons'
interface Props {
color?: ButtonColor;
alignment?: ButtonAlignment;
href?: string | undefined;
disabled?: boolean;
class?: string;
icon?: IconSource;
prefix?: import('svelte').Snippet;
children?: import('svelte').Snippet;
suffix?: import('svelte').Snippet;
color?: ButtonColor
alignment?: ButtonAlignment
href?: string | undefined
disabled?: boolean
class?: string
icon?: IconSource
prefix?: import('svelte').Snippet
children?: import('svelte').Snippet
suffix?: import('svelte').Snippet
[key: string]: any
}
@@ -29,8 +29,7 @@
children,
suffix,
...rest
}: Props = $props();
}: Props = $props()
</script>
<Button
@@ -53,9 +52,8 @@
? 'text-slate-600 dark:text-zinc-400'
: ''}
flex-shrink-0"
>
{#if !icon}
{#if icon}
<Icon src={icon} micro size="16" />
{:else}
{@render prefix?.()}
+27 -29
View File
@@ -29,6 +29,33 @@
import { focusTrap } from 'svelte-focus-trap'
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)
@@ -56,35 +83,6 @@
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>
<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 { env } from '$env/dynamic/public'
import { locale } from './translations'
@@ -40,7 +40,7 @@ interface Settings {
defaultSort: {
sort: SortType
feed: 'All' | 'Subscribed' | 'Local'
feed: ListingType
comments: CommentSortType
}
hidePosts: {
@@ -191,37 +191,27 @@ export const defaultSettings: Settings = {
logoColorMonth: null,
}
export const userSettings = writable(defaultSettings)
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
}
function createSettingsState(initial: Settings) {
let settings = $state(initial)
return settings
}
export let settings = createSettingsState(defaultSettings)
if (typeof window != 'undefined') {
let oldUserSettings = JSON.parse(
localStorage.getItem('settings') ?? JSON.stringify(defaultSettings)
)
oldUserSettings = migrate(oldUserSettings)
userSettings.set({
...defaultSettings,
...oldUserSettings,
settingsVer: defaultSettings.settingsVer,
})
// settings = {
// ...defaultSettings,
// ...oldUserSettings,
// settingsVer: defaultSettings.settingsVer,
// }
}
userSettings.subscribe((settings) => {
$effect.root(() => {
if (typeof window != 'undefined') {
localStorage.setItem('settings', JSON.stringify(settings))
}
@@ -230,4 +220,4 @@ userSettings.subscribe((settings) => {
} else {
if (browser) locale.set(navigator?.language)
}
})
})
+2 -2
View File
@@ -1,6 +1,6 @@
import { goto } from '$app/navigation'
import { toast } from 'mono-svelte'
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte'
import { get } from 'svelte/store'
import type { SubscribedType } from 'lemmy-js-client'
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',
],
get: (type: 'url' | 'post' | 'comment') => {
return get(userSettings)?.randomPlaceholders
return settings.randomPlaceholders
? placeholders[type][
Math.floor(Math.random() * placeholders[type].length)
]
+35 -45
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import { run } from 'svelte/legacy'
import Navbar from '$lib/components/ui/navbar/Navbar.svelte'
import '../style/app.css'
@@ -15,7 +15,7 @@
theme,
themeVars,
} from '$lib/ui/colors.js'
import { userSettings } from '$lib/settings.js'
import { settings } from '$lib/settings.svelte.js'
import {
Button,
ModalContainer,
@@ -26,7 +26,7 @@
import { onMount } from 'svelte'
import { browser } from '$app/environment'
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 SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { site } from '$lib/lemmy.js'
@@ -35,10 +35,10 @@
import { locale } from '$lib/translations'
import { getDefaultColors } from '$lib/ui/presets'
interface Props {
children?: import('svelte').Snippet;
children?: import('svelte').Snippet
}
let { children }: Props = $props();
let { children }: Props = $props()
nProgress.configure({
minimum: 0.4,
@@ -62,7 +62,7 @@
nProgress.done()
}
}
});
})
onMount(() => {
if (browser) {
@@ -70,31 +70,33 @@
history.replaceState(
null,
'',
window.location.toString().replace('#main', '')
window.location.toString().replace('#main', ''),
)
}
document.body.querySelector('.loader')?.classList.add('hidden')
themeVars.subscribe((vars) => {
document.body.setAttribute('style', vars)
})
userSettings.subscribe((settings) => {
document.body.classList.remove(
'font-display',
'font-inter',
'font-sans',
'font-system',
'font-nunito'
)
document.body.classList.add(
settings.font == 'inter'
? 'font-inter'
: $userSettings.font == 'system'
? 'font-system'
: $userSettings.font == 'satoshi/nunito'
? 'font-nunito'
: 'font-sans'
)
})
// $effect(() => {
// if (settings) {
// document.body.classList.remove(
// 'font-display',
// 'font-inter',
// 'font-sans',
// 'font-system',
// 'font-nunito',
// )
// document.body.classList.add(
// settings.font == 'inter'
// ? 'font-inter'
// : settings.font == 'system'
// ? 'font-system'
// : settings.font == 'satoshi/nunito'
// ? 'font-nunito'
// : 'font-sans',
// )
// }
// })
}
})
</script>
@@ -106,8 +108,8 @@
name="theme-color"
content={rgbToHex(
$colorScheme && inDarkColorScheme()
? $theme.colors.zinc?.[925] ?? getDefaultColors().zinc[925]
: $theme.colors.slate?.[25] ?? getDefaultColors().slate[25]
? ($theme.colors.zinc?.[925] ?? getDefaultColors().zinc[925])
: ($theme.colors.slate?.[25] ?? getDefaultColors().slate[25]),
)}
/>
{#if LINKED_INSTANCE_URL}
@@ -124,12 +126,12 @@
href="#main"
>
{#snippet prefix()}
<Icon src={Forward} mini size="16" />
<Icon src={Forward} mini size="16" />
{/snippet}
Skip Navigation
</Button>
<Shell
dir={$locale == 'he' && $userSettings.useRtl ? 'rtl' : 'ltr'}
dir={$locale == 'he' && settings.useRtl ? 'rtl' : 'ltr'}
class="min-h-screen "
route={$page.route}
>
@@ -139,20 +141,10 @@
<ModalContainer />
{#snippet sidebar({ style: s, class: c })}
<Sidebar
route={$page.route.id ?? ''}
class={c}
style={s}
/>
<Sidebar class={c} style={s} />
{/snippet}
{#snippet main({ style: s, class: c })}
<main
class="p-4 sm:p-6 min-w-0 w-full flex flex-col h-full relative {c}"
style={s}
id="main"
@@ -161,15 +153,13 @@
</main>
{/snippet}
{#snippet navbar({ style: s, class: c })}
<Navbar class={c} style={s} />
<Navbar class={c} style={s} />
{/snippet}
{#snippet suffix({ class: c, style: s })}
<div class={c} style={s}>
<div class={c} style={s}>
{#if $page.data.slots?.sidebar?.component}
{@const SvelteComponent = $page.data.slots.sidebar.component}
<SvelteComponent
{...$page.data.slots.sidebar.props}
/>
<SvelteComponent {...$page.data.slots.sidebar.props} />
{:else if $site}
<SiteCard
site={$site.site_view}
+2 -2
View File
@@ -1,6 +1,6 @@
import { browser } from '$app/environment'
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 { get } from 'svelte/store'
@@ -9,7 +9,7 @@ export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
export const load = async ({}) => {
if (browser) {
const initLocale =
get(userSettings)?.language ?? navigator?.language ?? 'en'
settings.language ?? navigator?.language ?? 'en'
console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`)
+22 -22
View File
@@ -1,29 +1,35 @@
<script lang="ts" module>
</script>
<script lang="ts">
import { page } from '$app/stores'
import Pageination from '$lib/components/ui/Pageination.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.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 { site } from '$lib/lemmy.js'
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
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 VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.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 &&
browser &&
!$userSettings.posts.noVirtualize
let type = $state(data.type_)
let sort = $state(data.sort)
$effect(() => {
if (sort) settings.defaultSort.sort = sort
})
const FeedComponent = $derived(
settings.infiniteScroll && browser && !settings.posts.noVirtualize
? VirtualFeed
: PostFeed);
: PostFeed,
)
</script>
<div class="flex flex-col gap-2 max-w-full w-full min-w-0">
@@ -32,24 +38,18 @@
{$t('routes.frontpage.title')}
{#snippet extended()}
<div class="flex items-center gap-2" >
{#if data.type_}
<Location changeDefault selected={data.type_} />
{/if}
<Sort changeDefault selected={data.sort} />
<div class="flex items-center gap-2">
<Location bind:selected={type} />
<Sort bind:selected={sort} />
<ViewSelect />
</div>
{/snippet}
{/snippet}
</Header>
</header>
<SvelteComponent
posts={data.posts.posts}
bind:feedData={data}
feedId="main"
/>
<FeedComponent posts={data.posts.posts} feedData={data} feedId="main" />
<svelte:element
this={$userSettings.infiniteScroll && !$userSettings.posts.noVirtualize
this={settings.infiniteScroll && !settings.posts.noVirtualize
? 'noscript'
: 'div'}
class="mt-auto"
+1 -3
View File
@@ -1,5 +1,5 @@
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 { get, writable } from 'svelte/store'
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 prevCursor = url.searchParams.get('prevCursor') as string | undefined
const settings = get(userSettings)
const sort: SortType =
(url.searchParams.get('sort') as SortType) || settings.defaultSort.sort
const listingType: ListingType =
+51 -55
View File
@@ -7,13 +7,13 @@
moveProfile,
type Profile,
profile,
} from '$lib/auth.js'
} from '$lib/auth.svelte.js'
import EditableList from '$lib/components/ui/list/EditableList.svelte'
import { Menu, MenuButton, Modal } from 'mono-svelte'
import DebugObject from '$lib/components/util/debug/DebugObject.svelte'
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
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 {
ArrowLeftOnRectangle,
@@ -58,21 +58,21 @@
bind:open={debugging}
>
{#snippet title()}
<span class="flex flex-col">
<span class="flex flex-col">
<h1 class="font-bold text-2xl">Debug</h1>
<span class="text-slate-600 dark:text-zinc-400 text-base font-normal">
Do NOT share anything from this menu.
</span>
</span>
{/snippet}
{/snippet}
</DebugObject>
{/if}
{#if removing.shown && removing.account}
<Modal bind:open={removing.shown}>
{#snippet title()}
<span >Removing Account</span>
{/snippet}
{#snippet customTitle()}
<span>Removing Account</span>
{/snippet}
<div class="flex flex-row items-center gap-2">
<ProfileAvatar profile={removing.account} selected={true} />
@@ -120,14 +120,14 @@
<div class="flex flex-row items-center gap-2">
<Button href="/accounts/login" size="lg">
{#snippet prefix()}
<Icon src={ArrowLeftOnRectangle} size="16" micro />
{/snippet}
<Icon src={ArrowLeftOnRectangle} size="16" micro />
{/snippet}
Log in
</Button>
<Button href="/signup" size="lg">
{#snippet prefix()}
<Icon src={Identification} size="16" micro />
{/snippet}
<Icon src={Identification} size="16" micro />
{/snippet}
Sign up
</Button>
</div>
@@ -138,7 +138,7 @@
<Header pageHeader>
{$t('routes.accounts')}
{#snippet extended()}
<div class="flex" >
<div class="flex">
<div class="flex gap-2 mr-auto">
<Button
href="/accounts/login"
@@ -147,40 +147,41 @@
color="primary"
>
{#snippet prefix()}
<Icon src={ArrowLeftOnRectangle} size="16" mini />
{/snippet}
<Icon src={ArrowLeftOnRectangle} size="16" mini />
{/snippet}
{$t('account.login')}
</Button>
{#if !LINKED_INSTANCE_URL}
<Button href="/accounts/login/guest" size="lg">
{#snippet prefix()}
<Icon src={Plus} size="16" micro />
{/snippet}
<Icon src={Plus} size="16" micro />
{/snippet}
{$t('account.addGuest')}
</Button>
{/if}
</div>
</div>
{/snippet}
{/snippet}
</Header>
<FilterTabs items={$profileData.profiles} id={(i) => i.instance} >
<FilterTabs items={$profileData.profiles} id={(i) => i.instance}>
{#snippet children({ items })}
<EditableList
<EditableList
on:action={(acc) => {
removing.account = acc.detail
removing.shown = !removing.shown
}}
>
{#snippet children({ action })}
{#each items as profile, index (profile.id)}
{#each items as profile, index (profile.id)}
<div
class="flex flex-row gap-2 items-center py-3"
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
animate:flip={{ duration: 500, easing: expoOut }}
>
<Button
title={profile.id == $currentProfile?.id ? 'Switch' : 'Current'}
title={profile.id == $currentProfile?.id
? 'Switch'
: 'Current'}
on:click={async () => {
if (profile.id != $currentProfile?.id) {
switching = profile.id
@@ -189,20 +190,20 @@
}
}}
size="square-md"
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'}
color={profile.id == $currentProfile?.id
? 'primary'
: 'ghost'}
loading={switching == profile.id}
disabled={switching == profile.id}
rounding="pill"
>
{#snippet prefix()}
{#if profile.id == $currentProfile?.id}
<Icon src={Check} mini size="16" />
{:else}
<Icon src={ArrowsRightLeft} size="16" mini />
{/if}
{/snippet}
{#if profile.id == $currentProfile?.id}
<Icon src={Check} mini size="16" />
{:else}
<Icon src={ArrowsRightLeft} size="16" mini />
{/if}
{/snippet}
</Button>
<div class="flex items-center gap-2">
<div class="relative group flex-col items-center">
@@ -236,12 +237,12 @@
<div class="ml-auto"></div>
<Menu placement="bottom-end">
{#snippet target()}
<Button size="square-md" >
<Button size="square-md">
{#snippet prefix()}
<Icon src={EllipsisHorizontal} mini size="16" />
{/snippet}
<Icon src={EllipsisHorizontal} mini size="16" />
{/snippet}
</Button>
{/snippet}
{/snippet}
<div class="px-4 py-2 flex items-center gap-2">
<Button
size="square-md"
@@ -250,8 +251,8 @@
on:click={() => moveProfile(profile.id, true)}
>
{#snippet prefix()}
<Icon src={ChevronUp} size="16" mini />
{/snippet}
<Icon src={ChevronUp} size="16" mini />
{/snippet}
</Button>
<Button
size="square-md"
@@ -260,8 +261,8 @@
on:click={() => moveProfile(profile.id, false)}
>
{#snippet prefix()}
<Icon src={ChevronDown} size="16" mini />
{/snippet}
<Icon src={ChevronDown} size="16" mini />
{/snippet}
</Button>
</div>
<MenuButton
@@ -269,11 +270,11 @@
on:click={() => (profile.color = undefined)}
>
{#snippet prefix()}
<Icon src={ArrowUturnLeft} size="16" mini />
{/snippet}
<Icon src={ArrowUturnLeft} size="16" mini />
{/snippet}
{$t('account.resetColor')}
</MenuButton>
{#if $userSettings.debugInfo}
{#if settings.debugInfo}
<MenuButton
on:click={() => {
debugProfile = profile
@@ -281,8 +282,8 @@
}}
>
{#snippet prefix()}
<Icon src={BugAnt} size="16" mini />
{/snippet}
<Icon src={BugAnt} size="16" mini />
{/snippet}
{$t('common.debug')}
</MenuButton>
{/if}
@@ -292,22 +293,17 @@
color="danger-subtle"
>
{#snippet prefix()}
<Icon
src={ArrowRightOnRectangle}
size="16"
mini
/>
{/snippet}
<Icon src={ArrowRightOnRectangle} size="16" mini />
{/snippet}
{$t('account.logout')}
</MenuButton>
{/if}
</Menu>
</div>
{/each}
{/snippet}
</EditableList>
{/snippet}
</FilterTabs>
{/snippet}
</EditableList>
{/snippet}
</FilterTabs>
</div>
{/if}
+2 -2
View File
@@ -1,5 +1,5 @@
<script>
import { notifications } from '$lib/auth'
import { notifications } from '$lib/auth.svelte'
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
import { t } from '$lib/translations'
@@ -10,7 +10,7 @@
*/
/** @type {Props} */
let { children } = $props();
let { children } = $props()
</script>
{#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 { getClient } from '$lib/lemmy.js'
import { site as siteStore } from '$lib/lemmy'
+2 -2
View File
@@ -2,14 +2,14 @@
import { page } from '$app/stores'
import Pageination from '$lib/components/ui/Pageination.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 Application from './Application.svelte'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data } = $props();
let { data } = $props()
</script>
<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 { get } from 'svelte/store'
@@ -1,5 +1,5 @@
<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 SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { Material, toast } from 'mono-svelte'
@@ -16,10 +16,10 @@
import { t } from '$lib/translations'
interface Props {
application: RegistrationApplicationView;
application: RegistrationApplicationView
}
let { application = $bindable() }: Props = $props();
let { application = $bindable() }: Props = $props()
let approving = $state(false)
let denying = $state(false)
@@ -52,7 +52,7 @@
try {
await getClient().approveRegistrationApplication(
registrationApplicationAnswer
registrationApplicationAnswer,
)
toast({
content: approve
@@ -144,8 +144,8 @@
disabled={approving || denying || reviewing}
>
{#snippet prefix()}
<Icon src={XMark} mini size="16" />
{/snippet}
<Icon src={XMark} mini size="16" />
{/snippet}
</Button>
<Button
size="square-md"
@@ -159,8 +159,8 @@
disabled={approving || denying || reviewing}
>
{#snippet prefix()}
<Icon src={Check} mini size="16" />
{/snippet}
<Icon src={Check} mini size="16" />
{/snippet}
</Button>
</div>
</div>
+12 -10
View File
@@ -1,7 +1,7 @@
<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 { Label, Switch, toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
@@ -14,17 +14,19 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte'
interface Props {
data: PageData;
data: PageData
}
let { data }: Props = $props();
let { data }: Props = $props()
const formData: Omit<EditSite, 'auth'> | undefined = $state(data.site
? {
...data.site.site_view.local_site,
...data.site.site_view.site,
}
: undefined)
const formData: Omit<EditSite, 'auth'> | undefined = $state(
data.site
? {
...data.site.site_view.local_site,
...data.site.site_view.site,
}
: undefined,
)
async function save() {
if (!$profile?.jwt) return
+30 -31
View File
@@ -1,7 +1,7 @@
<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 Header from '$lib/components/ui/layout/pages/Header.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte'
@@ -9,7 +9,7 @@
import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.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 {
Button,
@@ -31,7 +31,7 @@
import { expoInOut, expoOut } from 'svelte/easing'
import { slide } from 'svelte/transition'
let { data = $bindable() } = $props();
let { data = $bindable() } = $props()
let blockInstance = $state({
instance: '',
@@ -58,12 +58,12 @@
const blockedInstances =
data.federated_instances.federated_instances.blocked.map(
(i) => i.domain
(i) => i.domain,
)
const allowedInstances =
data.federated_instances.federated_instances.allowed.map(
(i) => i.domain
(i) => i.domain,
)
if (blocked) blockedInstances.push(instance)
@@ -97,11 +97,11 @@
const blockedInstances =
data.federated_instances.federated_instances.blocked.map(
(i) => i.domain
(i) => i.domain,
)
const allowedInstances =
data.federated_instances.federated_instances.allowed.map(
(i) => i.domain
(i) => i.domain,
)
return await getClient().editSite({
@@ -166,7 +166,7 @@
run(() => {
if (csv) parseCsv(csv)
});
})
</script>
<svelte:head>
@@ -182,25 +182,24 @@
{#if data.site && data.federated_instances?.federated_instances?.blocked}
<FileInput preview={false} bind:files={csv}>
{#snippet button()}
<Button class="w-max" >
<Button class="w-max">
{#snippet prefix()}
<Icon src={Plus} mini size="18" />
{/snippet}
<Icon src={Plus} mini size="18" />
{/snippet}
{$t('routes.admin.federation.csv')}
</Button>
{/snippet}
{/snippet}
{#snippet choose()}
{''}
{/snippet}
{''}
{/snippet}
</FileInput>
<div class="flex flex-col md:flex-row gap-4">
<div class="flex-1 w-full max-h-[42rem] h-full flex flex-col gap-2">
<h2 class="font-bold text-lg">{$t('routes.admin.federation.blocked')}</h2>
<form
onsubmit={preventDefault(() =>
moderateInstance(blockInstance.instance, true))}
moderateInstance(blockInstance.instance, true),
)}
class="flex flex-row gap-2"
>
<TextInput
@@ -223,7 +222,7 @@
: ''}"
>
{#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
animate:flip={{ duration: 300, easing: expoOut }}
class="flex justify-between items-center first:pt-0 last:pb-0"
@@ -246,13 +245,13 @@
data.federated_instances.federated_instances.blocked =
data.federated_instances?.federated_instances?.blocked.filter(
(i) => i.id != instance.id
(i) => i.id != instance.id,
)
}}
>
{#snippet prefix()}
<Icon src={XMark} size="16" mini />
{/snippet}
<Icon src={XMark} size="16" mini />
{/snippet}
</Button>
</div>
{/each}
@@ -272,14 +271,13 @@
{#if allowInstance.instance || !(data.federated_instances.federated_instances.allowed?.length == 0)}
<Popover openOnHover placement="bottom-end">
{#snippet target()}
<Icon
<Icon
src={ExclamationTriangle}
solid
class="text-yellow-500"
size="20"
/>
{/snippet}
{/snippet}
<p class="font-normal">
{$t('routes.admin.federation.emptyAllow.description')}
</p>
@@ -288,7 +286,8 @@
</h2>
<form
onsubmit={preventDefault(() =>
moderateInstance(allowInstance.instance, false))}
moderateInstance(allowInstance.instance, false),
)}
class="flex flex-row gap-2"
>
<TextInput
@@ -307,7 +306,7 @@
<Material class="h-full overflow-auto" color="distinct">
<EditableList class="[&>*]:py-3 dark:!divide-zinc-800 ">
{#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
animate:flip={{ duration: 300, easing: expoOut }}
class="flex justify-between items-center first:pt-0 last:pb-0"
@@ -330,13 +329,13 @@
data.federated_instances.federated_instances.allowed =
data.federated_instances?.federated_instances?.allowed.filter(
(i) => i.id != instance.id
(i) => i.id != instance.id,
)
}}
>
{#snippet prefix()}
<Icon src={XMark} size="16" mini />
{/snippet}
<Icon src={XMark} size="16" mini />
{/snippet}
</Button>
</div>
{/each}
@@ -346,7 +345,7 @@
icon={Check}
title={$t('routes.admin.federation.emptyAllow.title')}
description={$t(
'routes.admin.federation.emptyAllow.description'
'routes.admin.federation.emptyAllow.description',
)}
/>
</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 { get } from 'svelte/store'
+14 -13
View File
@@ -1,7 +1,7 @@
<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 MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
@@ -14,9 +14,11 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte'
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 saving = $state(false)
@@ -60,11 +62,10 @@
</Header>
<EditableList
on:action={(e) => {
taglines.splice(
taglines.findIndex((i) => i == e.detail),
1
1,
)
// hack for reactivity
@@ -72,7 +73,7 @@
}}
>
{#snippet children({ action })}
{#each taglines as tagline}
{#each taglines as tagline}
<div class="flex py-3">
<Markdown source={tagline} inline />
@@ -83,8 +84,8 @@
</div>
</div>
{/each}
{/snippet}
</EditableList>
{/snippet}
</EditableList>
<form
class="flex flex-col mt-auto gap-2 w-full"
onsubmit={preventDefault(() => {
@@ -99,8 +100,8 @@
<Button size="lg" submit>
{#snippet prefix()}
<Icon src={Plus} size="16" mini />
{/snippet}
<Icon src={Plus} size="16" mini />
{/snippet}
{$t('common.add')}
</Button>
</form>
@@ -130,8 +131,8 @@
<Button size="lg" submit>
{#snippet prefix()}
<Icon src={Plus} size="16" mini />
{/snippet}
<Icon src={Plus} size="16" mini />
{/snippet}
{$t('common.add')}
</Button>
</form>
+11 -11
View File
@@ -1,7 +1,7 @@
<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 Placeholder from '$lib/components/ui/Placeholder.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte'
@@ -9,13 +9,13 @@
import { instance } from '$lib/instance.js'
import { getClient } from '$lib/lemmy.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 { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js'
let { data = $bindable() } = $props();
let { data = $bindable() } = $props()
let newAdmin: string = $state(''),
adding: boolean = $state(false)
@@ -33,7 +33,7 @@
getClient().addAdmin({
added: false,
person_id: id,
})
}),
)
if (result) {
@@ -48,9 +48,9 @@
<Header pageHeader>{$t('routes.admin.team.title')}</Header>
{#if data.site}
<EditableList on:action={(e) => removeAdmin(e.detail, false)}>
<EditableList on:action={(e) => removeAdmin(e.detail, false)}>
{#snippet children({ action })}
{#if data.site.admins.length <= 0}
{#if data.site.admins.length <= 0}
<Placeholder
icon={QuestionMarkCircle}
title={$t('routes.admin.team.empty.title')}
@@ -66,8 +66,8 @@
</div>
{/each}
{/if}
{/snippet}
</EditableList>
{/snippet}
</EditableList>
<form
class="flex flex-row items-center gap-2 mt-auto w-full"
onsubmit={preventDefault(() => {
@@ -98,8 +98,8 @@
/>
<Button loading={adding} disabled={adding} size="md" class="h-full" submit>
{#snippet prefix()}
<Icon src={Plus} mini size="16" />
{/snippet}
<Icon src={Plus} mini size="16" />
{/snippet}
{$t('common.add')}
</Button>
</form>
+21 -26
View File
@@ -1,12 +1,12 @@
<script lang="ts">
import { run } from 'svelte/legacy';
import { run } from 'svelte/legacy'
import { navigating, page } from '$app/stores'
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import Avatar from '$lib/components/ui/Avatar.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 { setSessionStorage } from '$lib/session.js'
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
@@ -27,18 +27,13 @@
} from 'svelte-hero-icons'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
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 { resumables } from '$lib/lemmy/item'
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data = $bindable() } = $props();
let community;
run(() => {
community = data.community.community_view
});
let { data = $bindable() } = $props()
let sidebar: boolean = $state(false)
@@ -46,14 +41,14 @@
if (browser)
setSessionStorage(
'lastSeenCommunity',
data.community.community_view.community
data.community.community_view.community,
)
resumables.add({
name: community.community.title,
name: data.community.community_view.community.title,
type: 'community',
url: $page.url.toString(),
avatar: community.community.icon,
avatar: data.community.community_view.community.icon,
})
})
@@ -68,12 +63,12 @@
{#if sidebar}
<Modal bind:open={sidebar}>
{#snippet title()}
<span >About</span>
{/snippet}
{#snippet customTitle()}
<span>About</span>
{/snippet}
<div>
<CommunityCard
bind:community_view={community}
bind:community_view={data.community.community_view}
moderators={data.community.moderators}
/>
</div>
@@ -83,18 +78,18 @@
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<Header pageHeader>
<CommunityHeader
bind:community={community.community}
bind:subscribed={community.subscribed}
bind:blocked={community.blocked}
bind:community={data.community.community_view.community}
bind:subscribed={data.community.community_view.subscribed}
blocked={data.community.community_view.blocked}
moderators={data.community.moderators}
counts={community.counts}
counts={data.community.community_view.counts}
class="w-full relative"
/>
{#snippet extended()}
<Sort selected={data.sort} />
{/snippet}
<Sort selected={data.sort} />
{/snippet}
</Header>
{#if community.blocked}
{#if data.community.community_view.blocked}
<Placeholder
icon={XMark}
title="Blocked"
@@ -102,8 +97,8 @@
>
<Button href="/profile/blocks">
{#snippet suffix()}
<Icon src={ArrowRight} size="16" mini />
{/snippet}
<Icon src={ArrowRight} size="16" mini />
{/snippet}
Blocked Communities
</Button>
</Placeholder>
@@ -118,7 +113,7 @@
{/if}
<svelte:element
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
this={settings.infiniteScroll ? 'noscript' : 'div'}
class="mt-auto"
>
<Pageination
+2 -2
View File
@@ -1,5 +1,5 @@
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 { get } from 'svelte/store'
@@ -11,7 +11,7 @@ export async function load({ params, fetch, url }) {
const sort: SortType =
(url.searchParams.get('sort') as SortType) ||
get(userSettings).defaultSort.sort
settings.defaultSort.sort
return await postFeed({
id: 'community',
+10 -8
View File
@@ -5,20 +5,22 @@
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
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'
interface Props {
data: PageData;
children?: import('svelte').Snippet;
data: PageData
children?: import('svelte').Snippet
}
let { data, children }: Props = $props();
let { data, children }: Props = $props()
let communityUrl = $derived(`/c/${fullCommunityName(
data.community.community_view.community.name,
data.community.community_view.community.actor_id
)}`)
let communityUrl = $derived(
`/c/${fullCommunityName(
data.community.community_view.community.name,
data.community.community_view.community.actor_id,
)}`,
)
</script>
<div class="flex flex-col gap-4 h-full">
@@ -1,12 +1,12 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { preventDefault } from 'svelte/legacy'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import EditableList from '$lib/components/ui/list/EditableList.svelte'
import { Icon, Plus, Trash } from 'svelte-hero-icons'
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 { client, getClient } from '$lib/lemmy.js'
import { flip } from 'svelte/animate'
@@ -15,10 +15,10 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte'
interface Props {
data: PageData;
data: PageData
}
let { data = $bindable() }: Props = $props();
let { data = $bindable() }: Props = $props()
let formData = $state({
newModerator: '',
@@ -109,7 +109,6 @@
<Header pageHeader>Moderators</Header>
<EditableList
on:action={(e) => {
toast({
content: `Are you sure you want to remove ${e.detail.name} as a moderator?`,
@@ -158,7 +157,7 @@
submit
>
{#snippet prefix()}
<Icon src={Plus} micro size="16" />
{/snippet} Add moderator
<Icon src={Plus} micro size="16" />
{/snippet} Add moderator
</Button>
</form>
+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 { redirect } from '@sveltejs/kit'
import { get } from 'svelte/store'
+12 -14
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { preventDefault } from 'svelte/legacy'
import { navigating, page } from '$app/stores'
import {
@@ -10,7 +10,7 @@
QuestionMarkCircle,
} from 'svelte-hero-icons'
import Pageination from '$lib/components/ui/Pageination.svelte'
import { searchParam } from '$lib/util.js'
import { searchParam } from '$lib/util.svelte.js'
import {
Button,
Material,
@@ -31,21 +31,18 @@
import { fly } from 'svelte/transition'
import { backOut, expoOut } from 'svelte/easing'
let { data } = $props();
let { data } = $props()
let search = $state(data.query || '')
let searchElement: HTMLInputElement = $state()
let searchElement: HTMLInputElement | undefined = $state()
let instance = ''
let virtualList: HTMLDivElement = $state()
let offset: number = $state(0)
let showTop =
$derived((data.query ?? '' != '') && data.communities.length > 0 && data.page == 1)
let showTop = $derived(
(data.query ?? '' != '') && data.communities.length > 0 && data.page == 1,
)
</script>
<svelte:window
bind:scrollY={offset}
onkeydown={(e) => {
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">
<form
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"
>
<TextInput
@@ -86,8 +84,8 @@
loading={$navigating != null}
>
{#snippet prefix()}
<Icon src={MagnifyingGlass} size="16" micro />
{/snippet}
<Icon src={MagnifyingGlass} size="16" micro />
{/snippet}
</Button>
</form>
</Tabs>
@@ -149,7 +147,7 @@
{/if}
{#if data.communities}
{@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)}
<div
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 { client, getClient } from '$lib/lemmy.js'
import {
+5 -5
View File
@@ -1,15 +1,15 @@
<script lang="ts">
import { getClient } from '$lib/lemmy.js'
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'
interface Props {
community?: CommunityView | undefined;
children?: import('svelte').Snippet<[any]>;
community?: CommunityView | undefined
children?: import('svelte').Snippet<[any]>
}
let { community = undefined, children }: Props = $props();
let { community = undefined, children }: Props = $props()
let subscribing = $state(false)
@@ -38,4 +38,4 @@
}
</script>
{@render children?.({ subscribe, subscribing, })}
{@render children?.({ subscribe, subscribing })}
+8 -6
View File
@@ -1,15 +1,17 @@
<script lang="ts">
import { goto } from '$app/navigation'
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 { getSessionStorage, setSessionStorage } from '$lib/session.js'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data = {
crosspost: false,
} } = $props();
let {
data = {
crosspost: false,
},
} = $props()
onMount(() => {
if (!$profile?.jwt) {
@@ -49,9 +51,9 @@
on:submit={(e) => goto(`/post/${e.detail.post.id}`)}
>
{#snippet formtitle()}
<Header class="text-3xl font-bold" pageHeader>
<Header class="text-3xl font-bold" pageHeader>
{$t('routes.createPost')}
</Header>
{/snippet}
{/snippet}
</PostForm>
</div>
+2 -2
View File
@@ -13,10 +13,10 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
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 { fly } from 'svelte/transition'
import { searchParam } from '$lib/util.js'
import { searchParam } from '$lib/util.svelte.js'
import { Button, Select } from 'mono-svelte'
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.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 { getClient } from '$lib/lemmy.js'
import {
+25 -23
View File
@@ -2,7 +2,7 @@
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import { getClient } from '$lib/lemmy.js'
import { notifications, profile } from '$lib/auth.js'
import { notifications, profile } from '$lib/auth.svelte.js'
import {
ArrowUturnLeft,
ArrowUturnUp,
@@ -29,10 +29,10 @@
import Avatar from '$lib/components/ui/Avatar.svelte'
interface Props {
item: InboxItem;
item: InboxItem
}
let { item = $bindable() }: Props = $props();
let { item = $bindable() }: Props = $props()
let replying = $state(false)
let reply = ''
@@ -79,7 +79,7 @@
<Expandable open icon={false}>
{#snippet title()}
<div class="flex flex-row gap-2 items-center w-full" >
<div class="flex flex-row gap-2 items-center w-full">
<Avatar
url={item.creator.avatar}
circle={false}
@@ -141,8 +141,8 @@
class="flex-shrink-0"
>
{#snippet prefix()}
<Icon src={item.read ? EyeSlash : Eye} size="16" micro />
{/snippet}
<Icon src={item.read ? EyeSlash : Eye} size="16" micro />
{/snippet}
{item.read
? $t('post.actions.more.markUnread')
: $t('post.actions.more.markRead')}
@@ -161,7 +161,7 @@
</div>
{/snippet}
{#snippet extended()}
<div class="flex gap-2 w-full md:hidden mt-1">
<div class="flex gap-2 w-full md:hidden mt-1">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
@@ -174,33 +174,35 @@
rounding="pill"
>
{#snippet prefix()}
<Icon src={item.read ? EyeSlash : Eye} size="16" micro />
{/snippet}
<Icon src={item.read ? EyeSlash : Eye} size="16" micro />
{/snippet}
{item.read
? $t('post.actions.more.markUnread')
: $t('post.actions.more.markRead')}
</Button>
{#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')}
</Button>
{/if}
</div>
{/snippet}
{#snippet content()}
{#if item.type == 'comment_reply' || item.type == 'person_mention'}
<CommentItem
comment={item.item}
community={false}
view="cozy"
meta={false}
class="pt-0 pb-0"
/>
{:else}
<PrivateMessage message={item.item} meta={false} />
{/if}
{#if item.type == 'comment_reply' || item.type == 'person_mention'}
<CommentItem
comment={item.item}
community={false}
view="cozy"
meta={false}
class="pt-0 pb-0"
/>
{:else}
<PrivateMessage message={item.item} meta={false} />
{/if}
{/snippet}
</Expandable>
+5 -5
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/auth'
import { profile } from '$lib/auth.svelte.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { publishedToDate } from '$lib/components/util/date.js'
@@ -35,11 +35,11 @@
}
function conversationPreviews(
conversations: PrivateMessageView[]
conversations: PrivateMessageView[],
): ConversationPreview[] {
const deduplicated = filterDuplicates(
conversations.toReversed(),
(i) => i.creator.id
(i) => i.creator.id,
)
return deduplicated.map((i) => ({
@@ -51,7 +51,7 @@
}))
}
let { data } = $props();
let { data } = $props()
</script>
<Header pageHeader>
@@ -64,7 +64,7 @@
{:then data}
{@const conversations = data.private_messages}
{@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
+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 { get } from 'svelte/store'
+7 -7
View File
@@ -1,8 +1,8 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { preventDefault } from 'svelte/legacy'
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 { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
import {
@@ -18,7 +18,7 @@
QuestionMarkCircle,
UserCircle,
} 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 { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
@@ -30,11 +30,11 @@
import { page } from '$app/stores'
interface Props {
ref?: string;
children?: import('svelte').Snippet;
ref?: string
children?: import('svelte').Snippet
}
let { ref = '/', children }: Props = $props();
let { ref = '/', children }: Props = $props()
let data = $state({
instance: DEFAULT_INSTANCE_URL,
@@ -80,7 +80,7 @@
'incorrect_login' +
(data.attempts == 0 || data.attempts >= 12
? ''
: `_${data.attempts + 1}`)
: `_${data.attempts + 1}`),
)
: errorMessage(error),
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