fix: respect always expand content warnings
parent
e9de11000b
commit
16561845f8
|
@ -1,11 +1,13 @@
|
|||
<script setup lang="ts">
|
||||
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)
|
||||
|
||||
watchEffect(() => {
|
||||
showContent.value = !props.enabled
|
||||
showContent.value = expandSpoilersByDefault.value ? true : !props.enabled
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
@ -169,10 +169,23 @@ export async function loginTo(masto: ElkMasto, user: Overwrite<UserLogin, { acco
|
|||
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) {
|
||||
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('@'))
|
||||
account.acct = `${account.acct}@${server}`
|
||||
|
||||
// TODO: lazy load preferences
|
||||
accountPreferencesMap.set(account.acct, preferences)
|
||||
|
||||
cacheAccount(account, server, true)
|
||||
return account
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue