prettier: format project

This commit is contained in:
James Xylight committed 2025-09-06 22:25:07 -07:00
1 parent e7dd3e8dac
commit cbd27a38a0
94 files changed
+261 -252

No files matched your search

+20 -20
View File
@@ -61,8 +61,8 @@ const getCookie = (key: string): string | undefined => {
return document?.cookie
?.split(';')
.map(c => c.trim())
.find(c => c.split('=')?.[0] == key)
.map((c) => c.trim())
.find((c) => c.split('=')?.[0] == key)
?.split('=')?.[1]
}
@@ -82,7 +82,7 @@ class Profile {
},
)
#current = $derived(
this.meta.profiles.find(i => i.id == this.meta.profile) ??
this.meta.profiles.find((i) => i.id == this.meta.profile) ??
this.getDefaultProfile(),
)
@@ -123,7 +123,7 @@ class Profile {
setInterval(
() => {
if (profile.current.jwt)
this.checkInbox().then(res => notifications.update(() => res))
this.checkInbox().then((res) => notifications.update(() => res))
},
4 * 60 * 1000,
)
@@ -165,7 +165,7 @@ class Profile {
}
set current(value) {
if (!value) return
const index = this.meta.profiles.findIndex(i => i.id == value?.id)
const index = this.meta.profiles.findIndex((i) => i.id == value?.id)
this.meta.profiles[index] = value
}
@@ -200,7 +200,7 @@ class Profile {
site.data = undefined
client({ instanceURL: this.#current.instance })
.getSite()
.then(res => (site.data = res))
.then((res) => (site.data = res))
}
}
@@ -226,8 +226,8 @@ class Profile {
async add(jwt: string, instance: string, type: ClientType) {
const user = await userFromJwt(jwt, instance)
.then(u => u)
.catch(err => {
.then((u) => u)
.catch((err) => {
toast({ content: errorMessage(err as string), type: 'error' })
})
if (!user?.user) {
@@ -237,7 +237,7 @@ class Profile {
})
}
const id = Math.max(...this.meta.profiles.map(p => p.id)) + 1
const id = Math.max(...this.meta.profiles.map((p) => p.id)) + 1
this.meta.profile = id
this.meta.profiles.unshift({
id: id,
@@ -253,7 +253,7 @@ class Profile {
remove(id: number) {
this.meta.profiles.splice(
this.meta.profiles.findIndex(p => p.id == id),
this.meta.profiles.findIndex((p) => p.id == id),
1,
)
if (id == this.meta.profile) this.meta.profile = -1
@@ -261,7 +261,7 @@ class Profile {
move(id: number, up: boolean) {
try {
const index = this.meta.profiles.findIndex(i => i.id == id)
const index = this.meta.profiles.findIndex((i) => i.id == id)
this.meta.profiles = moveItem(
this.meta.profiles,
index,
@@ -277,7 +277,7 @@ class Profile {
$effect(() => {
const serialized = {
...this.meta,
profiles: this.meta.profiles.map(p => serializeUser(p)),
profiles: this.meta.profiles.map((p) => serializeUser(p)),
}
setFromStorage('profileData', serialized)
@@ -292,7 +292,7 @@ class Profile {
$effect(() => {
this.fetchUserData().then(() => {
if (this.current.jwt)
this.checkInbox().then(res => notifications.update(() => res))
this.checkInbox().then((res) => notifications.update(() => res))
})
})
})
@@ -325,11 +325,11 @@ async function userFromJwt(
)
const site = await sitePromise
.then(r => {
.then((r) => {
clearTimeout(timer)
return r
})
.catch(e => {
.catch((e) => {
toast({ content: `Failed to contact the instance. ${e}` })
})
@@ -360,27 +360,27 @@ function serializeUser(user: ProfileInfo): ProfileInfo {
async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) {
const unreadsPromise = getClient()
.getUnreadCount()
.then(res => res.mentions + res.private_messages + res.replies)
.then((res) => res.mentions + res.private_messages + res.replies)
.catch(() => 0)
const reportsPromise = mod
? getClient()
.getReportCount({})
.then(
res =>
(res) =>
res.comment_reports +
res.post_reports +
(res.private_message_reports ?? 0),
)
.catch(() => 0)
: new Promise<number>(res => res(0))
: new Promise<number>((res) => res(0))
const applicationsPromise = admin
? getClient()
.getUnreadRegistrationApplicationCount()
.then(res => res.registration_applications)
.then((res) => res.registration_applications)
.catch(() => 0)
: new Promise<number>(res => res(0))
: new Promise<number>((res) => res(0))
const [unreads, reports, applications] = await Promise.all([
unreadsPromise,