mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-22 21:43:09 +02:00
refactor: Simplify some parts of the post form language handling
This commit is contained in:
parent
d534a1cded
commit
8860e6866b
1 changed files with 9 additions and 7 deletions
|
@ -34,7 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
<button v-click-anime v-tooltip="i18n.ts.language" :class="['_button', $style.headerRightItem]" @click="setLanguage">
|
<button v-click-anime v-tooltip="i18n.ts.language" :class="['_button', $style.headerRightItem]" @click="setLanguage">
|
||||||
<span><i class="ph-translate ph-bold ph-lg"></i></span>
|
<span><i class="ph-translate ph-bold ph-lg"></i></span>
|
||||||
<span v-if="language !== '' && language != null" :class="$style.headerRightButtonText">{{ language }}</span>
|
<span v-if="language" :class="$style.headerRightButtonText">{{ language }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button v-click-anime v-tooltip="i18n.ts._visibility.disableFederation" class="_button" :class="[$style.headerRightItem, { [$style.danger]: localOnly }]" :disabled="channel != null || visibility === 'specified'" @click="toggleLocalOnly">
|
<button v-click-anime v-tooltip="i18n.ts._visibility.disableFederation" class="_button" :class="[$style.headerRightItem, { [$style.danger]: localOnly }]" :disabled="channel != null || visibility === 'specified'" @click="toggleLocalOnly">
|
||||||
<span v-if="!localOnly"><i class="ph-rocket-launch ph-bold ph-lg"></i></span>
|
<span v-if="!localOnly"><i class="ph-rocket-launch ph-bold ph-lg"></i></span>
|
||||||
|
@ -845,7 +845,7 @@ async function post(ev?: MouseEvent) {
|
||||||
channelId: props.channel ? props.channel.id : undefined,
|
channelId: props.channel ? props.channel.id : undefined,
|
||||||
poll: poll.value,
|
poll: poll.value,
|
||||||
cw: useCw.value ? cw.value ?? '' : null,
|
cw: useCw.value ? cw.value ?? '' : null,
|
||||||
lang: language.value ? language.value : null,
|
lang: language.value ?? null,
|
||||||
localOnly: localOnly.value,
|
localOnly: localOnly.value,
|
||||||
visibility: visibility.value,
|
visibility: visibility.value,
|
||||||
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(u => u.id) : undefined,
|
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(u => u.id) : undefined,
|
||||||
|
@ -957,10 +957,12 @@ async function post(ev?: MouseEvent) {
|
||||||
// update recentlyUsedLanguages
|
// update recentlyUsedLanguages
|
||||||
if (language.value != null) {
|
if (language.value != null) {
|
||||||
const maxLength = 6;
|
const maxLength = 6;
|
||||||
|
const filteredRecentlyUsed = defaultStore.state.recentlyUsedPostLanguages.filter((lang) => {
|
||||||
defaultStore.set('recentlyUsedPostLanguages', [language.value].concat(defaultStore.state.recentlyUsedPostLanguages.filter((lang) => {
|
|
||||||
return (lang !== language.value && langs.includes(lang));
|
return (lang !== language.value && langs.includes(lang));
|
||||||
})).slice(0, maxLength));
|
});
|
||||||
|
const recentlyUsedLangs = [language.value].concat(filteredRecentlyUsed).slice(0, maxLength);
|
||||||
|
|
||||||
|
defaultStore.set('recentlyUsedPostLanguages', recentlyUsedLangs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue