feat: improve AI Chat UX, add notebook summary, and fix shared/reminders routing
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m50s
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m50s
This commit is contained in:
@@ -31,15 +31,23 @@ export function LanguageProvider({ children, initialLanguage = 'en', initialTran
|
||||
initialLanguage?: SupportedLanguage
|
||||
initialTranslations?: Translations
|
||||
}) {
|
||||
// Use server-provided initialLanguage for the first render to prevent hydration mismatch.
|
||||
// Use server-provided initialLanguage and translations for the first render
|
||||
// to ensure client hydration matches server HTML exactly.
|
||||
const [language, setLanguageState] = useState<SupportedLanguage>(initialLanguage)
|
||||
|
||||
// Start with server-provided translations or English fallback
|
||||
const [translations, setTranslations] = useState<Translations>(
|
||||
(initialTranslations || enTranslations) as unknown as Translations
|
||||
)
|
||||
// Start with server-provided translations or fallback to English ONLY if it's the requested language
|
||||
const [translations, setTranslations] = useState<Translations>(() => {
|
||||
if (initialTranslations) return initialTranslations
|
||||
return enTranslations as unknown as Translations
|
||||
})
|
||||
|
||||
const cacheRef = useRef<Map<SupportedLanguage, Translations>>(new Map())
|
||||
|
||||
// Initialize cache with initial translations to prevent redundant loading
|
||||
if (initialTranslations && !cacheRef.current.has(initialLanguage)) {
|
||||
cacheRef.current.set(initialLanguage, initialTranslations)
|
||||
}
|
||||
|
||||
const isFirstRender = useRef(true)
|
||||
|
||||
// Load saved preference from localStorage AFTER hydration
|
||||
@@ -74,6 +82,7 @@ export function LanguageProvider({ children, initialLanguage = 'en', initialTran
|
||||
const setLanguage = useCallback((lang: SupportedLanguage) => {
|
||||
setLanguageState(lang)
|
||||
localStorage.setItem('user-language', lang)
|
||||
document.cookie = `user-language=${lang};path=/;max-age=${60 * 60 * 24 * 365};samesite=lax`
|
||||
updateDocumentDirection(lang)
|
||||
}, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user