1
0

fix: remove protocol from instance uri

This commit is contained in:
三咲智子 Kevin Deng 2023-01-20 00:20:56 +08:00
parent c200abcc90
commit eb966976db
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E

View File

@ -1,3 +1,4 @@
import { withoutProtocol } from 'ufo'
import type { mastodon } from 'masto' import type { mastodon } from 'masto'
import type { EffectScope, Ref } from 'vue' import type { EffectScope, Ref } from 'vue'
import type { MaybeComputedRef, RemovableRef } from '@vueuse/core' import type { MaybeComputedRef, RemovableRef } from '@vueuse/core'
@ -68,7 +69,7 @@ const publicInstance = ref<ElkInstance | null>(null)
export const currentInstance = computed<null | ElkInstance>(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value) export const currentInstance = computed<null | ElkInstance>(() => currentUser.value ? instances.value[currentUser.value.server] ?? null : publicInstance.value)
export function getInstanceDomain(instance: ElkInstance) { export function getInstanceDomain(instance: ElkInstance) {
return instance.accountDomain || instance.uri return instance.accountDomain || withoutProtocol(instance.uri)
} }
export const publicServer = ref('') export const publicServer = ref('')
@ -322,7 +323,7 @@ export function clearUserLocalStorage(account?: mastodon.v1.Account) {
if (!account) if (!account)
return return
const id = `${account.acct}@${currentInstance.value?.uri || currentServer.value}` const id = `${account.acct}@${currentInstance.value ? getInstanceDomain(currentInstance.value) : currentServer.value}`
// @ts-expect-error bind value to the function // @ts-expect-error bind value to the function
const cacheMap = useUserLocalStorage._ as Map<string, UseUserLocalStorageCache> | undefined const cacheMap = useUserLocalStorage._ as Map<string, UseUserLocalStorageCache> | undefined