fix: resolve all typescript errors in sv check (#715)

This commit is contained in:
xylight authored and GitHub committed 2026-02-08 23:43:50 +00:00
1 parent 2a5fb886ae
commit 7bddf16559
38 files changed
+233 -287

No files matched your search

+7 -2
View File
@@ -18,9 +18,10 @@
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/vite": "^4.1.18",
"@types/node": "^25.2.2",
"@types/nprogress": "^0.2.3",
"@types/ua-parser-js": "^0.7.39",
"@xylightdev/svelte-hero-icons": "^2.2.7",
"@xylightdev/svelte-hero-icons": "^2.2.9",
"eslint": "^9.39.2",
"eslint-plugin-svelte": "^3.14.0",
"jsdom": "^22.1.0",
@@ -357,6 +358,8 @@
"@types/linkify-it": ["@types/linkify-it@5.0.0", "", {}, "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="],
"@types/node": ["@types/node@25.2.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-BkmoP5/FhRYek5izySdkOneRyXYN35I860MFAGupTdebyE66uZaR+bXLHq8k4DirE5DwQi3NuhvRU1jqTVwUrQ=="],
"@types/nprogress": ["@types/nprogress@0.2.3", "", {}, "sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA=="],
"@types/resolve": ["@types/resolve@1.20.2", "", {}, "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q=="],
@@ -383,7 +386,7 @@
"@typescript-eslint/visitor-keys": ["@typescript-eslint/visitor-keys@8.54.0", "", { "dependencies": { "@typescript-eslint/types": "8.54.0", "eslint-visitor-keys": "^4.2.1" } }, "sha512-VFlhGSl4opC0bprJiItPQ1RfUhGDIBokcPwaFH4yiBCaNPeld/9VeXbiPO1cLyorQi1G1vL+ecBk1x8o1axORA=="],
"@xylightdev/svelte-hero-icons": ["@xylightdev/svelte-hero-icons@2.2.7", "", { "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-txlrlCf68r6DE43hITVN/ep8dYP2ops0AVtW+HAxIdWgAkae/L7fFJtbhb9iZIDSgHB7HV/5eV+UCVGdEXz3xw=="],
"@xylightdev/svelte-hero-icons": ["@xylightdev/svelte-hero-icons@2.2.9", "", { "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-P3cQPL8e3LNGLq1F4Pltg6/iMMf68wHmO89ovBmNl35WPu3KT3Ne4cv4OWLsQK2W0RgbSpzHbCr5ksBSnXISHA=="],
"abab": ["abab@2.0.6", "", {}, "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA=="],
@@ -805,6 +808,8 @@
"undici": ["undici@7.18.2", "", {}, "sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw=="],
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
"unenv": ["unenv@2.0.0-rc.24", "", { "dependencies": { "pathe": "^2.0.3" } }, "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw=="],
"universalify": ["universalify@0.2.0", "", {}, "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg=="],
+2 -1
View File
@@ -16,9 +16,10 @@
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/vite": "^4.1.18",
"@types/node": "^25.2.2",
"@types/nprogress": "^0.2.3",
"@types/ua-parser-js": "^0.7.39",
"@xylightdev/svelte-hero-icons": "^2.2.7",
"@xylightdev/svelte-hero-icons": "^2.2.10",
"eslint": "^9.39.2",
"eslint-plugin-svelte": "^3.14.0",
"jsdom": "^22.1.0",
+1 -1
View File
@@ -101,7 +101,7 @@ export function getClient(
export async function validateInstance(
instance: string,
type: ClientType,
type: ClientType = DEFAULT_CLIENT_TYPE,
): Promise<boolean> {
if (instance == '') return false
@@ -1,14 +1,13 @@
import { marked } from 'marked'
import { marked, type TokenizerAndRendererExtension, type Tokens } from 'marked'
import markedLinkifyIt from 'marked-linkify-it'
export const spoilerPlugin = {
export const spoilerPlugin: TokenizerAndRendererExtension = {
name: 'spoiler',
level: 'block',
start(src) {
start(src: string) {
return src.match(/:::/)?.index
},
// eslint-disable-next-line
tokenizer(src, tokens) {
tokenizer(src: string) {
const rule = /::: ?spoiler(?: ?(.*))\n([\s\S]*?)\n:::/
const match = rule.exec(src)
if (match) {
@@ -17,10 +16,11 @@ export const spoilerPlugin = {
raw: match[0],
title: match[1].trim(),
text: match[2].trim(),
tokens: [],
}
}
},
renderer(token) {
renderer(token: Tokens.Generic) {
return `
<details>
<summary>${marked.parseInline(token.title)}</summary>
@@ -30,11 +30,11 @@ export const spoilerPlugin = {
},
}
export const linkify = markedLinkifyIt(
export const linkify = (markedLinkifyIt as any)(
{
'!': {
validate: function (text, pos, self) {
var tail = text.slice(pos)
validate: function (text: string, pos: number, self: any) {
const tail = text.slice(pos)
if (!self.re.community) {
self.re.community = new RegExp(
@@ -47,11 +47,12 @@ export const linkify = markedLinkifyIt(
if (pos >= 2 && tail[pos - 2] === '!') {
return false
}
return tail.match(self.re.community)[0].length
const match = tail.match(self.re.community)
return match ? match[0].length : 0
}
return 0
},
normalize: function (match) {
normalize: function (match: any) {
let prefix = match.url
prefix = prefix.startsWith('c/') ? prefix.slice(2) : prefix.slice(1)
@@ -59,8 +60,8 @@ export const linkify = markedLinkifyIt(
},
},
'@': {
validate: function (text, pos, self) {
var tail = text.slice(pos)
validate: function (text: string, pos: number, self: any) {
const tail = text.slice(pos)
if (!self.re.user) {
self.re.user = new RegExp(
@@ -73,11 +74,12 @@ export const linkify = markedLinkifyIt(
if (pos >= 2 && tail[pos - 2] === '!') {
return false
}
return tail.match(self.re.user)[0].length
const match = tail.match(self.re.user)
return match ? match[0].length : 0
}
return 0
},
normalize: function (match) {
normalize: function (match: any) {
let prefix = match.url
prefix = prefix.startsWith('u/') ? prefix.slice(2) : prefix.slice(1)
@@ -103,7 +105,7 @@ export { regexes as CONTENT_REGEXES }
/**
* Convert links to photon links
*/
export const photonify = (link) => {
export const photonify = (link: string) => {
if (regexes.community.test(link)) {
const match = link.match(regexes.community)
if (!match) return
@@ -139,36 +141,41 @@ export const photonify = (link) => {
}
}
export function subSupscriptExtension(tokensExtractor) {
export function subSupscriptExtension(
tokensExtractor: (params: any) => Tokens.Generic | null,
): TokenizerAndRendererExtension {
return {
name: 'subscriptSuperscript',
level: 'inline',
start(src) {
start(src: string) {
return src.match(/[~^]/)?.index
},
// eslint-disable-next-line
tokenizer(src, tokens) {
tokenizer(this: any, src: string) {
const subscriptRule = /^~([^~\s](?:[^~]*[^~\s])?)~/
const superscriptRule = /^\^([^^\s](?:[^^]*[^^\s])?)\^/
let match
if ((match = subscriptRule.exec(src))) {
return tokensExtractor({
type: 'subscript',
content: match[1],
raw: match[0],
lexer: this.lexer,
})
return (
tokensExtractor({
type: 'subscript',
content: match[1],
raw: match[0],
lexer: this.lexer,
}) ?? undefined
)
}
if ((match = superscriptRule.exec(src))) {
return tokensExtractor({
type: 'superscript',
content: match[1],
raw: match[0],
lexer: this.lexer,
})
return (
tokensExtractor({
type: 'superscript',
content: match[1],
raw: match[0],
lexer: this.lexer,
}) ?? undefined
)
}
},
}
@@ -1,100 +0,0 @@
/**
* Container extension is a marked extension that parses a block of text surrounded by :::
*
* @param tokensExtractor Converts the container input into a custom token that svelte components will receive.
* If this function returns a value that contains an array of `tokens`,
* this array will be populated with the tokens that are found inside the container,
* allowing to nest markdown inside the container.
*
* @example
*
* Given the following markdown:
*
* :::container option="option-1" option-2="option-2" boolean-option
* Something inside the container
* :::
*
* The token extractor would receive the following parameters:
* **type**: `container`
* **content**: `Something inside the container`
* **options**: { 'option': 'option-1', 'option-2': 'option-2', 'boolean-option': true }
*/
export default function (tokensExtractor) {
return {
name: 'container',
level: 'block',
start(src) {
return src.match(/:::[^:\n]/)?.index
},
tokenizer(src) {
const rule =
/:::[\s]?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n)*/i
const match = rule.exec(findRawContainer(src))
if (!match || !match.groups) return null
const type = match.groups.type.toLocaleLowerCase()
const options = parseOptions(match.groups.options || '')
const content = match.groups.content || ''
const result = tokensExtractor({
type: type,
content: content,
raw: match[0],
options: options,
lexer: this.lexer,
})
if (result?.tokens) {
this.lexer.blockTokens(content, result.tokens)
}
return result
},
}
}
function findRawContainer(src) {
if (!src.startsWith(':::')) return undefined
const lines = src.split('\n')
let open = 1
let lineNumber = 1
for (lineNumber = 1; lineNumber < lines.length; lineNumber++) {
const line = lines[lineNumber]
if (line.startsWith(':::')) {
if (/:::[^:\n\s]/.test(line)) {
open++
} else if (/^:::(\n|$)/.test(line)) {
open -= 1
}
}
if (open === 0) {
break
}
}
return lines.slice(0, lineNumber + 1).join('\n')
}
function parseOptions(options) {
const output = {}
let remaining = options
while (true) {
const regex = /(?<name>[a-z0-9]+)(?:="(?<value>(?:.*?))")?/i
const match = regex.exec(remaining)
if (!match) break
const name = match?.groups?.name
if (name) {
output[name] = match?.groups?.value ?? true
}
remaining = remaining.slice(match.index + match[0].length)
}
return output
}
@@ -0,0 +1,57 @@
import type { TokenizerAndRendererExtension, Tokens } from 'marked'
/**
* spoiler extension for marked
*/
export default function (
tokensExtractor: (params: any) => Tokens.Generic | null,
): TokenizerAndRendererExtension {
return {
name: 'spoiler',
level: 'block',
start(src: string) {
return src.match(/:::[^:\n]/)?.index
},
tokenizer(this: any, src: string) {
const rule =
/^:::[ \t]*spoiler[ \t]*([^\n]*)\n([\s\S]*?)\n[ \t]*:::[ \t]*(?:\n|$)/
const match = rule.exec(src)
if (match) {
const title = match[1].trim()
const content = match[2].trim()
const options = parseOptions(title)
const result = tokensExtractor({
type: 'spoiler',
raw: match[0],
content: content,
options: options,
lexer: this.lexer,
})
if (result?.tokens) {
this.lexer.blockTokens(content, result.tokens)
}
return result ?? undefined
}
},
}
}
function parseOptions(options: string) {
const output: Record<string, string | boolean> = {}
const rule = /([a-z0-9]+)(?:="([^"]*)")?/gi
let match
while ((match = rule.exec(options)) !== null) {
const name = match[1]
if (name) {
output[name] = match?.groups?.value ?? true
}
}
return output
}
+17 -28
View File
@@ -57,40 +57,29 @@
>
{#if !children}
{#if community.community.deleted}
<Icon
src={Trash}
class="text-red-500 inline"
micro
size="14"
title={$t('post.badges.deleted')}
/>
<span title={$t('post.badges.deleted')}>
<Icon src={Trash} class="text-red-500 inline" micro size="14" />
</span>
{/if}
{#if community.community.nsfw}
<Icon
src={ExclamationTriangle}
class="text-red-500 inline"
micro
size="14"
title={$t('post.badges.nsfw')}
/>
<span title={$t('post.badges.nsfw')}>
<Icon
src={ExclamationTriangle}
class="text-red-500 inline"
micro
size="14"
/>
</span>
{/if}
{#if community.banned_from_community}
<Icon
src={NoSymbol}
class="text-red-500 inline"
micro
size="14"
title={$t('comment.banned')}
/>
<span title={$t('comment.banned')}>
<Icon src={NoSymbol} class="text-red-500 inline" micro size="14" />
</span>
{/if}
{#if community.community.visibility == 'LocalOnly'}
<Icon
src={MapPin}
class="text-green-500 inline"
micro
size="14"
title={$t('routes.admin.config.listingType.local')}
/>
<span title={$t('routes.admin.config.listingType.local')}>
<Icon src={MapPin} class="text-green-500 inline" micro size="14" />
</span>
{/if}
<Button
rounding="xl"
@@ -89,40 +89,29 @@
/>
</div>
{#if community.community.deleted}
<Icon
src={Trash}
class="text-red-500 inline"
micro
size="14"
title={$t('post.badges.deleted')}
/>
<span title={$t('post.badges.deleted')}>
<Icon src={Trash} class="text-red-500 inline" micro size="14" />
</span>
{/if}
{#if community.community.nsfw}
<Icon
src={ExclamationTriangle}
class="text-red-500 inline"
micro
size="14"
title={$t('post.badges.nsfw')}
/>
<span title={$t('post.badges.nsfw')}>
<Icon
src={ExclamationTriangle}
class="text-red-500 inline"
micro
size="14"
/>
</span>
{/if}
{#if community.banned_from_community}
<Icon
src={NoSymbol}
class="text-red-500 inline"
micro
size="14"
title={$t('comment.banned')}
/>
<span title={$t('comment.banned')}>
<Icon src={NoSymbol} class="text-red-500 inline" micro size="14" />
</span>
{/if}
{#if community.community.visibility == 'LocalOnly'}
<Icon
src={MapPin}
class="text-green-500 inline"
micro
size="14"
title={$t('routes.admin.config.listingType.local')}
/>
<span title={$t('routes.admin.config.listingType.local')}>
<Icon src={MapPin} class="text-green-500 inline" micro size="14" />
</span>
{/if}
<div class="flex gap-2 items-center justify-end w-full z-30 mt-auto">
<Button
@@ -67,13 +67,14 @@
{/if}
{#if badges}
{#if badges.nsfw}
<Icon
src={ExclamationTriangle}
size="14"
micro
title={$t('post.badges.nsfw')}
class="text-red-600 dark:text-red-400"
/>
<span title={$t('post.badges.nsfw')}>
<Icon
src={ExclamationTriangle}
size="14"
micro
class="text-red-600 dark:text-red-400"
/>
</span>
{/if}
{/if}
</a>
+1 -1
View File
@@ -5,6 +5,7 @@ import type {
Community,
CommunityView,
PersonView,
Post,
PostReportView,
PostView,
PrivateMessage,
@@ -13,7 +14,6 @@ import type {
} from '$lib/api/types'
import { profile } from '$lib/app/auth'
import { writable } from 'svelte/store'
import type { Post } from '../post'
export type Result =
| PostView
@@ -199,7 +199,6 @@
comment_view: item,
depth: 1,
}}
postId={item.post.id}
actions={false}
/>
{:else if isPostView(item)}
+1 -1
View File
@@ -118,7 +118,7 @@ export class PostFormState {
).post_view
}
if (api instanceof PiefedClient) {
if (api instanceof PiefedClient && api.assignFlair) {
const flairRes = await api.assignFlair({
flair_id_list: this.flairList.map((i) => i.id),
post_id: res.post.id,
+3 -1
View File
@@ -103,6 +103,7 @@
opened?: boolean
autoplay?: boolean
title?: string
class?: string
}
let {
@@ -112,6 +113,7 @@
title,
opened = $bindable(!settings.embeds.clickToView),
autoplay = settings.embeds.clickToView,
class: clazz = '',
}: Props = $props()
let data = $derived(typeData(type))
@@ -122,7 +124,7 @@
@component
Displays a video file or embedded video iframe.
-->
<div class="iframe-container">
<div class={['iframe-container', clazz]}>
{#if opened}
{#if type == 'video'}
<video {autoplay} controls>
+1 -1
View File
@@ -91,7 +91,7 @@
>
{#if post.alt_text}
<Button
onclick={(e) => {
onclick={(e: MouseEvent) => {
e.stopPropagation()
modal({
title: 'Alt',
+12 -10
View File
@@ -60,16 +60,18 @@
canVote = false
if (typeof id !== 'number') {
await api.voteOnPoll({
post_id: post.id,
choice_id: id,
})
} else {
await api.voteOnPoll({
post_id: post.id,
choice_id: [id],
})
if (api.voteOnPoll) {
if (typeof id !== 'number') {
await api.voteOnPoll({
post_id: post.id,
choice_id: id,
})
} else {
await api.voteOnPoll({
post_id: post.id,
choice_id: [id],
})
}
}
} catch (err) {
console.error(err)
+2 -8
View File
@@ -10,11 +10,10 @@
let switching: boolean = $state(false)
interface Props {
prof: ProfileInfo
index: number
guest?: boolean
}
let { prof, index, guest = false }: Props = $props()
let { prof, guest = false }: Props = $props()
</script>
<SidebarButton
@@ -39,12 +38,7 @@
class="w-full font-normal"
>
{#snippet customIcon()}
<ProfileAvatar
profile={prof}
{index}
{guest}
selected={profile.current?.id == prof.id}
/>
<ProfileAvatar profile={prof} selected={profile.current?.id == prof.id} />
{/snippet}
<span
class="inline-flex flex-col gap-0 {profile.current?.id == prof.id
+4 -1
View File
@@ -15,7 +15,8 @@
showWhenEmpty?: boolean
hideOwnUser?: boolean
placeholder?: string
onselect?: (e: Person) => void
label?: string
onselect?: (e?: Person) => void
}
let {
@@ -24,6 +25,7 @@
listing_type = 'Subscribed',
showWhenEmpty = false,
hideOwnUser = false,
label,
...rest
}: Props = $props()
@@ -50,6 +52,7 @@
}}
extractName={(c) => `${c.name}@${new URL(c.actor_id).hostname}`}
bind:query={q}
{label}
{...rest}
>
{#snippet noresults()}
+6 -3
View File
@@ -32,10 +32,13 @@
: ''}
{url != undefined ? 'rounded-b-none' : ''}
"
ondrop={preventDefault((event) => (files = event.dataTransfer?.files))}
ondrop={preventDefault(
(event) => (files = (event as DragEvent).dataTransfer?.files ?? null),
)}
ondragover={preventDefault((event) => {
if (event.dataTransfer) {
event.dataTransfer.dropEffect = 'copy'
const dragEvent = event as DragEvent
if (dragEvent.dataTransfer) {
dragEvent.dataTransfer.dropEffect = 'copy'
dragover = true
}
})}
+3
View File
@@ -13,6 +13,7 @@
children?: import('svelte').Snippet
style?: 'header' | 'subpage'
margin?: boolean
class?: string
}
let {
@@ -22,6 +23,7 @@
children,
style = 'header',
margin = true,
class: clazz = '',
}: Props = $props()
let matchType = $derived<('search' | 'pathname')[]>(
@@ -59,6 +61,7 @@
style == 'header' ? 'bar-header' : 'gap-2',
margin && 'my-2',
margin && style == 'subpage' && 'mb-3',
clazz,
]}
>
{#each routes as route, index (route.href)}
+3 -8
View File
@@ -2,11 +2,7 @@
import { Spinner } from 'mono-svelte'
import type { Snippet } from 'svelte'
import { type IconSource, Icon } from 'svelte-hero-icons/dist'
import type {
ClassValue,
HTMLAnchorAttributes,
HTMLButtonAttributes,
} from 'svelte/elements'
import type { ClassValue } from 'svelte/elements'
export type ButtonColor = keyof typeof buttonColor
export type ButtonAlignment = keyof typeof buttonAlignment
@@ -77,8 +73,7 @@
}
type ButtonGap = keyof typeof buttonGap
interface Props
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
interface Props extends Record<string, any> {
loading?: boolean
submit?: boolean
type?: 'button' | 'none'
@@ -94,7 +89,7 @@
prefix?: Snippet
children?: Snippet
suffix?: Snippet
onclick?: HTMLButtonAttributes['onclick']
onclick?: any
icon?: IconSource
weight?: ButtonWeight
}
@@ -9,7 +9,7 @@
title={$shownModal.title}
dismissable={$shownModal.dismissable}
ondismissed={() => shownModal.set(undefined)}
bind:open={$shownModal}
open={!!$shownModal}
>
{#if $shownModal.snippet}
{@render $shownModal.snippet?.()}
+3 -2
View File
@@ -9,7 +9,7 @@
selected?: T | undefined
search: (query: string) => Promise<T[]>
extractName: (item: T) => string
select?: (item: T) => void
select?: (item?: T) => void
input?: import('svelte').Snippet
noresults?: import('svelte').Snippet
required?: boolean
@@ -43,7 +43,8 @@
selected = $bindable(undefined),
search,
extractName,
select = (item: T) => {
select = (item?: T) => {
if (item == null) return
selected = item
query = extractName(item)
onselect?.(item)
+2 -7
View File
@@ -21,13 +21,8 @@
toast,
} from 'mono-svelte'
import { Icon, Plus } from 'svelte-hero-icons/dist'
import type { PageData } from '../$types'
interface Props {
data: PageData
}
let { data: pageData }: Props = $props()
let { data: pageData } = $props()
let data = $state(pageData)
const formData: Omit<EditSite, 'auth'> | undefined = $state(
@@ -198,7 +193,7 @@
{/snippet}
{#each site.data.all_languages.filter((l) => !formData.discussion_languages?.includes(l.id)) as language (language.id)}
<MenuButton
class="min-h-[16px] py-0"
class="min-h-4 py-0"
onclick={() => {
formData.discussion_languages?.push(language.id)
}}
+1 -1
View File
@@ -101,7 +101,7 @@
<div class="w-full">
<UserAutocomplete
listing_type="All"
onselect={(p) => (newAdmin = p.id)}
onselect={(p) => (newAdmin = p?.id)}
/>
</div>
<Button
@@ -136,7 +136,9 @@
<div class="w-full">
<UserAutocomplete
listing_type="All"
onselect={(p) => (formData.newModerator = p.id)}
onselect={(p) => {
if (p) formData.newModerator = p.id
}}
/>
</div>
<Button
+2 -2
View File
@@ -1,4 +1,4 @@
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import { instance } from '$lib/app/instance.svelte'
import { redirect } from '@sveltejs/kit'
@@ -6,7 +6,7 @@ export function load({ params }) {
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
redirect(
302,
resolveRoute('/comment/[instance]/[id]', {
resolve('/comment/[instance]/[id]', {
instance: encodeURIComponent(instance.data.toLowerCase()),
id: params.instance,
}),
+6 -9
View File
@@ -1,11 +1,11 @@
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit'
export async function load({ params, fetch }) {
if (profile.current.instance != params.instance)
redirect(302, resolveRoute('/comment/[instance]/[id]/confirm', params))
redirect(302, resolve('/comment/[instance]/[id]/confirm', params))
const comment = await client({
instanceURL: profile.current.instance,
@@ -20,12 +20,9 @@ export async function load({ params, fetch }) {
redirect(
302,
resolveRoute(
`/post/[instance]/[id]?thread=${threadPath}#${comment.comment_view.comment.id}`,
{
instance: encodeURIComponent(params.instance),
id: comment.comment_view.post.id.toString(),
},
),
resolve('/post/[instance]/[id=integer]', {
instance: encodeURIComponent(params.instance),
id: comment.comment_view.post.id.toString(),
}) + `?thread=${threadPath}#${comment.comment_view.comment.id}`,
)
}
@@ -1,6 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth'
@@ -24,7 +24,7 @@
if (res.comment) {
goto(
resolveRoute(`/comment/[instance]/[id]`, {
resolve(`/comment/[instance]/[id]`, {
instance: profile.current.instance,
id: res.comment.comment.id.toString(),
}),
@@ -88,8 +88,8 @@
rounding="2xl"
class="dark:bg-zinc-950 max-h-96 overflow-auto"
>
{#each filtered as profile, index (profile.id)}
<ProfileButton prof={profile} {index} />
{#each filtered as profile (profile.id)}
<ProfileButton prof={profile} />
{/each}
<SidebarButton
href="/accounts/login/guest?redirect={page.url}"
+2 -2
View File
@@ -16,7 +16,7 @@ export async function load({ url, fetch, route, params }) {
const feedData = await feed(route.id, async (p) => {
const piefedFeedData = piefed.getFeeds!({ include_communities: true }).then(
(i) => i.feeds.find((j) => j.id.toString() == p.feed_id!),
(i) => i.feeds.find((j) => j.id == p.feed_id),
)
const postPromise = piefed.getPosts(p)
@@ -34,7 +34,7 @@ export async function load({ url, fetch, route, params }) {
type_: 'All',
limit: 20,
show_hidden: settings.posts.showHidden,
feed_id: params.id,
feed_id: Number(params.id),
})
return feedData
+1 -1
View File
@@ -70,7 +70,7 @@
{loading}
disabled={loading ||
item.creator.id == profile.current.user?.local_user_view.person.id}
onclick={(e) => {
onclick={(e: MouseEvent) => {
e.stopPropagation()
markAsRead(!item.read)
}}
+8 -4
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import type { Person, PrivateMessageView } from '$lib/api/types'
import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n'
@@ -84,10 +84,14 @@
<UserAutocomplete
listing_type="All"
hideOwnUser={true}
onselect={(u) =>
onselect={(u) => {
if (!u) return
goto(
resolveRoute('/inbox/messages/[user_id]', { user_id: u.id.toString() }),
)}
resolve('/inbox/messages/[user_id=integer]', {
user_id: u.id.toString(),
}),
)
}}
/>
</Modal>
@@ -75,8 +75,10 @@
bind:selected={banFromCommunity}
/>
<UserAutocomplete
onselect={(p) =>
ban(banFromCommunity, p, data.community.community_view.community)}
onselect={(p) => {
if (!p) return
ban(banFromCommunity, p, data.community.community_view.community)
}}
listing_type="All"
/>
</div>
+2 -2
View File
@@ -1,4 +1,4 @@
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import { profile } from '$lib/app/auth'
import { error, redirect } from '@sveltejs/kit'
@@ -6,7 +6,7 @@ export function load({ params }) {
if (Number(params.instance)) {
redirect(
302,
resolveRoute(`/post/[instance]/[id]`, {
resolve(`/post/[instance]/[id=integer]`, {
instance: encodeURIComponent(profile.current.instance.toLowerCase()),
id: params.instance,
}),
@@ -1,4 +1,4 @@
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth'
import { settings } from '$lib/app/settings.svelte'
@@ -51,7 +51,7 @@ async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
export async function load({ params, url, route }) {
if (profile.current.instance != params.instance)
redirect(302, resolveRoute('/post/[instance]/[id]/confirm', params))
redirect(302, resolve('/post/[instance]/[id=integer]/confirm', params))
// TODO use Lemmy profile default settings
const sort = settings?.defaultSort?.comments ?? 'Hot'
@@ -1,6 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { resolveRoute } from '$app/paths'
import { resolve } from '$app/paths'
import { page } from '$app/state'
import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth'
@@ -24,7 +24,7 @@
if (res.post) {
goto(
resolveRoute(`/post/[instance]/[id]`, {
resolve(`/post/[instance]/[id=integer]`, {
instance: profile.current.instance,
id: res.post.post.id.toString(),
}),
@@ -87,8 +87,8 @@
rounding="2xl"
class="dark:bg-zinc-950 max-h-96 overflow-auto"
>
{#each filtered as profile, index (profile.id)}
<ProfileButton prof={profile} {index} />
{#each filtered as profile (profile.id)}
<ProfileButton prof={profile} />
{/each}
<SidebarButton
href="/accounts/login/guest?redirect={page.url}"
+1 -6
View File
@@ -116,12 +116,7 @@
listing_type="All"
showWhenEmpty={true}
onselect={(c) =>
searchParam(
page.url,
'community',
c?.community.id || undefined,
'page',
)}
searchParam(page.url, 'creator', c?.id.toString() ?? '', 'page')}
/>
</div>
{/snippet}
+1 -1
View File
@@ -53,7 +53,7 @@
images={false}
previewButton
beforePreview={(input) =>
removalTemplate(input, {
removalTemplate(input ?? '', {
postTitle: '<Example post>',
communityLink: '[!community@example.com]()',
reason: '<Being a meanie>',
+2 -2
View File
@@ -17,7 +17,7 @@ export async function load({ url, fetch, route, params }) {
const feedData = await feed(route.id, async (p) => {
const piefedTopicData = piefed.getTopics!({
include_communities: true,
}).then((i) => i.topics.find((j) => j.id.toString() == p.topic_id!))
}).then((i) => i.topics.find((j) => j.id == p.topic_id))
const posts = await piefed.getPosts(p)
@@ -33,7 +33,7 @@ export async function load({ url, fetch, route, params }) {
type_: 'All',
limit: 20,
show_hidden: settings.posts.showHidden,
topic_id: params.id,
topic_id: Number(params.id),
})
return feedData