lint: use svelte/reactivity classes

This commit is contained in:
James Xylight committed 2025-08-03 10:17:12 -07:00
1 parent 9114c82f6a
commit 3802c46c8f
11 files changed
+31 -52

No files matched your search

+9 -36
View File
@@ -1,12 +1,11 @@
import { goto } from '$app/navigation'
import { client } from '$lib/lemmy.svelte.js'
import { settings } from '$lib/settings.svelte'
import { feature } from '$lib/version.js'
import type { SubscribedType } from 'lemmy-js-client'
import { toast } from 'mono-svelte'
import { t } from './i18n/translations'
import { site } from './lemmy.svelte'
import { errorMessage } from './lemmy/error'
import { SvelteURL } from 'svelte/reactivity'
// Despite the name, this will round up
// Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128
@@ -29,7 +28,7 @@ export const searchParam = (
}
export const fullCommunityName = (name: string, actorId: string) =>
`${name}@${new URL(actorId).hostname}`
`${name}@${new SvelteURL(actorId).hostname}`
export const placeholders = {
url: ['https://example.com'],
@@ -126,38 +125,12 @@ export async function uploadImage(
const formData = new FormData()
formData.append('images[]', image)
if (feature('unproxiedImageUpload', site.data?.version)) {
const res = await client({ auth: jwt, instanceURL: instance }).uploadImage({
image: image,
})
const res = await client({ auth: jwt, instanceURL: instance }).uploadImage({
image: image,
})
if (res.url) return res.url
else throw new Error(`Failed to upload image. ${res.msg}`)
} else {
const response = await fetch(
`${
window.location.origin
}/cors/${instance}/pictrs/image?${new URLSearchParams({
auth: jwt,
})}`,
{
method: 'POST',
body: formData,
},
)
const json = await response.json()
if (json.msg == 'ok') {
return `https://${instance}/pictrs/image/${json.files?.[0]?.file}`
}
throw new Error(
`${
(await response.text().catch(() => undefined)) ??
'Failed to upload image'
}: ${response.status}: ${response.statusText}`,
)
}
if (res.url) return res.url
else throw new Error(`Failed to upload image. ${res.msg}`)
}
export const instanceToURL = (input: string) =>
@@ -167,7 +140,7 @@ export const instanceToURL = (input: string) =>
export function canParseUrl(url: string): boolean {
try {
new URL(url)
new SvelteURL(url)
return true
} catch {
return false
@@ -175,7 +148,7 @@ export function canParseUrl(url: string): boolean {
}
export function instanceId(actorId: string) {
return new URL(actorId).hostname
return new SvelteURL(actorId).hostname
}
export function escapeHtml(input: string): string {