fix: circular dependency
This commit is contained in:
1 parent
85468a5059
commit
92dfd91c23
7 files changed
+23
-33
No files matched your search
+9
-10
@@ -1,9 +1,15 @@
|
||||
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { DEFAULT_INSTANCE_URL, getClient, instance } from '$lib/lemmy.js'
|
||||
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { MyUserInfo } from 'lemmy-js-client'
|
||||
import { get, writable } from 'svelte/store'
|
||||
|
||||
const getDefaultProfile = () => ({
|
||||
id: -1,
|
||||
instance: get(profileData)?.defaultInstance ?? get(instance),
|
||||
})
|
||||
|
||||
function getFromStorage<T>(key: string): T | undefined {
|
||||
if (typeof localStorage == 'undefined') return undefined
|
||||
const lc = localStorage.getItem(key)
|
||||
@@ -40,7 +46,7 @@ interface PersonData extends MyUserInfo {
|
||||
reports: number
|
||||
}
|
||||
|
||||
export const profileData = writable<ProfileData>(
|
||||
export let profileData = writable<ProfileData>(
|
||||
getFromStorage<ProfileData>('profileData') ?? { profiles: [], profile: -1 }
|
||||
)
|
||||
|
||||
@@ -58,7 +64,7 @@ profileData.subscribe(async (pd) => {
|
||||
}
|
||||
})
|
||||
|
||||
export const profile = writable<Profile | undefined>(getProfile())
|
||||
export let profile = writable<Profile | undefined>(getProfile())
|
||||
|
||||
profile.subscribe(async (p) => {
|
||||
if (p?.id == -1) {
|
||||
@@ -149,13 +155,6 @@ function getProfile() {
|
||||
return pd.profiles.find((p) => p.id == id)
|
||||
}
|
||||
|
||||
function getDefaultProfile() {
|
||||
return {
|
||||
id: -1,
|
||||
instance: get(profileData)?.defaultInstance ?? get(instance),
|
||||
}
|
||||
}
|
||||
|
||||
export function resetProfile() {
|
||||
profile.set(getDefaultProfile())
|
||||
profileData.update((p) => ({ ...p, profile: -1 }))
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { LINKED_INSTANCE_URL, instance, site } from '$lib/lemmy.js'
|
||||
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import {
|
||||
ArrowLeftOnRectangle,
|
||||
ArrowRightOnRectangle,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// maybe fix circular dependency, hopefully.
|
||||
|
||||
import { env } from '$env/dynamic/public'
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
export const LINKED_INSTANCE_URL = env.PUBLIC_INSTANCE_URL
|
||||
export const DEFAULT_INSTANCE_URL = env.PUBLIC_INSTANCE_URL || 'lemmy.ml'
|
||||
export let instance = writable(DEFAULT_INSTANCE_URL)
|
||||
+1
-4
@@ -8,10 +8,7 @@ import { get, writable } from 'svelte/store'
|
||||
import { env } from '$env/dynamic/public'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { error } from '@sveltejs/kit'
|
||||
|
||||
export const LINKED_INSTANCE_URL = env.PUBLIC_INSTANCE_URL
|
||||
export const DEFAULT_INSTANCE_URL = env.PUBLIC_INSTANCE_URL || 'lemmy.ml'
|
||||
export let instance = writable(DEFAULT_INSTANCE_URL)
|
||||
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
|
||||
async function customFetch(
|
||||
func: (
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
import TextInput from '$lib/components/input/TextInput.svelte'
|
||||
import EditableList from '$lib/components/ui/list/EditableList.svelte'
|
||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import {
|
||||
LINKED_INSTANCE_URL,
|
||||
instance,
|
||||
validateInstance,
|
||||
} from '$lib/lemmy.js'
|
||||
import { ArrowLeftOnRectangle, Icon, Plus, Trash } from 'svelte-hero-icons'
|
||||
|
||||
@@ -5,12 +5,8 @@
|
||||
import TextInput from '$lib/components/input/TextInput.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import {
|
||||
DEFAULT_INSTANCE_URL,
|
||||
LINKED_INSTANCE_URL,
|
||||
getClient,
|
||||
validateInstance,
|
||||
} from '$lib/lemmy.js'
|
||||
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||
import { getClient, validateInstance } from '$lib/lemmy.js'
|
||||
|
||||
let data = {
|
||||
instance: DEFAULT_INSTANCE_URL,
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
<script lang="ts">
|
||||
import Switch from '$lib/components/input/Switch.svelte'
|
||||
import TextInput from '$lib/components/input/TextInput.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import {
|
||||
LINKED_INSTANCE_URL,
|
||||
instance,
|
||||
validateInstance,
|
||||
} from '$lib/lemmy.js'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import Setting from './Setting.svelte'
|
||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||
import Sort from '$lib/components/lemmy/Sort.svelte'
|
||||
|
||||
Reference in new issue
Block a user