refactor: split auth.svelte.ts -> auth/profile.svelte.ts + auth/inbox.svelte.ts

This commit is contained in:
Xylight committed 2026-02-08 11:20:32 -08:00
1 parent 9d1d172924
commit 48fa25c285
95 files changed
+236 -224

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { DEFAULT_INSTANCE_URL } from '$lib/app/instance.svelte' import { DEFAULT_INSTANCE_URL } from '$lib/app/instance.svelte'
import { instanceToURL } from '$lib/app/util.svelte' import { instanceToURL } from '$lib/app/util.svelte'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
+90
View File
@@ -0,0 +1,90 @@
import type { Profile } from './profile.svelte'
interface Notifications {
inbox: number
reports: number
applications: number
}
export class InboxService {
private readonly POLL_INTERVAL = 4 * 60 * 1000
#pollInterval: ReturnType<typeof setInterval> | null = null
#profile: Profile
notifications = $state<Notifications>({
applications: 0,
inbox: 0,
reports: 0,
})
constructor(profile: Profile) {
this.#profile = profile
}
async init(): Promise<void> {
this.cleanup()
this.notifications = await this.checkInbox()
this.#pollInterval = setInterval(async () => {
this.notifications = await this.checkInbox()
}, this.POLL_INTERVAL)
}
cleanup(): void {
if (this.#pollInterval) clearInterval(this.#pollInterval)
this.#pollInterval = null
}
clear(): Notifications {
this.notifications = {
applications: 0,
inbox: 0,
reports: 0,
}
return this.notifications
}
async checkInbox(): Promise<Notifications> {
if (!this.#profile.current.user || !this.#profile.current.jwt)
return this.clear()
const unreadsPromise = this.#profile.client
.getUnreadCount()
.then((res) => res.mentions + res.private_messages + res.replies)
.catch(() => 0)
const reportsPromise = this.#profile.isMod()
? this.#profile.client
.getReportCount({})
.then(
(res) =>
res.comment_reports +
res.post_reports +
(res.private_message_reports ?? 0),
)
.catch(() => 0)
: Promise.resolve(0)
const applicationsPromise = this.#profile.isAdmin
? this.#profile.client
.getUnreadRegistrationApplicationCount()
.then((res) => res.registration_applications)
.catch(() => 0)
: Promise.resolve(0)
const [unreads, reports, applications] = await Promise.all([
unreadsPromise,
reportsPromise,
applicationsPromise,
])
return {
inbox: unreads,
reports: reports,
applications: applications,
}
}
}
+1
View File
@@ -0,0 +1 @@
export { profile, type ProfileInfo } from './profile.svelte'
@@ -5,10 +5,11 @@ import { client, site } from '$lib/api/client.svelte'
import type { Community, GetSiteResponse, MyUserInfo } from '$lib/api/types' import type { Community, GetSiteResponse, MyUserInfo } from '$lib/api/types'
import { publishedToDate } from '$lib/ui/util/date' import { publishedToDate } from '$lib/ui/util/date'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
import { errorMessage } from './error' import { errorMessage } from '../error'
import { t } from './i18n' import { t } from '../i18n'
import { DEFAULT_INSTANCE_URL } from './instance.svelte' import { DEFAULT_INSTANCE_URL } from '../instance.svelte'
import { instanceToURL, moveItem } from './util.svelte' import { instanceToURL, moveItem } from '../util.svelte'
import { InboxService } from './inbox.svelte'
function getFromStorage<T>(key: string): T | undefined { function getFromStorage<T>(key: string): T | undefined {
if (!browser) return if (!browser) return
@@ -18,9 +19,12 @@ function getFromStorage<T>(key: string): T | undefined {
return JSON.parse(lc) return JSON.parse(lc)
} }
function setFromStorage(key: string, item: any, stringify: boolean = true) { function setFromStorage<T>(key: string, item: T, stringify: boolean = true) {
if (!browser) return if (!browser) return
return localStorage.setItem(key, stringify ? JSON.stringify(item) : item) return localStorage.setItem(
key,
stringify ? JSON.stringify(item) : (item as string),
)
} }
export interface ProfileInfo { export interface ProfileInfo {
@@ -44,12 +48,6 @@ interface ProfileData {
profile: number profile: number
} }
interface Notifications {
inbox: number
reports: number
applications: number
}
const getCookie = (key: string): string | undefined => { const getCookie = (key: string): string | undefined => {
if (!browser) return undefined if (!browser) return undefined
@@ -60,7 +58,7 @@ const getCookie = (key: string): string | undefined => {
?.split('=')?.[1] ?.split('=')?.[1]
} }
class Profile { export class Profile {
private static readonly DONATION_CHECK_TIMEOUT = 3 * 1000 private static readonly DONATION_CHECK_TIMEOUT = 3 * 1000
private static readonly DONATION_REMINDER_INTERVAL = 375 * 24 * 60 * 60 * 1000 private static readonly DONATION_REMINDER_INTERVAL = 375 * 24 * 60 * 60 * 1000
@@ -142,11 +140,10 @@ class Profile {
private donationPoll(delay: number) { private donationPoll(delay: number) {
return setTimeout(() => { return setTimeout(() => {
if ( if (
profile.current.user?.local_user_view.local_user this.current.user?.local_user_view.local_user.last_donation_notification
.last_donation_notification
) { ) {
const donationDate = publishedToDate( const donationDate = publishedToDate(
profile.current.user?.local_user_view.local_user this.current.user?.local_user_view.local_user
.last_donation_notification, .last_donation_notification,
) )
if ( if (
@@ -161,11 +158,11 @@ class Profile {
// lemmy js client donation dialog is broken // lemmy js client donation dialog is broken
fetch( fetch(
`${instanceToURL(profile.current.instance)}/api/v3/user/donation_dialog_shown`, `${instanceToURL(this.current.instance)}/api/v3/user/donation_dialog_shown`,
{ {
method: 'POST', method: 'POST',
headers: { headers: {
authorization: `Bearer ${profile.current.jwt}`, authorization: `Bearer ${this.current.jwt}`,
}, },
}, },
) )
@@ -179,7 +176,7 @@ class Profile {
if (this.#current.jwt) { if (this.#current.jwt) {
site.data = undefined site.data = undefined
const res = await userFromJwt( const res = await fetchUserContext(
this.#current.jwt, this.#current.jwt,
this.#current.instance, this.#current.instance,
this.#current.client, this.#current.client,
@@ -199,7 +196,7 @@ class Profile {
site.data = res?.site site.data = res?.site
this.#current.user = res?.user this.#current.user = res?.user
if (profile.current.user) { if (this.current.user) {
this.#current.avatar = res?.user?.local_user_view.person.avatar this.#current.avatar = res?.user?.local_user_view.person.avatar
this.#current.username = res?.user?.local_user_view.person.name this.#current.username = res?.user?.local_user_view.person.name
} }
@@ -218,7 +215,7 @@ class Profile {
async add(jwt: string, instance: string, type: ClientType) { async add(jwt: string, instance: string, type: ClientType) {
try { try {
const user = await userFromJwt(jwt, instance, type) const user = await fetchUserContext(jwt, instance, type)
if (!user?.user) { if (!user?.user) {
throw new Error('No user data received') throw new Error('No user data received')
} }
@@ -265,15 +262,13 @@ class Profile {
} }
isMod(community?: Community): boolean { isMod(community?: Community): boolean {
if (community) if (!community) return (this.#current.user?.moderates.length ?? 0) > 0
return ( if (community.local && this.isAdmin) return true
(this.#current.user?.moderates.some( return (
(i) => i.community.id == community.id, this.#current.user?.moderates.some(
) || (m) => m.community.id === community.id,
(community.local && this.isAdmin)) ?? ) ?? false
false )
)
else return (this.#current.user?.moderates.length ?? 0) > 0
} }
get isAdmin(): boolean { get isAdmin(): boolean {
@@ -311,93 +306,9 @@ class Profile {
}) })
} }
class InboxService {
private readonly POLL_INTERVAL = 4 * 60 * 1000
#pollInterval: NodeJS.Timeout | null = null
#profile: Profile
notifications = $state<Notifications>({
applications: 0,
inbox: 0,
reports: 0,
})
constructor(profile: Profile) {
this.#profile = profile
}
async init(): Promise<void> {
this.cleanup()
this.notifications = await this.checkInbox()
this.#pollInterval = setInterval(async () => {
this.notifications = await this.checkInbox()
}, this.POLL_INTERVAL)
}
cleanup(): void {
if (this.#pollInterval) clearInterval(this.#pollInterval)
this.#pollInterval = null
}
clear(): Notifications {
this.notifications = {
applications: 0,
inbox: 0,
reports: 0,
}
return this.notifications
}
async checkInbox(): Promise<Notifications> {
if (!this.#profile.current.user || !this.#profile.current.jwt)
return this.clear()
const unreadsPromise = client()
.getUnreadCount()
.then((res) => res.mentions + res.private_messages + res.replies)
.catch(() => 0)
const reportsPromise = this.#profile.isMod()
? client()
.getReportCount({})
.then(
(res) =>
res.comment_reports +
res.post_reports +
(res.private_message_reports ?? 0),
)
.catch(() => 0)
: new Promise<number>((res) => res(0))
const applicationsPromise = this.#profile.isAdmin
? client()
.getUnreadRegistrationApplicationCount()
.then((res) => res.registration_applications)
.catch(() => 0)
: new Promise<number>((res) => res(0))
const [unreads, reports, applications] = await Promise.all([
unreadsPromise,
reportsPromise,
applicationsPromise,
])
return {
inbox: unreads,
reports: reports,
applications: applications,
}
}
}
export const profile = new Profile() export const profile = new Profile()
// this is all garbage legacy code, remove later async function fetchUserContext(
async function userFromJwt(
jwt: string, jwt: string,
instance: string, instance: string,
type: ClientType, type: ClientType,
@@ -429,10 +340,8 @@ async function userFromJwt(
if (!site) return if (!site) return
const myUser = site.my_user
return { return {
user: myUser, user: site.my_user,
site: site, site: site,
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { profile } from './auth.svelte' import { profile } from './auth'
class InstanceData { class InstanceData {
#instance = $derived(profile.current.instance) #instance = $derived(profile.current.instance)
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state' import { page } from '$app/state'
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { CommentView } from '$lib/api/types' import type { CommentView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { Button, Menu, MenuButton } from 'mono-svelte' import { Button, Menu, MenuButton } from 'mono-svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client, site } from '$lib/api/client.svelte' import { client, site } from '$lib/api/client.svelte'
import type { CommentResponse } from '$lib/api/types' import type { CommentResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { site } from '$lib/api/client.svelte' import { site } from '$lib/api/client.svelte'
import type { Comment } from '$lib/api/types' import type { Comment } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
@@ -1,7 +1,7 @@
<script lang="ts" module> <script lang="ts" module>
import { client, getClient } from '$lib/api/client.svelte' import { client, getClient } from '$lib/api/client.svelte'
import type { CommunityModeratorView, CommunityView } from '$lib/api/types' import type { CommunityModeratorView, CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { client, site } from '$lib/api/client.svelte' import { client, site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -6,7 +6,7 @@
CommunityModeratorView, CommunityModeratorView,
SubscribedType, SubscribedType,
} from '$lib/api/types' } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { fullCommunityName, userLink } from '$lib/app/util.svelte' import { fullCommunityName, userLink } from '$lib/app/util.svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { CommunityView } from '$lib/api/types' import type { CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { locale, t } from '$lib/app/i18n' import { locale, t } from '$lib/app/i18n'
import { fullCommunityName } from '$lib/app/util.svelte' import { fullCommunityName } from '$lib/app/util.svelte'
import CommonItem from '$lib/ui/layout/CommonItem.svelte' import CommonItem from '$lib/ui/layout/CommonItem.svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { CommunityView } from '$lib/api/types' import type { CommunityView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { communityLink } from '$lib/app/util.svelte' import { communityLink } from '$lib/app/util.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte' import Avatar from '$lib/ui/generic/Avatar.svelte'
+1 -1
View File
@@ -15,7 +15,7 @@ import type {
SortType, SortType,
TopicView, TopicView,
} from '$lib/api/types' } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { recursiveEqual } from '$lib/app/util.svelte' import { recursiveEqual } from '$lib/app/util.svelte'
import { SvelteMap } from 'svelte/reactivity' import { SvelteMap } from 'svelte/reactivity'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state' import { page } from '$app/state'
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { searchParam } from '$lib/app/util.svelte' import { searchParam } from '$lib/app/util.svelte'
import { Option, Select } from 'mono-svelte' import { Option, Select } from 'mono-svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state' import { page } from '$app/state'
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { searchParam } from '$lib/app/util.svelte' import { searchParam } from '$lib/app/util.svelte'
import { Option, Select } from 'mono-svelte' import { Option, Select } from 'mono-svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { PrivateMessageView } from '$lib/api/types' import type { PrivateMessageView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
import UserLink from '../user/UserLink.svelte' import UserLink from '../user/UserLink.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { type ProfileInfo } from '$lib/app/auth.svelte.js' import { type ProfileInfo } from '$lib/app/auth'
import Avatar from '$lib/ui/generic/Avatar.svelte' import Avatar from '$lib/ui/generic/Avatar.svelte'
interface Props { interface Props {
+1 -1
View File
@@ -11,7 +11,7 @@ import type {
PrivateMessageReportView, PrivateMessageReportView,
PrivateMessageView, PrivateMessageView,
} from '$lib/api/types' } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import type { Post } from '../post' import type { Post } from '../post'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { Community, Person } from '$lib/api/types' import type { Community, Person } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { CommentView } from '$lib/api/types' import type { CommentView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { Menu, MenuButton, MenuDivider } from 'mono-svelte' import { Menu, MenuButton, MenuDivider } from 'mono-svelte'
import type { Snippet } from 'svelte' import type { Snippet } from 'svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import type { CommentView, PostView } from '$lib/api/types' import type { CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte' import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import type { CommentView, PostView } from '$lib/api/types' import type { CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -5,7 +5,7 @@
PostView, PostView,
PrivateMessageView, PrivateMessageView,
} from '$lib/api/types' } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { PostView } from '$lib/api/types' import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { type View, settings } from '$lib/app/settings.svelte' import { type View, settings } from '$lib/app/settings.svelte'
import { publishedToDate } from '$lib/ui/util/date' import { publishedToDate } from '$lib/ui/util/date'
import type { ClassValue } from 'svelte/elements' import type { ClassValue } from 'svelte/elements'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts" module> <script lang="ts" module>
import type { Community, Person, SubscribedType } from '$lib/api/types' import type { Community, Person, SubscribedType } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
import { type View, settings } from '$lib/app/settings.svelte' import { type View, settings } from '$lib/app/settings.svelte'
+1 -1
View File
@@ -18,7 +18,7 @@
<script lang="ts"> <script lang="ts">
import { site } from '$lib/api/client.svelte' import { site } from '$lib/api/client.svelte'
import type { Post } from '$lib/api/types' import type { Post } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state' import { page } from '$app/state'
import type { PostView } from '$lib/api/types' import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import { settings, type View } from '$lib/app/settings.svelte' import { settings, type View } from '$lib/app/settings.svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import type { PostView } from '$lib/api/types' import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { deleteItem, markAsRead } from '$lib/feature/legacy/contentview' import { deleteItem, markAsRead } from '$lib/feature/legacy/contentview'
+1 -1
View File
@@ -2,7 +2,7 @@
import { client, site } from '$lib/api/client.svelte' import { client, site } from '$lib/api/client.svelte'
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import type { PostView } from '$lib/api/types' import type { PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { CommentView, PersonView, Post } from '$lib/api/types' import type { CommentView, PersonView, Post } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { import {
canParseUrl, canParseUrl,
findClosestNumber, findClosestNumber,
+1 -1
View File
@@ -2,7 +2,7 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import type { Post, PostPoll } from '$lib/api/types' import type { Post, PostPoll } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { CommonList } from '$lib/ui/layout' import { CommonList } from '$lib/ui/layout'
+11 -7
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { LocalImage, Person } from '$lib/api/types' import type { LocalImage, Person } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { instanceToURL } from '$lib/app/util.svelte' import { instanceToURL } from '$lib/app/util.svelte'
import { showImage } from '$lib/ui/generic/ExpandableImage.svelte' import { showImage } from '$lib/ui/generic/ExpandableImage.svelte'
@@ -42,14 +42,16 @@
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
{#snippet img()} {#snippet img()}
<button <button
onclick={ onclick={() =>
() => showImage(
showImage(`${instanceToURL(profile.current.instance)}/pictrs/image/${image.pictrs_alias}`) `${instanceToURL(profile.current.instance)}/pictrs/image/${image.pictrs_alias}`,
} )}
class="cursor-pointer" class="cursor-pointer"
> >
<img <img
src="{instanceToURL(profile.current.instance)}/pictrs/image/{image.pictrs_alias}" src="{instanceToURL(
profile.current.instance,
)}/pictrs/image/{image.pictrs_alias}"
width="500" width="500"
height="500" height="500"
class="aspect-square w-full h-full object-cover rounded-xl" class="aspect-square w-full h-full object-cover rounded-xl"
@@ -70,7 +72,9 @@
/> />
<Button <Button
title={$t('routes.profile.media.download')} title={$t('routes.profile.media.download')}
href="{instanceToURL(profile.current.instance)}/pictrs/image/{image.pictrs_alias}" href="{instanceToURL(
profile.current.instance,
)}/pictrs/image/{image.pictrs_alias}"
size="square-md" size="square-md"
class="ml-auto" class="ml-auto"
icon={ArrowDownTray} icon={ArrowDownTray}
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/state' import { page } from '$app/state'
import { profile, type ProfileInfo } from '$lib/app/auth.svelte' import { profile, type ProfileInfo } from '$lib/app/auth'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import SidebarButton from '$lib/ui/sidebar/SidebarButton.svelte' import SidebarButton from '$lib/ui/sidebar/SidebarButton.svelte'
import { Icon, QuestionMarkCircle } from 'svelte-hero-icons/dist' import { Icon, QuestionMarkCircle } from 'svelte-hero-icons/dist'
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/state' import { page } from '$app/state'
import { DEFAULT_CLIENT_TYPE } from '$lib/api/base' import { DEFAULT_CLIENT_TYPE } from '$lib/api/base'
import { profile, type ProfileInfo } from '$lib/app/auth.svelte' import { profile, type ProfileInfo } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte' import Avatar from '$lib/ui/generic/Avatar.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import type { ListingType, Person } from '$lib/api/types' import type { ListingType, Person } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import Avatar from '$lib/ui/generic/Avatar.svelte' import Avatar from '$lib/ui/generic/Avatar.svelte'
import { MenuButton, Search } from 'mono-svelte' import { MenuButton, Search } from 'mono-svelte'
import { createEventDispatcher } from 'svelte' import { createEventDispatcher } from 'svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { Community, MyUserInfo } from '$lib/api/types' import type { Community, MyUserInfo } from '$lib/api/types'
import { profile, type ProfileInfo } from '$lib/app/auth.svelte' import { profile, type ProfileInfo } from '$lib/app/auth'
// TODO obliterate this file // TODO obliterate this file
export async function blockUser(block: boolean, id: number) { export async function blockUser(block: boolean, id: number) {
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { uploadImage } from '$lib/app/util.svelte' import { uploadImage } from '$lib/app/util.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { site } from '$lib/api/client.svelte' import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import { Menu, Spinner } from 'mono-svelte' import { Menu, Spinner } from 'mono-svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { site } from '$lib/api/client.svelte' import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { theme } from '$lib/app/theme/theme.svelte' import { theme } from '$lib/app/theme/theme.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/state' import { page } from '$app/state'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { theme } from '$lib/app/theme/theme.svelte' import { theme } from '$lib/app/theme/theme.svelte'
import { fuzzySearch } from '$lib/app/util.svelte' import { fuzzySearch } from '$lib/app/util.svelte'
+1 -4
View File
@@ -1,9 +1,6 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/state' import { page } from '$app/state'
import { import { profile as currentProfile, type ProfileInfo } from '$lib/app/auth'
profile as currentProfile,
type ProfileInfo,
} from '$lib/app/auth.svelte'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { theme, type ThemeData } from '$lib/app/theme/theme.svelte' import { theme, type ThemeData } from '$lib/app/theme/theme.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { env } from '$env/dynamic/public' import { env } from '$env/dynamic/public'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DEFAULT_CLIENT_TYPE } from '$lib/api/base' import { DEFAULT_CLIENT_TYPE } from '$lib/api/base'
import { type ProfileInfo, profile } from '$lib/app/auth.svelte' import { type ProfileInfo, profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { import {
DEFAULT_INSTANCE_URL, DEFAULT_INSTANCE_URL,
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { error, redirect } from '@sveltejs/kit' import { error, redirect } from '@sveltejs/kit'
export const ssr = false export const ssr = false
+1 -1
View File
@@ -1,5 +1,5 @@
<script> <script>
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { Tabs } from '$lib/ui/layout' import { Tabs } from '$lib/ui/layout'
import { Badge } from 'mono-svelte' import { Badge } from 'mono-svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { getClient, site } from '$lib/api/client.svelte' import { getClient, site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
export async function load({ fetch }) { export async function load({ fetch }) {
@@ -4,7 +4,7 @@
ApproveRegistrationApplication, ApproveRegistrationApplication,
RegistrationApplicationView, RegistrationApplicationView,
} from '$lib/api/types' } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import ApplicationDenyModal from '$lib/feature/moderation/ApplicationDenyModal.svelte' import ApplicationDenyModal from '$lib/feature/moderation/ApplicationDenyModal.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client, site } from '$lib/api/client.svelte' import { client, site } from '$lib/api/client.svelte'
import type { EditSite } from '$lib/api/types' import type { EditSite } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client, getClient } from '$lib/api/client.svelte' import { client, getClient } from '$lib/api/client.svelte'
import type { Instance } from '$lib/api/types' import type { Instance } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Placeholder from '$lib/ui/info/Placeholder.svelte' import Placeholder from '$lib/ui/info/Placeholder.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte' import { ReactiveState } from '$lib/app/util.svelte'
export async function load({ fetch, url }) { export async function load({ fetch, url }) {
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import type { Tagline } from '$lib/api/types' import type { Tagline } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte' import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { navigating, page } from '$app/state' import { navigating, page } from '$app/state'
import { site } from '$lib/api/client.svelte' import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { setSessionStorage } from '$lib/app/session' import { setSessionStorage } from '$lib/app/session'
import CommunityHeader from '$lib/feature/community/CommunityHeader.svelte' import CommunityHeader from '$lib/feature/community/CommunityHeader.svelte'
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte' import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
import { resolveRoute } from '$app/paths' import { resolveRoute } from '$app/paths'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
export async function load({ params, fetch }) { export async function load({ params, fetch }) {
@@ -3,7 +3,7 @@
import { resolveRoute } from '$app/paths' import { resolveRoute } from '$app/paths'
import { page } from '$app/state' import { page } from '$app/state'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import ProfileButton from '$lib/feature/user/ProfileButton.svelte' import ProfileButton from '$lib/feature/user/ProfileButton.svelte'
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
export async function load({ params }) { export async function load({ params }) {
+1 -1
View File
@@ -5,7 +5,7 @@
CommunityView, CommunityView,
SubscribedType, SubscribedType,
} from '$lib/api/types' } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { toast } from 'mono-svelte' import { toast } from 'mono-svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { site } from '$lib/api/client.svelte' import { site } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { Header, Tabs } from '$lib/ui/layout' import { Header, Tabs } from '$lib/ui/layout'
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
export const load = () => { export const load = () => {
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state' import { page } from '$app/state'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
import Location from '$lib/feature/filter/Location.svelte' import Location from '$lib/feature/filter/Location.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { page } from '$app/state' import { page } from '$app/state'
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { searchParam } from '$lib/app/util.svelte' import { searchParam } from '$lib/app/util.svelte'
import Fixate from '$lib/ui/generic/Fixate.svelte' import Fixate from '$lib/ui/generic/Fixate.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte' import { ReactiveState } from '$lib/app/util.svelte'
import { import {
generalizeCommentReply, generalizeCommentReply,
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
import { escapeHtml } from '$lib/app/util.svelte' import { escapeHtml } from '$lib/app/util.svelte'
+1 -1
View File
@@ -2,7 +2,7 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { resolveRoute } from '$app/paths' import { resolveRoute } from '$app/paths'
import type { Person, PrivateMessageView } from '$lib/api/types' import type { Person, PrivateMessageView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte' import UserAutocomplete from '$lib/feature/user/UserAutocomplete.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte' import Avatar from '$lib/ui/generic/Avatar.svelte'
@@ -2,7 +2,7 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { PrivateMessageResponse } from '$lib/api/types' import type { PrivateMessageResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
+2 -3
View File
@@ -9,7 +9,7 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { LemmyClient } from '$lib/api/lemmy/adapter' import { LemmyClient } from '$lib/api/lemmy/adapter'
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { import {
@@ -75,8 +75,7 @@
// leading HTTPS is redundant // leading HTTPS is redundant
form.instance = form.instance.trim().replace(/^https:\/\//, '') form.instance = form.instance.trim().replace(/^https:\/\//, '')
if (!LINKED_INSTANCE_URL) if (!LINKED_INSTANCE_URL) await checkInstance()
await checkInstance()
const response = await client({ const response = await client({
instanceURL: form.instance, instanceURL: form.instance,
+1 -1
View File
@@ -6,7 +6,7 @@
type ClientType, type ClientType,
DEFAULT_CLIENT_TYPE, DEFAULT_CLIENT_TYPE,
} from '$lib/api/base' } from '$lib/api/base'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte' import { LINKED_INSTANCE_URL } from '$lib/app/instance.svelte'
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { getClient, validateInstance } from '$lib/api/client.svelte' import { getClient, validateInstance } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { import {
+1 -1
View File
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
export function load() { export function load() {
+1 -1
View File
@@ -1,5 +1,5 @@
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte' import { ReactiveState } from '$lib/app/util.svelte'
import { isCommentView, isPostView } from '$lib/feature/legacy/item' import { isCommentView, isPostView } from '$lib/feature/legacy/item'
import { import {
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import CommentItem from '$lib/feature/comment/CommentItem.svelte' import CommentItem from '$lib/feature/comment/CommentItem.svelte'
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import CommunityItem from '$lib/feature/community/CommunityItem.svelte' import CommunityItem from '$lib/feature/community/CommunityItem.svelte'
import { CommonList, Header } from '$lib/ui/layout' import { CommonList, Header } from '$lib/ui/layout'
+1 -1
View File
@@ -2,7 +2,7 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { page } from '$app/state' import { page } from '$app/state'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { searchParam } from '$lib/app/util.svelte' import { searchParam } from '$lib/app/util.svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { getClient, validateInstance } from '$lib/api/client.svelte' import { getClient, validateInstance } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { import {
+1 -1
View File
@@ -1,5 +1,5 @@
import { resolveRoute } from '$app/paths' import { resolveRoute } from '$app/paths'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { error, redirect } from '@sveltejs/kit' import { error, redirect } from '@sveltejs/kit'
export function load({ params }) { export function load({ params }) {
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/state' import { page } from '$app/state'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
@@ -1,10 +1,15 @@
import { resolveRoute } from '$app/paths' import { resolveRoute } from '$app/paths'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import { ReactiveState } from '$lib/app/util.svelte' import { ReactiveState } from '$lib/app/util.svelte'
import CommunityCard from '$lib/feature/community/CommunityCard.svelte' import CommunityCard from '$lib/feature/community/CommunityCard.svelte'
import { Feed, feed, feeds, type FeedTypes } from '$lib/feature/feeds/feed.svelte' import {
Feed,
feed,
feeds,
type FeedTypes,
} from '$lib/feature/feeds/feed.svelte'
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
function buildContext(thread?: string) { function buildContext(thread?: string) {
@@ -29,10 +34,17 @@ function buildContext(thread?: string) {
async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) { async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
// this never actually loads anything // this never actually loads anything
if (id == '/') { if (id == '/') {
return (feeds.get(id) as Feed<FeedTypes['/'][0], FeedTypes['/'][1]>)?.peek() return (feeds.get(id) as Feed<FeedTypes['/'][0], FeedTypes['/'][1]>)
?.peek()
?.posts.find((i) => i.post.id.toString() == postId) ?.posts.find((i) => i.post.id.toString() == postId)
} else { } else {
return (feeds.get(id) as Feed<FeedTypes['/c/[name]'][0], FeedTypes['/c/[name]'][1]>)?.peek() return (
feeds.get(id) as Feed<
FeedTypes['/c/[name]'][0],
FeedTypes['/c/[name]'][1]
>
)
?.peek()
?.posts.find((i) => i.post.id.toString() == postId) ?.posts.find((i) => i.post.id.toString() == postId)
} }
} }
@@ -2,7 +2,7 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { page } from '$app/state' import { page } from '$app/state'
import type { CommentSortType, CommentView, PostView } from '$lib/api/types' import type { CommentSortType, CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { settings } from '$lib/app/settings.svelte' import { settings } from '$lib/app/settings.svelte'
import CommentForm from '$lib/feature/comment/CommentForm.svelte' import CommentForm from '$lib/feature/comment/CommentForm.svelte'
@@ -3,7 +3,7 @@
import { resolveRoute } from '$app/paths' import { resolveRoute } from '$app/paths'
import { page } from '$app/state' import { page } from '$app/state'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import ProfileButton from '$lib/feature/user/ProfileButton.svelte' import ProfileButton from '$lib/feature/user/ProfileButton.svelte'
@@ -1,4 +1,4 @@
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { redirect } from '@sveltejs/kit' import { redirect } from '@sveltejs/kit'
export async function load({ params }) { export async function load({ params }) {
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { communityLink } from '$lib/app/util.svelte.js' import { communityLink } from '$lib/app/util.svelte.js'
import ItemList from '$lib/ui/generic/ItemList.svelte' import ItemList from '$lib/ui/generic/ItemList.svelte'
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import ItemList from '$lib/ui/generic/ItemList.svelte' import ItemList from '$lib/ui/generic/ItemList.svelte'
import Placeholder from '$lib/ui/info/Placeholder.svelte' import Placeholder from '$lib/ui/info/Placeholder.svelte'
@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { userLink } from '$lib/app/util.svelte.js' import { userLink } from '$lib/app/util.svelte.js'
import ItemList from '$lib/ui/generic/ItemList.svelte' import ItemList from '$lib/ui/generic/ItemList.svelte'
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { Button, TextInput, toast } from 'mono-svelte' import { Button, TextInput, toast } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { Button, removeToast, Switch, TextInput, toast } from 'mono-svelte' import { Button, removeToast, Switch, TextInput, toast } from 'mono-svelte'
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { getClient, site } from '$lib/api/client.svelte' import { getClient, site } from '$lib/api/client.svelte'
import type { SaveUserSettings } from '$lib/api/types' import type { SaveUserSettings } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
import ImageInputUpload from '$lib/ui/form/ImageInputUpload.svelte' import ImageInputUpload from '$lib/ui/form/ImageInputUpload.svelte'
+1 -1
View File
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
// disable ssr, as the server cannot be authenticated // disable ssr, as the server cannot be authenticated
+1 -1
View File
@@ -1,5 +1,5 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte' import { ReactiveState } from '$lib/app/util.svelte'
export async function load({ fetch, url }) { export async function load({ fetch, url }) {
+1 -1
View File
@@ -1,6 +1,6 @@
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { CommentView, PostView } from '$lib/api/types' import type { CommentView, PostView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { error } from '@sveltejs/kit' import { error } from '@sveltejs/kit'
function getSavedItemPublished(item: PostView | CommentView) { function getSavedItemPublished(item: PostView | CommentView) {
+1 -1
View File
@@ -1,7 +1,7 @@
import { client, getClient } from '$lib/api/client.svelte' import { client, getClient } from '$lib/api/client.svelte'
import { PiefedClient } from '$lib/api/piefed/adapter' import { PiefedClient } from '$lib/api/piefed/adapter'
import type { ListingType, SearchType, SortType } from '$lib/api/types' import type { ListingType, SearchType, SortType } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { ReactiveState } from '$lib/app/util.svelte' import { ReactiveState } from '$lib/app/util.svelte'
import { getItemPublished } from '$lib/feature/legacy/item' import { getItemPublished } from '$lib/feature/legacy/item'
+1 -1
View File
@@ -4,7 +4,7 @@
import type { ClientType } from '$lib/api/base.js' import type { ClientType } from '$lib/api/base.js'
import { getClient } from '$lib/api/client.svelte' import { getClient } from '$lib/api/client.svelte'
import type { GetCaptchaResponse } from '$lib/api/types' import type { GetCaptchaResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import Markdown from '$lib/app/markdown/Markdown.svelte' import Markdown from '$lib/app/markdown/Markdown.svelte'
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { PersonView } from '$lib/api/types' import type { PersonView } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte' import { profile } from '$lib/app/auth'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import { ban } from '$lib/feature/moderation/moderation' import { ban } from '$lib/feature/moderation/moderation'
import { blockUser, isBlocked } from '$lib/feature/user' import { blockUser, isBlocked } from '$lib/feature/user'