misc: change $instance to a $state

This commit is contained in:
James Xylight committed 2025-02-09 11:36:04 -08:00
1 parent 8dcca84e60
commit d8e916d526
26 files changed
+54 -48

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
// maybe fix circular dependency, hopefully.
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public'
import { writable } from 'svelte/store'
import { profile } from './auth.svelte'
export const LINKED_INSTANCE_URL =
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
? env.PUBLIC_INSTANCE_URL
: undefined
const getDefaultInstance = (): string => {
if (browser) {
return env.PUBLIC_INSTANCE_URL || 'lemm.ee'
} else {
return env.PUBLIC_INTERNAL_INSTANCE || env.PUBLIC_INSTANCE_URL || 'lemm.ee'
}
}
export const DEFAULT_INSTANCE_URL = getDefaultInstance()
class InstanceData {
#instance = $derived(profile.data.instance)
get data() {
return this.#instance
}
}
export let instance = new InstanceData()