fix: respect always expand content warnings

This commit is contained in:
patak 2023-05-04 22:29:47 +02:00
parent e9de11000b
commit 16561845f8
2 changed files with 18 additions and 3 deletions

View file

@ -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
}