fix: default user language when writing a publication (#1446)

zio/stable
victordelva 2023-01-25 16:41:09 +01:00 committed by GitHub
parent 255c341a78
commit adb17d7f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -33,7 +33,7 @@ export function getDefaultDraft(options: Partial<Mutable<mastodon.v1.CreateStatu
visibility: visibility || 'public', visibility: visibility || 'public',
sensitive: sensitive ?? false, sensitive: sensitive ?? false,
spoilerText: spoilerText || '', spoilerText: spoilerText || '',
language: language || 'en', language: language || getDefaultLanguage(),
}, },
mentions, mentions,
lastUpdated: Date.now(), lastUpdated: Date.now(),
@ -52,6 +52,16 @@ export async function getDraftFromStatus(status: mastodon.v1.Status): Promise<Dr
}) })
} }
function getDefaultLanguage() {
const userSettings = useUserSettings()
const defaultLanguage = userSettings.value.language
if (defaultLanguage)
return defaultLanguage.split('-')[0]
return 'en'
}
function getAccountsToMention(status: mastodon.v1.Status) { function getAccountsToMention(status: mastodon.v1.Status) {
const userId = currentUser.value?.account.id const userId = currentUser.value?.account.id
const accountsToMention = new Set<string>() const accountsToMention = new Set<string>()