feat: respect Media Display preferences (#2065)
This commit is contained in:
parent
a3116e703a
commit
d9e7a09d24
5 changed files with 49 additions and 10 deletions
|
@ -170,10 +170,28 @@ export async function loginTo(masto: ElkMasto, user: Overwrite<UserLogin, { acco
|
|||
}
|
||||
|
||||
const accountPreferencesMap = new Map<string, mastodon.v1.Preference>()
|
||||
|
||||
/**
|
||||
* @returns `true` when user ticked the preference to always expand posts with content warnings
|
||||
*/
|
||||
export function getExpandSpoilersByDefault(account: mastodon.v1.AccountCredentials) {
|
||||
return accountPreferencesMap.get(account.acct)?.['reading:expand:spoilers'] ?? false
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns `true` when user selected "Always show media" as Media Display preference
|
||||
*/
|
||||
export function getExpandMediaByDefault(account: mastodon.v1.AccountCredentials) {
|
||||
return accountPreferencesMap.get(account.acct)?.['reading:expand:media'] === 'show_all' ?? false
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns `true` when user selected "Always hide media" as Media Display preference
|
||||
*/
|
||||
export function getHideMediaByDefault(account: mastodon.v1.AccountCredentials) {
|
||||
return accountPreferencesMap.get(account.acct)?.['reading:expand:media'] === 'hide_all' ?? false
|
||||
}
|
||||
|
||||
export async function fetchAccountInfo(client: mastodon.Client, server: string) {
|
||||
const [account, preferences] = await Promise.all([
|
||||
client.v1.accounts.verifyCredentials(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue