fix: respect always expand content warnings
This commit is contained in:
parent
e9de11000b
commit
16561845f8
|
@ -1,11 +1,13 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{ enabled?: boolean; filter?: boolean; isDM?: boolean }>()
|
const props = defineProps<{ enabled?: boolean; filter?: boolean; isDM?: boolean }>()
|
||||||
|
|
||||||
const showContent = ref(!props.enabled)
|
const expandSpoilersByDefault = computed(() => currentUser.value ? getExpandSpoilersByDefault(currentUser.value.account) : false)
|
||||||
|
|
||||||
|
const showContent = ref(expandSpoilersByDefault.value ? true : !props.enabled)
|
||||||
const toggleContent = useToggle(showContent)
|
const toggleContent = useToggle(showContent)
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
showContent.value = !props.enabled
|
showContent.value = expandSpoilersByDefault.value ? true : !props.enabled
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -169,10 +169,23 @@ export async function loginTo(masto: ElkMasto, user: Overwrite<UserLogin, { acco
|
||||||
currentUserHandle.value = me.acct
|
currentUserHandle.value = me.acct
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const accountPreferencesMap = new Map<string, mastodon.v1.Preference>()
|
||||||
|
export function getExpandSpoilersByDefault(account: mastodon.v1.AccountCredentials) {
|
||||||
|
return accountPreferencesMap.get(account.acct)?.['reading:expand:spoilers'] ?? false
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchAccountInfo(client: mastodon.Client, server: string) {
|
export async function fetchAccountInfo(client: mastodon.Client, server: string) {
|
||||||
const account = await client.v1.accounts.verifyCredentials()
|
const [account, preferences] = await Promise.all([
|
||||||
|
client.v1.accounts.verifyCredentials(),
|
||||||
|
client.v1.preferences.fetch(),
|
||||||
|
])
|
||||||
|
|
||||||
if (!account.acct.includes('@'))
|
if (!account.acct.includes('@'))
|
||||||
account.acct = `${account.acct}@${server}`
|
account.acct = `${account.acct}@${server}`
|
||||||
|
|
||||||
|
// TODO: lazy load preferences
|
||||||
|
accountPreferencesMap.set(account.acct, preferences)
|
||||||
|
|
||||||
cacheAccount(account, server, true)
|
cacheAccount(account, server, true)
|
||||||
return account
|
return account
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue