Improve the language behaviors around the PWI (#3545)
* Handle leftnav overflow with longer languages' copy * Update the language dropdown to set ALL language prefs * Add hackfix to language cachebusting on PWI * Reset feeds on language change
This commit is contained in:
parent
23056daa29
commit
0b43d728e4
6 changed files with 111 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
import React from 'react'
|
||||
import * as persisted from '#/state/persisted'
|
||||
|
||||
import {AppLanguage} from '#/locale/languages'
|
||||
import * as persisted from '#/state/persisted'
|
||||
|
||||
type SetStateCb = (
|
||||
s: persisted.Schema['languagePrefs'],
|
||||
|
@ -9,6 +10,7 @@ type StateContext = persisted.Schema['languagePrefs']
|
|||
type ApiContext = {
|
||||
setPrimaryLanguage: (code2: string) => void
|
||||
setPostLanguage: (commaSeparatedLangCodes: string) => void
|
||||
setContentLanguage: (code2: string) => void
|
||||
toggleContentLanguage: (code2: string) => void
|
||||
togglePostLanguage: (code2: string) => void
|
||||
savePostLanguageToHistory: () => void
|
||||
|
@ -21,6 +23,7 @@ const stateContext = React.createContext<StateContext>(
|
|||
const apiContext = React.createContext<ApiContext>({
|
||||
setPrimaryLanguage: (_: string) => {},
|
||||
setPostLanguage: (_: string) => {},
|
||||
setContentLanguage: (_: string) => {},
|
||||
toggleContentLanguage: (_: string) => {},
|
||||
togglePostLanguage: (_: string) => {},
|
||||
savePostLanguageToHistory: () => {},
|
||||
|
@ -53,6 +56,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||
setPostLanguage(commaSeparatedLangCodes: string) {
|
||||
setStateWrapped(s => ({...s, postLanguage: commaSeparatedLangCodes}))
|
||||
},
|
||||
setContentLanguage(code2: string) {
|
||||
setStateWrapped(s => ({...s, contentLanguages: [code2]}))
|
||||
},
|
||||
toggleContentLanguage(code2: string) {
|
||||
setStateWrapped(s => {
|
||||
const exists = s.contentLanguages.includes(code2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue