fix: reference conflicts
This commit is contained in:
parent
2bee673a14
commit
d546390f5c
|
@ -48,16 +48,16 @@ function mentionHTML(acct: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReplyDraft(status: Status) {
|
export function getReplyDraft(status: Status) {
|
||||||
const acountsToMention: string[] = []
|
const accountsToMention: string[] = []
|
||||||
const userId = currentUser.value?.account.id
|
const userId = currentUser.value?.account.id
|
||||||
if (status.account.id !== userId)
|
if (status.account.id !== userId)
|
||||||
acountsToMention.push(status.account.acct)
|
accountsToMention.push(status.account.acct)
|
||||||
acountsToMention.push(...(status.mentions.filter(mention => mention.id !== userId).map(mention => mention.acct)))
|
accountsToMention.push(...(status.mentions.filter(mention => mention.id !== userId).map(mention => mention.acct)))
|
||||||
return {
|
return {
|
||||||
key: `reply-${status.id}`,
|
key: `reply-${status.id}`,
|
||||||
draft: () => {
|
draft: () => {
|
||||||
return getDefaultDraft({
|
return getDefaultDraft({
|
||||||
initialText: acountsToMention.map(acct => mentionHTML(acct)).join(' '),
|
initialText: accountsToMention.map(acct => mentionHTML(acct)).join(' '),
|
||||||
inReplyToId: status!.id,
|
inReplyToId: status!.id,
|
||||||
visibility: status.visibility,
|
visibility: status.visibility,
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,6 +20,11 @@ export const currentUser = computed<UserLogin | undefined>(() => {
|
||||||
return users.value[0]
|
return users.value[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const currentUserHandle = computed(() => currentUser.value?.account.id
|
||||||
|
? `${currentUser.value.account.acct}@${currentUser.value.server}`
|
||||||
|
: '[anonymous]',
|
||||||
|
)
|
||||||
|
|
||||||
export const publicServer = ref(DEFAULT_SERVER)
|
export const publicServer = ref(DEFAULT_SERVER)
|
||||||
const publicInstance = ref<Instance | null>(null)
|
const publicInstance = ref<Instance | null>(null)
|
||||||
export const currentServer = computed<string>(() => currentUser.value?.server || publicServer.value)
|
export const currentServer = computed<string>(() => currentUser.value?.server || publicServer.value)
|
||||||
|
@ -153,29 +158,23 @@ export function checkLogin() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const userLocalStorages = new Map<string, Ref<Record<string, any>>>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create reactive storage for the current user
|
* Create reactive storage for the current user
|
||||||
*/
|
*/
|
||||||
export function useUserLocalStorage<T extends object>(key: string, initial: () => T) {
|
export function useUserLocalStorage<T extends object>(key: string, initial: () => T) {
|
||||||
if (!userLocalStorages.has(key))
|
// @ts-expect-error bind value to the function
|
||||||
userLocalStorages.set(key, useLocalStorage(key, {}, { deep: true }))
|
const storages = useUserLocalStorage._ = useUserLocalStorage._ || new Map<string, Ref<Record<string, any>>>()
|
||||||
|
|
||||||
const all = userLocalStorages.get(key) as Ref<Record<string, T>>
|
if (!storages.has(key))
|
||||||
|
storages.set(key, useLocalStorage(key, {}, { deep: true }))
|
||||||
|
const all = storages.get(key) as Ref<Record<string, T>>
|
||||||
|
|
||||||
|
return computed(() => {
|
||||||
const id = currentUser.value?.account.id
|
const id = currentUser.value?.account.id
|
||||||
? `${currentUser.value.account.acct}@${currentUser.value.server}`
|
? `${currentUser.value.account.acct}@${currentUser.value.server}`
|
||||||
: '[anonymous]'
|
: '[anonymous]'
|
||||||
|
|
||||||
all.value[id] = Object.assign(initial(), all.value[id] || {})
|
all.value[id] = Object.assign(initial(), all.value[id] || {})
|
||||||
return extendRef(
|
return all.value[id]
|
||||||
computed(() => all.value[id]),
|
|
||||||
{
|
|
||||||
remove: {
|
|
||||||
value: () => {
|
|
||||||
delete all.value[id]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue