format: whole project

This commit is contained in:
James Xylight committed 2025-02-04 16:23:31 -08:00
1 parent b883b5f6e0
commit 80269cf275
78 files changed
+367 -389

No files matched your search

@@ -1,22 +1,22 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { DocumentPlus, Icon } from 'svelte-hero-icons' import { DocumentPlus, Icon } from 'svelte-hero-icons'
import { Label, TextInput } from 'mono-svelte' import { Label, TextInput } from 'mono-svelte'
interface Props { interface Props {
accept?: string; accept?: string
files?: FileList | undefined | null; files?: FileList | undefined | null
label?: string | undefined; label?: string | undefined
url?: string | undefined; url?: string | undefined
} }
let { let {
accept = 'image/*', accept = 'image/*',
files = $bindable(null), files = $bindable(null),
label = undefined, label = undefined,
url = undefined url = undefined,
}: Props = $props(); }: Props = $props()
let dragover = $state(false) let dragover = $state(false)
@@ -38,7 +38,7 @@ export function buildCommentsTree(
comment_view, comment_view,
children: [], children: [],
depth: depth, depth: depth,
expanded: true expanded: true,
} }
min_depth = Math.min(min_depth, depth) min_depth = Math.min(min_depth, depth)
if (filter(comment_view)) { if (filter(comment_view)) {
+8 -10
View File
@@ -1,14 +1,13 @@
<script lang="ts"> <script lang="ts">
import { Icon, type IconSource } from 'svelte-hero-icons' import { Icon, type IconSource } from 'svelte-hero-icons'
interface Props { interface Props {
icon?: IconSource | undefined; icon?: IconSource | undefined
title: string; title: string
description?: string | undefined; description?: string | undefined
center?: boolean; center?: boolean
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { let {
@@ -17,9 +16,8 @@
description = undefined, description = undefined,
center = false, center = false,
class: clazz = '', class: clazz = '',
children children,
}: Props = $props(); }: Props = $props()
</script> </script>
<div <div
+4 -4
View File
@@ -1,20 +1,20 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'; import { run } from 'svelte/legacy'
import { expoOut } from 'svelte/easing' import { expoOut } from 'svelte/easing'
import { tweened } from 'svelte/motion' import { tweened } from 'svelte/motion'
interface Props { interface Props {
progress?: number; progress?: number
} }
let { progress = 0 }: Props = $props(); let { progress = 0 }: Props = $props()
let tween = tweened(progress, { easing: expoOut }) let tween = tweened(progress, { easing: expoOut })
run(() => { run(() => {
tween.set(progress) tween.set(progress)
}); })
</script> </script>
<div <div
+5 -9
View File
@@ -1,18 +1,14 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
small?: boolean; small?: boolean
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
[key: string]: any [key: string]: any
} }
let { small = false, class: clazz = '', children, ...rest }: Props = $props(); let { small = false, class: clazz = '', children, ...rest }: Props = $props()
</script> </script>
<span <span {...rest} class="{!small ? 'text-lg' : 'text-xs'} font-semibold {clazz}">
{...rest}
class="{!small ? 'text-lg' : 'text-xs'} font-semibold {clazz}"
>
{@render children?.()} {@render children?.()}
</span> </span>
+3 -4
View File
@@ -1,11 +1,10 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { class: clazz = '', children }: Props = $props(); let { class: clazz = '', children }: Props = $props()
</script> </script>
<aside <aside
@@ -77,7 +77,6 @@
<script lang="ts"> <script lang="ts">
import { settings } from '$lib/settings.svelte.js' import { settings } from '$lib/settings.svelte.js'
import { themeVars } from '$lib/ui/colors' import { themeVars } from '$lib/ui/colors'
import { routes } from '$lib/util.svelte.js'
import { writable, type Readable, type Writable } from 'svelte/store' import { writable, type Readable, type Writable } from 'svelte/store'
interface Props { interface Props {
@@ -102,9 +101,6 @@
...rest ...rest
}: Props = $props() }: Props = $props()
let title = $derived(
route ? routes[(route.id as keyof typeof routes) ?? ''] : '',
)
let sidePadding = $derived( let sidePadding = $derived(
calculatePadding($dockProps.noGap, $dockProps.top, false), calculatePadding($dockProps.noGap, $dockProps.top, false),
) )
@@ -147,7 +143,6 @@
: `border-slate-200 dark:border-zinc-800 shadow-2xl : `border-slate-200 dark:border-zinc-800 shadow-2xl
bg-white/50 dark:bg-zinc-950/70` bg-white/50 dark:bg-zinc-950/70`
}`, }`,
title,
style: 'transition: border-radius 250ms;', style: 'transition: border-radius 250ms;',
})} })}
</div> </div>
@@ -338,16 +338,14 @@ export function getGroups(
default: t.get('filter.view.compact'), default: t.get('filter.view.compact'),
}), }),
icon: ViewColumns, icon: ViewColumns,
handle: () => handle: () => (settings.view = 'compact'),
settings.view = 'compact'
}, },
{ {
name: t.get('nav.commands.setViewTo', { name: t.get('nav.commands.setViewTo', {
default: t.get('filter.view.cozy'), default: t.get('filter.view.cozy'),
}), }),
icon: ViewColumns, icon: ViewColumns,
handle: () => handle: () => (settings.view = 'cozy'),
settings.view = 'cozy'
}, },
], ],
}, },
+4 -5
View File
@@ -6,14 +6,13 @@
</script> </script>
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
wrap?: keyof typeof wrapClass; wrap?: keyof typeof wrapClass
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { wrap = 'wrap', class: clazz = '', children }: Props = $props(); let { wrap = 'wrap', class: clazz = '', children }: Props = $props()
let classes = $derived(`${wrapClass[wrap]} ${clazz ?? ''}`) let classes = $derived(`${wrapClass[wrap]} ${clazz ?? ''}`)
</script> </script>
+6 -10
View File
@@ -1,12 +1,11 @@
<script lang="ts"> <script lang="ts">
import { locale } from '$lib/translations' import { locale } from '$lib/translations'
interface Props { interface Props {
number: number; number: number
locale?: string; locale?: string
options?: Intl.NumberFormatOptions; options?: Intl.NumberFormatOptions
class?: string; class?: string
} }
let { let {
@@ -15,11 +14,8 @@
options = { options = {
notation: 'compact', notation: 'compact',
}, },
class: clazz = '' class: clazz = '',
}: Props = $props(); }: Props = $props()
</script> </script>
<span class={clazz ?? ''}> <span class={clazz ?? ''}>
+8 -9
View File
@@ -3,7 +3,7 @@
date: Date, date: Date,
options: Intl.RelativeTimeFormatOptions, options: Intl.RelativeTimeFormatOptions,
locale?: string, locale?: string,
relativeTo?: Date relativeTo?: Date,
) { ) {
try { try {
const now = relativeTo?.getTime() ?? Date.now() const now = relativeTo?.getTime() ?? Date.now()
@@ -41,7 +41,6 @@
<script lang="ts"> <script lang="ts">
import { locale } from '$lib/translations' import { locale } from '$lib/translations'
const toLocaleDateString = (date: Date): string => { const toLocaleDateString = (date: Date): string => {
try { try {
return date.toLocaleString() return date.toLocaleString()
@@ -51,11 +50,11 @@
} }
interface Props { interface Props {
date: Date; date: Date
relativeTo?: Date | undefined; relativeTo?: Date | undefined
options?: Intl.RelativeTimeFormatOptions; options?: Intl.RelativeTimeFormatOptions
style?: string; style?: string
class?: string; class?: string
} }
let { let {
@@ -66,8 +65,8 @@
style: 'narrow', style: 'narrow',
}, },
style = '', style = '',
class: clazz = '' class: clazz = '',
}: Props = $props(); }: Props = $props()
let dateTime = $derived(toLocaleDateString(date)) let dateTime = $derived(toLocaleDateString(date))
</script> </script>
@@ -3,17 +3,19 @@
import { Modal } from 'mono-svelte' import { Modal } from 'mono-svelte'
interface Props { interface Props {
object: any; object: any
open?: boolean; open?: boolean
title?: import('svelte').Snippet; title?: import('svelte').Snippet
} }
let { object, open = $bindable(false), title }: Props = $props(); let { object, open = $bindable(false), title }: Props = $props()
</script> </script>
<Modal bind:open> <Modal bind:open>
{#snippet title()} {#snippet title()}
<span >{#if title}{@render title()}{:else}Debug{/if}</span> <span>
{#if title}{@render title()}{:else}Debug{/if}
</span>
{/snippet} {/snippet}
<DebugTree {object} isParent={true} /> <DebugTree {object} isParent={true} />
</Modal> </Modal>
@@ -1,11 +1,11 @@
<script lang="ts"> <script lang="ts">
import DebugTree from './DebugTree.svelte'; import DebugTree from './DebugTree.svelte'
interface Props { interface Props {
object: any; object: any
isParent?: boolean; isParent?: boolean
} }
let { object, isParent = false }: Props = $props(); let { object, isParent = false }: Props = $props()
</script> </script>
<ul class:ml-4={!isParent} class="leading-8"> <ul class:ml-4={!isParent} class="leading-8">
+31 -21
View File
@@ -1,24 +1,28 @@
<script lang="ts"> <script lang="ts">
import { Badge, Modal } from "mono-svelte" import { Badge, Modal } from 'mono-svelte'
import type { Data } from "./fediseer" import type { Data } from './fediseer'
import SectionTitle from "$lib/components/ui/SectionTitle.svelte" import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import LabelStat from "$lib/components/ui/LabelStat.svelte" import LabelStat from '$lib/components/ui/LabelStat.svelte'
import Expandable from "$lib/components/ui/Expandable.svelte" import Expandable from '$lib/components/ui/Expandable.svelte'
interface Props { interface Props {
open?: boolean; open?: boolean
data: Data; data: Data
} }
let { open = $bindable(false), data }: Props = $props(); let { open = $bindable(false), data }: Props = $props()
</script> </script>
<Modal bind:open title="Fediseer"> <Modal bind:open title="Fediseer">
<div class="flex flex-col [&>*]:py-2 divide-y divide-slate-300 dark:divide-zinc-800"> <div
class="flex flex-col [&>*]:py-2 divide-y divide-slate-300 dark:divide-zinc-800"
>
<Expandable class="flex flex-col gap-4"> <Expandable class="flex flex-col gap-4">
{#snippet title()} {#snippet title()}
<SectionTitle class="flex gap-2 items-center flex-row"> <SectionTitle class="flex gap-2 items-center flex-row">
Endorsements <Badge class="w-max h-max" color="green-subtle">{data.endorsements.instances.length}</Badge> Endorsements <Badge class="w-max h-max" color="green-subtle">
{data.endorsements.instances.length}
</Badge>
</SectionTitle> </SectionTitle>
{/snippet} {/snippet}
<div class="flex flex-row gap-6 flex-wrap"> <div class="flex flex-row gap-6 flex-wrap">
@@ -28,8 +32,8 @@
labelClass="!text-sm" labelClass="!text-sm"
label={instance.domain} label={instance.domain}
formatted={false} formatted={false}
content={instance.endorsement_reasons?.[0] || '👍'}> content={instance.endorsement_reasons?.[0] || '👍'}
</LabelStat> ></LabelStat>
</div> </div>
{/each} {/each}
</div> </div>
@@ -37,7 +41,9 @@
<Expandable class="flex flex-col gap-4"> <Expandable class="flex flex-col gap-4">
{#snippet title()} {#snippet title()}
<SectionTitle class="flex gap-2 items-center flex-row"> <SectionTitle class="flex gap-2 items-center flex-row">
Guarantees <Badge class="w-max h-max" color="green-subtle">{data.guarantees.instances.length}</Badge> Guarantees <Badge class="w-max h-max" color="green-subtle">
{data.guarantees.instances.length}
</Badge>
</SectionTitle> </SectionTitle>
{/snippet} {/snippet}
<div class="flex flex-row gap-6 flex-wrap"> <div class="flex flex-row gap-6 flex-wrap">
@@ -47,8 +53,8 @@
labelClass="!text-sm" labelClass="!text-sm"
label={instance.domain} label={instance.domain}
formatted={false} formatted={false}
content={instance.guarantee_reasons?.[0] || '👍'}> content={instance.guarantee_reasons?.[0] || '👍'}
</LabelStat> ></LabelStat>
</div> </div>
{/each} {/each}
</div> </div>
@@ -56,7 +62,9 @@
<Expandable class="flex flex-col gap-4"> <Expandable class="flex flex-col gap-4">
{#snippet title()} {#snippet title()}
<SectionTitle class="flex gap-2 items-center flex-row"> <SectionTitle class="flex gap-2 items-center flex-row">
Censures <Badge class="w-max h-max" color="red-subtle">{data.censures.instances.length}</Badge> Censures <Badge class="w-max h-max" color="red-subtle">
{data.censures.instances.length}
</Badge>
</SectionTitle> </SectionTitle>
{/snippet} {/snippet}
<div class="flex flex-row gap-6 flex-wrap"> <div class="flex flex-row gap-6 flex-wrap">
@@ -66,8 +74,8 @@
labelClass="!text-sm" labelClass="!text-sm"
label={instance.domain} label={instance.domain}
formatted={false} formatted={false}
content={instance.censure_reasons?.[0] || '👎'}> content={instance.censure_reasons?.[0] || '👎'}
</LabelStat> ></LabelStat>
</div> </div>
{/each} {/each}
</div> </div>
@@ -75,7 +83,9 @@
<Expandable class="flex flex-col gap-4"> <Expandable class="flex flex-col gap-4">
{#snippet title()} {#snippet title()}
<SectionTitle class="flex gap-2 items-center flex-row"> <SectionTitle class="flex gap-2 items-center flex-row">
Hesitations <Badge class="w-max h-max" color="red-subtle">{data.hesitations.instances.length}</Badge> Hesitations <Badge class="w-max h-max" color="red-subtle">
{data.hesitations.instances.length}
</Badge>
</SectionTitle> </SectionTitle>
{/snippet} {/snippet}
<div class="flex flex-row gap-6 flex-wrap"> <div class="flex flex-row gap-6 flex-wrap">
@@ -85,8 +95,8 @@
labelClass="!text-sm" labelClass="!text-sm"
label={instance.domain} label={instance.domain}
formatted={false} formatted={false}
content={instance.hesitation_reasons?.[0] || '👎'}> content={instance.hesitation_reasons?.[0] || '👎'}
</LabelStat> ></LabelStat>
</div> </div>
{/each} {/each}
</div> </div>
+16 -6
View File
@@ -41,12 +41,22 @@ class Fediseer {
} }
async getInstanceInfo(domain: string): Promise<Data> { async getInstanceInfo(domain: string): Promise<Data> {
const [endorsements, hesitations, guarantees, censures] = await Promise.all([ const [endorsements, hesitations, guarantees, censures] = await Promise.all(
fetch(`${this.url}/v1/endorsements/${domain}`).then(r => r.json()) as Promise<Endorsements>, [
fetch(`${this.url}/v1/hesitations/${domain}`).then(r => r.json()) as Promise<Hesitations>, fetch(`${this.url}/v1/endorsements/${domain}`).then((r) =>
fetch(`${this.url}/v1/guarantees/${domain}`).then(r => r.json()) as Promise<Guarantees>, r.json(),
fetch(`${this.url}/v1/censures/${domain}`).then(r => r.json()) as Promise<Censures> ) as Promise<Endorsements>,
]) fetch(`${this.url}/v1/hesitations/${domain}`).then((r) =>
r.json(),
) as Promise<Hesitations>,
fetch(`${this.url}/v1/guarantees/${domain}`).then((r) =>
r.json(),
) as Promise<Guarantees>,
fetch(`${this.url}/v1/censures/${domain}`).then((r) =>
r.json(),
) as Promise<Censures>,
],
)
return { endorsements, hesitations, guarantees, censures } return { endorsements, hesitations, guarantees, censures }
} }
+16 -13
View File
@@ -3,10 +3,13 @@ enum SwipeDirection {
Down = 'down', Down = 'down',
Left = 'left', Left = 'left',
Right = 'right', Right = 'right',
None = 'none' None = 'none',
} }
export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => any) { export function swipeGesture(
node: HTMLElement,
swipe: (dir: SwipeDirection) => any,
) {
let touchstartX = 0 let touchstartX = 0
let touchstartY = 0 let touchstartY = 0
let touchendX = 0 let touchendX = 0
@@ -20,7 +23,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
// @ts-ignore // @ts-ignore
touchstartY = event?.screenY touchstartY = event?.screenY
}, },
false false,
) )
node?.addEventListener( node?.addEventListener(
@@ -31,7 +34,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
// @ts-ignore // @ts-ignore
touchstartY = event?.screenY touchstartY = event?.screenY
}, },
false false,
) )
node?.addEventListener( node?.addEventListener(
@@ -43,7 +46,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
touchendY = event.screenY touchendY = event.screenY
return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY)) return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY))
}, },
false false,
) )
node?.addEventListener( node?.addEventListener(
@@ -55,7 +58,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
touchendY = event.screenY touchendY = event.screenY
return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY)) return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY))
}, },
false false,
) )
} }
@@ -63,26 +66,26 @@ function swipeDir(
touchStartX: number, touchStartX: number,
touchStartY: number, touchStartY: number,
touchEndX: number, touchEndX: number,
touchEndY: number touchEndY: number,
): SwipeDirection { ): SwipeDirection {
const deltaX = touchEndX - touchStartX; const deltaX = touchEndX - touchStartX
const deltaY = touchEndY - touchStartY; const deltaY = touchEndY - touchStartY
// Define a threshold for the minimum swipe distance // Define a threshold for the minimum swipe distance
const minSwipeDistance = 10; // Adjust this value as needed const minSwipeDistance = 10 // Adjust this value as needed
// Check the absolute difference between deltaX and deltaY // Check the absolute difference between deltaX and deltaY
if (Math.abs(deltaX) >= Math.abs(deltaY)) { if (Math.abs(deltaX) >= Math.abs(deltaY)) {
// Horizontal swipe // Horizontal swipe
if (Math.abs(deltaX) >= minSwipeDistance) { if (Math.abs(deltaX) >= minSwipeDistance) {
return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left; return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left
} }
} else { } else {
// Vertical swipe // Vertical swipe
if (Math.abs(deltaY) >= minSwipeDistance) { if (Math.abs(deltaY) >= minSwipeDistance) {
return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up; return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up
} }
} }
return SwipeDirection.None; return SwipeDirection.None
} }
+6 -6
View File
@@ -25,12 +25,12 @@ async function customFetch(
func: func:
| (( | ((
input: RequestInfo | URL, input: RequestInfo | URL,
init?: RequestInit | undefined init?: RequestInit | undefined,
) => Promise<Response>) ) => Promise<Response>)
| undefined, | undefined,
input: RequestInfo | URL, input: RequestInfo | URL,
init?: RequestInit | undefined, init?: RequestInit | undefined,
auth?: string auth?: string,
): Promise<Response> { ): Promise<Response> {
const f = func ? func : fetch const f = func ? func : fetch
@@ -63,7 +63,7 @@ export function client({
instanceURL?: string instanceURL?: string
func?: ( func?: (
input: RequestInfo | URL, input: RequestInfo | URL,
init?: RequestInit | undefined init?: RequestInit | undefined,
) => Promise<Response> ) => Promise<Response>
auth?: string auth?: string
} = {}) { } = {}) {
@@ -84,9 +84,9 @@ export function getClient(
instanceURL?: string, instanceURL?: string,
func?: ( func?: (
input: RequestInfo | URL, input: RequestInfo | URL,
init?: RequestInit | undefined init?: RequestInit | undefined,
) => Promise<Response>, ) => Promise<Response>,
auth?: string auth?: string,
): LemmyHttp { ): LemmyHttp {
return client({ instanceURL, func, auth }) return client({ instanceURL, func, auth })
} }
@@ -107,7 +107,7 @@ export async function validateInstance(instance: string): Promise<boolean> {
export function mayBeIncompatible( export function mayBeIncompatible(
minVersion: string, minVersion: string,
availableVersion: string availableVersion: string,
) { ) {
if (minVersion.valueOf() === availableVersion.valueOf()) return false if (minVersion.valueOf() === availableVersion.valueOf()) return false
+5 -5
View File
@@ -20,7 +20,7 @@ export interface ContentView {
} }
const isSubmissionView = ( const isSubmissionView = (
item: SubmissionView | ContentView item: SubmissionView | ContentView,
): item is SubmissionView => !('type' in item) ): item is SubmissionView => !('type' in item)
const isSubmission = (item: Submission | ContentView): item is Submission => const isSubmission = (item: Submission | ContentView): item is Submission =>
@@ -63,7 +63,7 @@ export const contentItem = (item: Submission): ContentView => {
export async function save( export async function save(
item: ContentView | SubmissionView, item: ContentView | SubmissionView,
save: boolean, save: boolean,
jwt: string jwt: string,
): Promise<boolean> { ): Promise<boolean> {
if (isSubmissionView(item)) item = contentView(item) if (isSubmissionView(item)) item = contentView(item)
@@ -88,7 +88,7 @@ export async function save(
export async function deleteItem( export async function deleteItem(
item: ContentView | SubmissionView, item: ContentView | SubmissionView,
deleted: boolean, deleted: boolean,
jwt: string jwt: string,
): Promise<boolean> { ): Promise<boolean> {
if (isSubmissionView(item)) item = contentView(item) if (isSubmissionView(item)) item = contentView(item)
@@ -113,7 +113,7 @@ export async function deleteItem(
export async function vote( export async function vote(
item: ContentView | Submission, item: ContentView | Submission,
vote: number, vote: number,
jwt: string jwt: string,
): Promise<{ upvotes: number; downvotes: number; score: number }> { ): Promise<{ upvotes: number; downvotes: number; score: number }> {
if (isSubmission(item)) item = contentItem(item) if (isSubmission(item)) item = contentItem(item)
@@ -138,7 +138,7 @@ export async function vote(
export async function markAsRead( export async function markAsRead(
item: ContentView | Submission, item: ContentView | Submission,
read: boolean, read: boolean,
jwt: string jwt: string,
): Promise<boolean> { ): Promise<boolean> {
if (isSubmission(item)) item = contentItem(item) if (isSubmission(item)) item = contentItem(item)
+2 -2
View File
@@ -25,7 +25,7 @@ export const generalizeCommentReply = (item: CommentReplyView): InboxItem => ({
}) })
export const generalizePersonMention = ( export const generalizePersonMention = (
item: PersonMentionView item: PersonMentionView,
): InboxItem => ({ ): InboxItem => ({
type: 'person_mention', type: 'person_mention',
id: item.person_mention.id, id: item.person_mention.id,
@@ -38,7 +38,7 @@ export const generalizePersonMention = (
}) })
export const generalizePrivateMessage = ( export const generalizePrivateMessage = (
item: PrivateMessageView item: PrivateMessageView,
): InboxItem => ({ ): InboxItem => ({
type: 'private_message', type: 'private_message',
id: item.private_message.id, id: item.private_message.id,
+8 -5
View File
@@ -67,7 +67,7 @@ export const isCommentReport = (item: Result): item is CommentReportView =>
'comment_report' in item 'comment_report' in item
export const isPrivateMessageReport = ( export const isPrivateMessageReport = (
item: Result item: Result,
): item is PrivateMessageReportView => 'private_message_report' in item ): item is PrivateMessageReportView => 'private_message_report' in item
export interface ResumableItem { export interface ResumableItem {
@@ -86,15 +86,18 @@ function resumableStore(limit: number = 10) {
const { subscribe, set, update } = writable<ResumableItem[]>([]) const { subscribe, set, update } = writable<ResumableItem[]>([])
return { return {
subscribe, set, update, subscribe,
set,
update,
add: (item: ResumableItem) => { add: (item: ResumableItem) => {
update(resumables => { update((resumables) => {
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item))) return resumables if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item)))
return resumables
resumables.unshift(item) resumables.unshift(item)
if (resumables.length > limit) resumables.pop() if (resumables.length > limit) resumables.pop()
return resumables return resumables
}) })
} },
} }
} }
+2 -2
View File
@@ -12,7 +12,7 @@ import { get, writable } from 'svelte/store'
export const shouldReload = ( export const shouldReload = (
cache: PostFeed | undefined, cache: PostFeed | undefined,
url: URL, url: URL,
instance: string instance: string,
): boolean => ): boolean =>
cache?.instance != instance || cache?.url.toString() != url.toString() cache?.instance != instance || cache?.url.toString() != url.toString()
@@ -27,7 +27,7 @@ export async function postFeed(args: {
url: URL url: URL
fetch?: ( fetch?: (
input: RequestInfo | URL, input: RequestInfo | URL,
init?: RequestInit | undefined init?: RequestInit | undefined,
) => Promise<Response> ) => Promise<Response>
}) { }) {
const feed = get(postFeeds)[args.id] const feed = get(postFeeds)[args.id]
+2 -2
View File
@@ -37,7 +37,7 @@ interface BaseReport {
} }
export const generalizeCommentReport = ( export const generalizeCommentReport = (
report: CommentReportView report: CommentReportView,
): ReportView => ({ ): ReportView => ({
creator: report.creator, creator: report.creator,
item: { item: {
@@ -77,7 +77,7 @@ export const generalizePostReport = (report: PostReportView): ReportView => ({
}) })
export const generalizePrivateMessageReport = ( export const generalizePrivateMessageReport = (
report: PrivateMessageReportView report: PrivateMessageReportView,
): ReportView => ({ ): ReportView => ({
creator: report.creator, creator: report.creator,
item: report.private_message, item: report.private_message,
+1 -1
View File
@@ -20,7 +20,7 @@ export const isBlocked = (me: MyUserInfo, user: number) =>
export const addSubscription = ( export const addSubscription = (
community: Community, community: Community,
subscribe: boolean = true subscribe: boolean = true,
) => { ) => {
const p = get(profile) const p = get(profile)
+8 -11
View File
@@ -1,5 +1,4 @@
<script lang="ts"> <script lang="ts">
const badgeColor = { const badgeColor = {
red: 'bg-red-500 text-white ring-transparent', red: 'bg-red-500 text-white ring-transparent',
green: 'bg-green-500 text-white dark:text-black ring-transparent', green: 'bg-green-500 text-white dark:text-black ring-transparent',
@@ -31,15 +30,14 @@
type BadgeColor = keyof typeof badgeColor type BadgeColor = keyof typeof badgeColor
type BadgeRoundness = keyof typeof badgeRoundness type BadgeRoundness = keyof typeof badgeRoundness
interface Props { interface Props {
label?: string; label?: string
color?: BadgeColor; color?: BadgeColor
rounding?: BadgeRoundness; rounding?: BadgeRoundness
allowIconOnly?: boolean; allowIconOnly?: boolean
class?: string; class?: string
icon?: import('svelte').Snippet; icon?: import('svelte').Snippet
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { let {
@@ -51,8 +49,7 @@
icon, icon,
children, children,
...rest ...rest
}: Props = $props(); }: Props = $props()
</script> </script>
<span <span
+8 -9
View File
@@ -3,11 +3,11 @@
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
interface Props { interface Props {
open?: boolean; open?: boolean
class?: string; class?: string
summary?: import('svelte').Snippet<[any]>; summary?: import('svelte').Snippet<[any]>
extended?: import('svelte').Snippet; extended?: import('svelte').Snippet
children?: import('svelte').Snippet<[any]>; children?: import('svelte').Snippet<[any]>
[key: string]: any [key: string]: any
} }
@@ -18,18 +18,17 @@
extended, extended,
children, children,
...rest ...rest
}: Props = $props(); }: Props = $props()
</script> </script>
<div {...rest} class={clazz}> <div {...rest} class={clazz}>
<button onclick={() => (open = !open)} class="w-full"> <button onclick={() => (open = !open)} class="w-full">
{@render summary?.({ open, })} {@render summary?.({ open })}
</button> </button>
{@render extended?.()} {@render extended?.()}
{#if open} {#if open}
<div transition:slide={{ axis: 'y', easing: expoOut, duration: 300 }}> <div transition:slide={{ axis: 'y', easing: expoOut, duration: 300 }}>
{@render children?.({ open, })} {@render children?.({ open })}
</div> </div>
{/if} {/if}
</div> </div>
+18 -10
View File
@@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
defaultValue?: boolean; defaultValue?: boolean
checked?: boolean | undefined; checked?: boolean | undefined
inlineDescription?: boolean; inlineDescription?: boolean
children?: import('svelte').Snippet; children?: import('svelte').Snippet
description?: import('svelte').Snippet; description?: import('svelte').Snippet
} }
let { let {
@@ -12,16 +12,24 @@
checked = $bindable(defaultValue), checked = $bindable(defaultValue),
inlineDescription = false, inlineDescription = false,
children, children,
description description,
}: Props = $props(); }: Props = $props()
</script> </script>
<label class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"> <label
class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"
>
<input type="checkbox" bind:checked class="cursor-pointer" /> <input type="checkbox" bind:checked class="cursor-pointer" />
<div class="inline-flex {inlineDescription ? 'flex-row' : 'flex-col'} font-medium gap-1"> <div
class="inline-flex {inlineDescription
? 'flex-row'
: 'flex-col'} font-medium gap-1"
>
{@render children?.()} {@render children?.()}
{#if description} {#if description}
<span class="font-normal text-slate-600 dark:text-zinc-400">{@render description?.()}</span> <span class="font-normal text-slate-600 dark:text-zinc-400">
{@render description?.()}
</span>
{/if} {/if}
</div> </div>
</label> </label>
+5 -8
View File
@@ -1,14 +1,12 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
for?: string | undefined; for?: string | undefined
/** /**
* The `text` prop will take precedence over the slot. * The `text` prop will take precedence over the slot.
*/ */
text?: string | undefined; text?: string | undefined
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
[key: string]: any [key: string]: any
} }
@@ -18,8 +16,7 @@
class: clazz = '', class: clazz = '',
children, children,
...rest ...rest
}: Props = $props(); }: Props = $props()
</script> </script>
<svelte:element <svelte:element
+10 -10
View File
@@ -1,19 +1,19 @@
<script lang="ts"> <script lang="ts">
import { createBubbler } from 'svelte/legacy'; import { createBubbler } from 'svelte/legacy'
const bubble = createBubbler(); const bubble = createBubbler()
import { generateID } from '../forms/helper.js' import { generateID } from '../forms/helper.js'
type T = $$Generic type T = $$Generic
interface Props { interface Props {
value: T; value: T
group: T; group: T
inlineDescription?: boolean; inlineDescription?: boolean
id?: string; id?: string
disabled?: boolean; disabled?: boolean
children?: import('svelte').Snippet; children?: import('svelte').Snippet
description?: import('svelte').Snippet; description?: import('svelte').Snippet
[key: string]: any [key: string]: any
} }
@@ -26,7 +26,7 @@
children, children,
description, description,
...rest ...rest
}: Props = $props(); }: Props = $props()
</script> </script>
<div <div
+7 -8
View File
@@ -2,25 +2,24 @@
import { generateID } from '../forms/helper.js' import { generateID } from '../forms/helper.js'
interface Props { interface Props {
group?: string; group?: string
row?: boolean; row?: boolean
class?: string; class?: string
children?: import('svelte').Snippet<[any]>; children?: import('svelte').Snippet<[any]>
} }
let { let {
group = generateID(), group = generateID(),
row = false, row = false,
class: clazz = '', class: clazz = '',
children children,
}: Props = $props(); }: Props = $props()
</script> </script>
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<div <div
class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz || ''}" class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz || ''}"
> >
{@render children?.({ group, })} {@render children?.({ group })}
</div> </div>
</div> </div>
+8 -10
View File
@@ -1,12 +1,11 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
defaultValue?: boolean; defaultValue?: boolean
checked?: boolean; checked?: boolean
labelClass?: string; labelClass?: string
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
description?: import('svelte').Snippet; description?: import('svelte').Snippet
} }
let { let {
@@ -15,9 +14,8 @@
labelClass = '', labelClass = '',
class: clazz = '', class: clazz = '',
children, children,
description description,
}: Props = $props(); }: Props = $props()
</script> </script>
<label <label
+2 -2
View File
@@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
width?: number; width?: number
[key: string]: any [key: string]: any
} }
let { width = 16, ...rest }: Props = $props(); let { width = 16, ...rest }: Props = $props()
</script> </script>
<svg <svg
+10 -12
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { createBubbler } from 'svelte/legacy'; import { createBubbler } from 'svelte/legacy'
const bubble = createBubbler(); const bubble = createBubbler()
type Elevation = keyof typeof elevationClass type Elevation = keyof typeof elevationClass
type Padding = keyof typeof paddingClass type Padding = keyof typeof paddingClass
type Rounding = keyof typeof roundedClass type Rounding = keyof typeof roundedClass
@@ -46,15 +46,14 @@
none: '', none: '',
} }
interface Props { interface Props {
elevation?: Elevation; elevation?: Elevation
padding?: Padding; padding?: Padding
rounding?: Rounding; rounding?: Rounding
color?: Color; color?: Color
element?: string; element?: string
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
[key: string]: any [key: string]: any
} }
@@ -67,8 +66,7 @@
class: clazz = '', class: clazz = '',
children, children,
...rest ...rest
}: Props = $props(); }: Props = $props()
</script> </script>
<svelte:element <svelte:element
+2 -2
View File
@@ -40,7 +40,7 @@ export const action = (action?: {
: () => shownModal.set(undefined), : () => shownModal.set(undefined),
type: action?.type ?? 'secondary', type: action?.type ?? 'secondary',
content: action?.content || 'OK', content: action?.content || 'OK',
close: action?.close ?? true close: action?.close ?? true,
}) })
export function modal(inputModal: { export function modal(inputModal: {
@@ -58,7 +58,7 @@ export function modal(inputModal: {
dismissable: inputModal.dismissable ?? true, dismissable: inputModal.dismissable ?? true,
title: inputModal.title, title: inputModal.title,
body: inputModal.body, body: inputModal.body,
type: inputModal.type ?? 'info' type: inputModal.type ?? 'info',
} }
shownModal.set(modal) shownModal.set(modal)
+7 -9
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import Routebar from './Routebar.svelte'; import Routebar from './Routebar.svelte'
import Button from '../button/Button.svelte' import Button from '../button/Button.svelte'
type Route = string type Route = string
@@ -10,24 +10,22 @@
name: string name: string
} }
interface Props { interface Props {
/** /**
* The routes for the routebar. * The routes for the routebar.
*/ */
routes: RouteObject[]; routes: RouteObject[]
currentRoute?: Route | undefined; currentRoute?: Route | undefined
parentRoute?: Route | undefined; parentRoute?: Route | undefined
depth?: number; depth?: number
} }
let { let {
routes, routes,
currentRoute = undefined, currentRoute = undefined,
parentRoute = undefined, parentRoute = undefined,
depth = 0 depth = 0,
}: Props = $props(); }: Props = $props()
</script> </script>
<svelte:element this={depth == 0 ? 'nav' : 'ul'} class="flex flex-col h-full"> <svelte:element this={depth == 0 ? 'nav' : 'ul'} class="flex flex-col h-full">
+3 -3
View File
@@ -3,11 +3,11 @@
import { Icon, InformationCircle } from 'svelte-hero-icons' import { Icon, InformationCircle } from 'svelte-hero-icons'
interface Props { interface Props {
content?: string | undefined; content?: string | undefined
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { content = undefined, children }: Props = $props(); let { content = undefined, children }: Props = $props()
</script> </script>
<Material <Material
+4 -2
View File
@@ -5,12 +5,14 @@
*/ */
/** @type {Props} */ /** @type {Props} */
let { children } = $props(); let { children } = $props()
</script> </script>
<div <div
class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1" class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1"
> >
<div>{@render children?.()}</div> <div>{@render children?.()}</div>
<hr class="flex-shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70" /> <hr
class="flex-shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70"
/>
</div> </div>
+5 -5
View File
@@ -3,7 +3,8 @@
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516 // https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
import { onMount, onDestroy, createEventDispatcher } from 'svelte' import { onMount, onDestroy, createEventDispatcher } from 'svelte'
let slottedElements: HTMLDivElement = $state(), portal: HTMLDivElement let slottedElements: HTMLDivElement = $state(),
portal: HTMLDivElement
const dispatch = createEventDispatcher<{ mounted: void }>() const dispatch = createEventDispatcher<{ mounted: void }>()
@@ -21,12 +22,11 @@
}) })
interface Props { interface Props {
class?: string; class?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { class: clazz = '', children }: Props = $props(); let { class: clazz = '', children }: Props = $props()
</script> </script>
<div class="portal-initial-mount-point"> <div class="portal-initial-mount-point">
+2 -2
View File
@@ -14,10 +14,10 @@
import { fly } from 'svelte/transition' import { fly } from 'svelte/transition'
interface Props { interface Props {
toast: Toast; toast: Toast
} }
let { toast }: Props = $props(); let { toast }: Props = $props()
</script> </script>
<div <div
+8 -6
View File
@@ -3,11 +3,13 @@ import { writable } from 'svelte/store'
type ToastType = keyof typeof toastColors type ToastType = keyof typeof toastColors
export const toastColors = { export const toastColors = {
error: 'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700', error:
'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
warning: warning:
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600', 'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
success: 'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500', success:
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg' 'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg',
} }
export interface Toast { export interface Toast {
@@ -27,7 +29,7 @@ export function toast({
type = 'info', type = 'info',
duration = 5000, duration = 5000,
loading = false, loading = false,
action action,
}: { }: {
title?: string title?: string
content: string content: string
@@ -49,8 +51,8 @@ export function toast({
title: title, title: title,
type: type, type: type,
loading: loading, loading: loading,
action: action action: action,
} },
] ]
}) })
+2 -2
View File
@@ -19,7 +19,7 @@ interface SessionStorage {
export const setSessionStorage = ( export const setSessionStorage = (
key: keyof SessionStorage, key: keyof SessionStorage,
value: SessionStorage[typeof key] value: SessionStorage[typeof key],
) => { ) => {
if (!browser) return if (!browser) return
if (value == undefined) { if (value == undefined) {
@@ -30,7 +30,7 @@ export const setSessionStorage = (
} }
export const getSessionStorage = ( export const getSessionStorage = (
key: keyof SessionStorage key: keyof SessionStorage,
): SessionStorage[typeof key] => { ): SessionStorage[typeof key] => {
if (!browser) return if (!browser) return
return JSON.parse(sessionStorage.getItem(key)!) return JSON.parse(sessionStorage.getItem(key)!)
+9 -15
View File
@@ -187,8 +187,6 @@ export const defaultSettings: Settings = {
logoColorMonth: null, logoColorMonth: null,
} }
function createSettingsState(initial: Settings): Settings { function createSettingsState(initial: Settings): Settings {
let settings = $state(initial) let settings = $state(initial)
if (browser) { if (browser) {
@@ -197,9 +195,7 @@ function createSettingsState(initial: Settings): Settings {
const merged = mergeDeep(initial, localSettings) const merged = mergeDeep(initial, localSettings)
settings = merged settings = merged
} catch (e) { } catch (e) {}
}
} }
return settings return settings
} }
@@ -217,13 +213,11 @@ $effect.root(() => {
} }
}) })
return () => { return () => {}
}
}) })
function isObject(item: any) { function isObject(item: any) {
return (item && typeof item === 'object' && !Array.isArray(item)); return item && typeof item === 'object' && !Array.isArray(item)
} }
/** /**
@@ -232,19 +226,19 @@ function isObject(item: any) {
* @param ...sources * @param ...sources
*/ */
function mergeDeep(target: any, ...sources: any[]) { function mergeDeep(target: any, ...sources: any[]) {
if (!sources.length) return target; if (!sources.length) return target
const source = sources.shift(); const source = sources.shift()
if (isObject(target) && isObject(source)) { if (isObject(target) && isObject(source)) {
for (const key in source) { for (const key in source) {
if (isObject(source[key])) { if (isObject(source[key])) {
if (!target[key]) Object.assign(target, { [key]: {} }); if (!target[key]) Object.assign(target, { [key]: {} })
mergeDeep(target[key], source[key]); mergeDeep(target[key], source[key])
} else { } else {
Object.assign(target, { [key]: source[key] }); Object.assign(target, { [key]: source[key] })
} }
} }
} }
return mergeDeep(target, ...sources); return mergeDeep(target, ...sources)
} }
+2 -4
View File
@@ -88,7 +88,7 @@ const config: Config = {
loader: async () => (await import('./i18n/zh-Hant.json')).default, loader: async () => (await import('./i18n/zh-Hant.json')).default,
}, },
], ],
fallbackLocale: 'en' fallbackLocale: 'en',
} }
export const aliases = new Map([ export const aliases = new Map([
@@ -111,6 +111,4 @@ export const aliases = new Map([
['he-IL', 'he'], ['he-IL', 'he'],
]) ])
export let { t, locale, locales, loading, loadTranslations } = new i18n( export let { t, locale, locales, loading, loadTranslations } = new i18n(config)
config
)
+7 -7
View File
@@ -84,8 +84,8 @@ function themeStore(
fn: ( fn: (
values: ThemeData, values: ThemeData,
set: (value: Theme) => void, set: (value: Theme) => void,
update: (fn: Updater<Theme>) => void update: (fn: Updater<Theme>) => void,
) => any ) => any,
) { ) {
const derive: Readable<Theme> = derived(data, fn) const derive: Readable<Theme> = derived(data, fn)
const { subscribe } = derive const { subscribe } = derive
@@ -107,7 +107,7 @@ export let themeData = writable<ThemeData>(
scheme: 'system', scheme: 'system',
themes: presets, themes: presets,
currentTheme: 0, currentTheme: 0,
} },
) )
themeData.subscribe((themeData) => { themeData.subscribe((themeData) => {
@@ -118,7 +118,7 @@ themeData.subscribe((themeData) => {
JSON.stringify({ JSON.stringify({
...themeData, ...themeData,
themes: filteredThemes, themes: filteredThemes,
}) }),
) )
} }
}) })
@@ -126,7 +126,7 @@ themeData.subscribe((themeData) => {
export let theme = themeStore( export let theme = themeStore(
themeData, themeData,
(data) => (data) =>
data.themes.find((t) => t.id == data.currentTheme) ?? getDefaultTheme() data.themes.find((t) => t.id == data.currentTheme) ?? getDefaultTheme(),
) )
export function calculateVars(theme: Theme) { export function calculateVars(theme: Theme) {
@@ -145,7 +145,7 @@ export const themeVars = derived(theme, (t) => calculateVars(t as Theme))
const configuredColorScheme = env.PUBLIC_COLORSCHEME ?? 'system' const configuredColorScheme = env.PUBLIC_COLORSCHEME ?? 'system'
export const colorScheme = writable<ColorScheme>( export const colorScheme = writable<ColorScheme>(
configuredColorScheme as ColorScheme configuredColorScheme as ColorScheme,
) )
export const toggleColorScheme = () => { export const toggleColorScheme = () => {
@@ -175,7 +175,7 @@ function loadColorScheme() {
colorScheme.subscribe((colorScheme) => { colorScheme.subscribe((colorScheme) => {
if (typeof document != 'undefined') { if (typeof document != 'undefined') {
const prefersDark = window.matchMedia( const prefersDark = window.matchMedia(
'(prefers-color-scheme: dark)' '(prefers-color-scheme: dark)',
).matches ).matches
const html = document.querySelector('html') const html = document.querySelector('html')
+1 -2
View File
@@ -8,8 +8,7 @@ export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
export const load = async ({}) => { export const load = async ({}) => {
if (browser) { if (browser) {
const initLocale = const initLocale = settings.language ?? navigator?.language ?? 'en'
settings.language ?? navigator?.language ?? 'en'
console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`) console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`)
+7 -10
View File
@@ -1,14 +1,12 @@
<script lang="ts"> <script lang="ts">
import { Badge } from 'mono-svelte' import { Badge } from 'mono-svelte'
interface Props { interface Props {
name: string; name: string
description: string; description: string
badge?: string | undefined; badge?: string | undefined
link?: string; link?: string
class?: string; class?: string
} }
let { let {
@@ -16,9 +14,8 @@
description, description,
badge = undefined, badge = undefined,
link = '#', link = '#',
class: clazz = '' class: clazz = '',
}: Props = $props(); }: Props = $props()
</script> </script>
<div class="flex flex-col w-max {clazz}"> <div class="flex flex-col w-max {clazz}">
+1 -1
View File
@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
export const load = () => { export const load = () => {
redirect(302, '/admin/config'); redirect(302, '/admin/config')
} }
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
let { data, children } = $props(); let { data, children } = $props()
</script> </script>
<svelte:head> <svelte:head>
+1 -2
View File
@@ -10,8 +10,7 @@ export async function load({ params, fetch, url }) {
const page = Number(url.searchParams.get('page')) || undefined const page = Number(url.searchParams.get('page')) || undefined
const sort: SortType = const sort: SortType =
(url.searchParams.get('sort') as SortType) || (url.searchParams.get('sort') as SortType) || settings.defaultSort.sort
settings.defaultSort.sort
return await postFeed({ return await postFeed({
id: 'community', id: 'community',
+2 -5
View File
@@ -3,17 +3,14 @@
import CommunityTitle from '$lib/components/lemmy/community/CommunityTitle.svelte' import CommunityTitle from '$lib/components/lemmy/community/CommunityTitle.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
let { data } = $props(); let { data } = $props()
</script> </script>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<Header pageHeader> <Header pageHeader>
<span>Settings</span> <span>Settings</span>
{#snippet extended()} {#snippet extended()}
<CommunityTitle <CommunityTitle community={data.community.community_view.community} />
community={data.community.community_view.community}
/>
{/snippet} {/snippet}
</Header> </Header>
<CommunityForm <CommunityForm
+1 -1
View File
@@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit'
export function load({ params }) { export function load({ params }) {
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance. // If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
redirect(302, `/comment/${getInstance()}/${params.instance}`); redirect(302, `/comment/${getInstance()}/${params.instance}`)
} }
+1 -1
View File
@@ -13,6 +13,6 @@ export async function load({ params, fetch }) {
redirect( redirect(
302, 302,
`/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}` `/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`,
) )
} }
+1 -1
View File
@@ -55,7 +55,7 @@ export async function load({ url, fetch }) {
].sort( ].sort(
(a, b) => (a, b) =>
publishedToDate(b.published).getTime() - publishedToDate(b.published).getTime() -
publishedToDate(a.published).getTime() publishedToDate(a.published).getTime(),
) )
return { return {
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { run, preventDefault } from 'svelte/legacy'; import { run, preventDefault } from 'svelte/legacy'
import { Button, Material, Spinner, TextInput, toast } from 'mono-svelte' import { Button, Material, Spinner, TextInput, toast } from 'mono-svelte'
import Message from './Message.svelte' import Message from './Message.svelte'
@@ -17,7 +17,7 @@
import { report } from '$lib/components/lemmy/moderation/moderation' import { report } from '$lib/components/lemmy/moderation/moderation'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
let { data = $bindable() } = $props(); let { data = $bindable() } = $props()
let textbox = $state({ let textbox = $state({
message: '', message: '',
@@ -27,7 +27,7 @@
let chatWindow: HTMLDivElement = $state() let chatWindow: HTMLDivElement = $state()
async function sendMessage( async function sendMessage(
message: string message: string,
): Promise<PrivateMessageResponse | undefined> { ): Promise<PrivateMessageResponse | undefined> {
if (message == '') return if (message == '') return
@@ -55,10 +55,13 @@
run(() => { run(() => {
if (browser && data.message && chatWindow) { if (browser && data.message && chatWindow) {
tick().then(() => tick().then(() =>
chatWindow.scrollTo({ top: chatWindow.scrollHeight, behavior: 'smooth' }) chatWindow.scrollTo({
top: chatWindow.scrollHeight,
behavior: 'smooth',
}),
) )
} }
}); })
async function deleteMessage(id: number) { async function deleteMessage(id: number) {
const res = await client().deletePrivateMessage({ const res = await client().deletePrivateMessage({
@@ -69,9 +72,9 @@
data.message = { data.message = {
private_messages: data.message.private_messages.toSpliced( private_messages: data.message.private_messages.toSpliced(
data.message.private_messages.findLastIndex( data.message.private_messages.findLastIndex(
(i) => i.private_message.id == id (i) => i.private_message.id == id,
), ),
1 1,
), ),
} }
} }
+1 -1
View File
@@ -7,7 +7,7 @@
import { Material, Popover } from 'mono-svelte' import { Material, Popover } from 'mono-svelte'
import { Check, Icon, InformationCircle } from 'svelte-hero-icons' import { Check, Icon, InformationCircle } from 'svelte-hero-icons'
let { data } = $props(); let { data } = $props()
</script> </script>
<Header pageHeader>Linked Instances</Header> <Header pageHeader>Linked Instances</Header>
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { import {
+1 -1
View File
@@ -53,7 +53,7 @@ export async function load({ url, fetch }) {
...posts.post_reports.map(generalizePostReport), ...posts.post_reports.map(generalizePostReport),
...comments.comment_reports.map(generalizeCommentReport), ...comments.comment_reports.map(generalizeCommentReport),
...(messages?.private_message_reports ?? []).map( ...(messages?.private_message_reports ?? []).map(
generalizePrivateMessageReport generalizePrivateMessageReport,
), ),
].sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime()) ].sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())
+2 -2
View File
@@ -252,7 +252,7 @@ export async function load({ url }) {
filters: { filters: {
user: user ? moderationActions[0]?.moderatee?.name : undefined, user: user ? moderationActions[0]?.moderatee?.name : undefined,
community: community ? moderationActions[0]?.community?.title : undefined, community: community ? moderationActions[0]?.community?.title : undefined,
moderator: modId ? moderationActions[0]?.moderator?.name : undefined moderator: modId ? moderationActions[0]?.moderator?.name : undefined,
} },
} }
} }
+3 -4
View File
@@ -17,14 +17,13 @@
import type { ActionName } from './+page.js' import type { ActionName } from './+page.js'
interface Props { interface Props {
action: ActionName; action: ActionName
} }
let { action }: Props = $props(); let { action }: Props = $props()
const getAction = ( const getAction = (
action: ActionName action: ActionName,
): { icon: IconSource; text: string; class: string } => { ): { icon: IconSource; text: string; class: string } => {
switch (action) { switch (action) {
case 'ban': { case 'ban': {
+2 -2
View File
@@ -10,10 +10,10 @@
import ModlogAction from '../ModlogAction.svelte' import ModlogAction from '../ModlogAction.svelte'
interface Props { interface Props {
item: ModLog; item: ModLog
} }
let { item }: Props = $props(); let { item }: Props = $props()
</script> </script>
<Material padding="lg" class="flex flex-col gap-2"> <Material padding="lg" class="flex flex-col gap-2">
@@ -7,10 +7,10 @@
import ModlogAction from '../ModlogAction.svelte' import ModlogAction from '../ModlogAction.svelte'
interface Props { interface Props {
item: ModLog; item: ModLog
} }
let { item }: Props = $props(); let { item }: Props = $props()
</script> </script>
<tr class=""> <tr class="">
@@ -28,7 +28,8 @@
user={item.moderator} user={item.moderator}
/> />
{:else} {:else}
<p class="text-slate-500 dark:text-zinc-500">Hidden<p></p> <p class="text-slate-500 dark:text-zinc-500">Hidden</p>
<p></p>
{/if} {/if}
</td> </td>
<td> <td>
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
@@ -15,10 +15,10 @@
interface Props { interface Props {
data: { data: {
token: string token: string
}; }
} }
let { data }: Props = $props(); let { data }: Props = $props()
let instance = $state(LINKED_INSTANCE_URL || $currentInstance || '') let instance = $state(LINKED_INSTANCE_URL || $currentInstance || '')
let password = $state(''), let password = $state(''),
+2 -2
View File
@@ -12,8 +12,8 @@ export function load({ params, url }) {
const newUrl = new URL(url) const newUrl = new URL(url)
newUrl.pathname = split.join('/') newUrl.pathname = split.join('/')
redirect(302, newUrl.toString()); redirect(302, newUrl.toString())
} }
error(404, 'Not found'); error(404, 'Not found')
} }
@@ -5,7 +5,7 @@
*/ */
/** @type {Props} */ /** @type {Props} */
let { children } = $props(); let { children } = $props()
</script> </script>
{@render children?.()} {@render children?.()}
@@ -5,7 +5,7 @@
*/ */
/** @type {Props} */ /** @type {Props} */
let { children } = $props(); let { children } = $props()
</script> </script>
<div <div
@@ -10,7 +10,7 @@
UserGroup, UserGroup,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
let { data } = $props(); let { data } = $props()
</script> </script>
<div <div
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import UserPage from '../../u/[name]/+page.svelte' import UserPage from '../../u/[name]/+page.svelte'
let { data } = $props(); let { data } = $props()
</script> </script>
{#if data.user && data.sort && data.type && data.page} {#if data.user && data.sort && data.type && data.page}
+2 -2
View File
@@ -26,12 +26,12 @@ export async function load({ url, fetch, parent }) {
(a, b) => (a, b) =>
b.counts.upvotes - b.counts.upvotes -
b.counts.downvotes - b.counts.downvotes -
(a.counts.upvotes - a.counts.downvotes) (a.counts.upvotes - a.counts.downvotes),
) )
} else if (sort == 'New') { } else if (sort == 'New') {
items.sort( items.sort(
(a, b) => (a, b) =>
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)) Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)),
) )
} }
+2 -2
View File
@@ -5,9 +5,9 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations' import { t } from '$lib/translations'
let { data = $bindable() } = $props(); let { data = $bindable() } = $props()
const SvelteComponent = $derived(browser ? VirtualFeed : PostFeed); const SvelteComponent = $derived(browser ? VirtualFeed : PostFeed)
</script> </script>
<Header> <Header>
+1 -1
View File
@@ -44,7 +44,7 @@ export async function load({ url, fetch }) {
const everything = [...posts.posts, ...comments.comments].sort( const everything = [...posts.posts, ...comments.comments].sort(
(a, b) => (a, b) =>
Date.parse(getSavedItemPublished(b)) - Date.parse(getSavedItemPublished(b)) -
Date.parse(getSavedItemPublished(a)) Date.parse(getSavedItemPublished(a)),
) )
return { page: page, data: everything, type: type } return { page: page, data: everything, type: type }
+1 -1
View File
@@ -46,7 +46,7 @@ export async function load({ url, fetch }) {
everything.sort( everything.sort(
(a, b) => (a, b) =>
new Date(getItemPublished(b)).getTime() - new Date(getItemPublished(b)).getTime() -
new Date(getItemPublished(a)).getTime() new Date(getItemPublished(a)).getTime(),
) )
} }
+5 -11
View File
@@ -4,20 +4,14 @@
import { backOut, expoOut } from 'svelte/easing' import { backOut, expoOut } from 'svelte/easing'
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
interface Props { interface Props {
title: string; title: string
id: string; id: string
open?: boolean; open?: boolean
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { let { title, id, open = $bindable(true), children }: Props = $props()
title,
id,
open = $bindable(true),
children
}: Props = $props();
</script> </script>
<div class="flex flex-col max-w-full w-full"> <div class="flex flex-col max-w-full w-full">
+10 -12
View File
@@ -8,16 +8,15 @@
Icon, Icon,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
interface Props { interface Props {
supportedPlatforms?: any; supportedPlatforms?: any
mainClass?: string; mainClass?: string
itemsClass?: string; itemsClass?: string
optionClass?: string; optionClass?: string
class?: string; class?: string
title?: import('svelte').Snippet; title?: import('svelte').Snippet
description?: import('svelte').Snippet; description?: import('svelte').Snippet
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { let {
@@ -32,9 +31,8 @@
class: clazz = '', class: clazz = '',
title, title,
description, description,
children children,
}: Props = $props(); }: Props = $props()
</script> </script>
<div <div
+7 -8
View File
@@ -9,13 +9,12 @@
Icon, Icon,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
interface Props { interface Props {
title: string; title: string
description?: string | undefined; description?: string | undefined
checked?: boolean; checked?: boolean
beta?: boolean; beta?: boolean
supportedPlatforms?: any; supportedPlatforms?: any
} }
let { let {
@@ -27,8 +26,8 @@
desktop: true, desktop: true,
tablet: true, tablet: true,
mobile: true, mobile: true,
} },
}: Props = $props(); }: Props = $props()
</script> </script>
<div class="flex flex-col w-full justify-between gap-2 max-w-full"> <div class="flex flex-col w-full justify-between gap-2 max-w-full">
+5 -11
View File
@@ -2,18 +2,13 @@
import { Material, Popover } from 'mono-svelte' import { Material, Popover } from 'mono-svelte'
interface Props { interface Props {
href: string; href: string
size?: keyof typeof sizes; size?: keyof typeof sizes
title?: string; title?: string
children?: import('svelte').Snippet; children?: import('svelte').Snippet
} }
let { let { href, size = 'medium', title = '', children }: Props = $props()
href,
size = 'medium',
title = '',
children
}: Props = $props();
const sizes = { const sizes = {
large: 'h-24', large: 'h-24',
@@ -30,7 +25,6 @@
{/snippet} {/snippet}
{#snippet popover()} {#snippet popover()}
<Material <Material
padding="none" padding="none"
rounding="xl" rounding="xl"
elevation="medium" elevation="medium"
+2 -2
View File
@@ -14,7 +14,7 @@
</script> </script>
<script lang="ts"> <script lang="ts">
import { preventDefault } from 'svelte/legacy'; import { preventDefault } from 'svelte/legacy'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { Badge, Material, Spinner, toast } from 'mono-svelte' import { Badge, Material, Spinner, toast } from 'mono-svelte'
@@ -36,7 +36,7 @@
try { try {
const res: Instance[] = ( const res: Instance[] = (
await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then( await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then(
(r) => r.json() (r) => r.json(),
) )
) )
.filter((i: Instance) => i.fed) .filter((i: Instance) => i.fed)
+3 -3
View File
@@ -1,8 +1,8 @@
import { LINKED_INSTANCE_URL } from "$lib/instance.js"; import { LINKED_INSTANCE_URL } from '$lib/instance.js'
import { redirect } from "@sveltejs/kit"; import { redirect } from '@sveltejs/kit'
export const load = () => { export const load = () => {
if (LINKED_INSTANCE_URL) { if (LINKED_INSTANCE_URL) {
redirect(302, `/signup/${LINKED_INSTANCE_URL}`); redirect(302, `/signup/${LINKED_INSTANCE_URL}`)
} }
} }
+2 -2
View File
@@ -24,12 +24,12 @@ export async function load({ params, url, fetch }) {
(a, b) => (a, b) =>
b.counts.upvotes - b.counts.upvotes -
b.counts.downvotes - b.counts.downvotes -
(a.counts.upvotes - a.counts.downvotes) (a.counts.upvotes - a.counts.downvotes),
) )
} else if (sort == 'New') { } else if (sort == 'New') {
items.sort( items.sort(
(a, b) => (a, b) =>
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)) Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)),
) )
} }
+3 -3
View File
@@ -1,15 +1,15 @@
<script lang="ts"> <script lang="ts">
import { run } from 'svelte/legacy'; import { run } from 'svelte/legacy'
import { photonify } from '$lib/components/markdown/renderers/plugins' import { photonify } from '$lib/components/markdown/renderers/plugins'
import { TextInput } from 'mono-svelte' import { TextInput } from 'mono-svelte'
let link = $state('') let link = $state('')
let photonified; let photonified
run(() => { run(() => {
photonified = photonify(link) photonified = photonify(link)
}); })
</script> </script>
<h1 class="font-bold text-2xl">Photonify links</h1> <h1 class="font-bold text-2xl">Photonify links</h1>