@lobehub/chat 0.128.0 → 0.128.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.128.1](https://github.com/lobehub/lobe-chat/compare/v0.128.0...v0.128.1)
6
+
7
+ <sup>Released on **2024-02-15**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix auto lang switch.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix auto lang switch, closes [#1305](https://github.com/lobehub/lobe-chat/issues/1305) ([7a51329](https://github.com/lobehub/lobe-chat/commit/7a51329))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ## [Version 0.128.0](https://github.com/lobehub/lobe-chat/compare/v0.127.2...v0.128.0)
6
31
 
7
32
  <sup>Released on **2024-02-14**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.128.0",
3
+ "version": "0.128.1",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -5,10 +5,7 @@ import useSWR from 'swr';
5
5
 
6
6
  import { createI18nNext } from '@/locales/create';
7
7
  import { normalizeLocale } from '@/locales/resources';
8
- import { useOnFinishHydrationGlobal } from '@/store/global';
9
- import { settingsSelectors } from '@/store/global/selectors';
10
8
  import { isOnServerSide } from '@/utils/env';
11
- import { switchLang } from '@/utils/switchLang';
12
9
 
13
10
  const getAntdLocale = async (lang?: string) => {
14
11
  let normalLang = normalizeLocale(lang);
@@ -50,12 +47,6 @@ const Locale = memo<LocaleLayoutProps>(({ children, defaultLang }) => {
50
47
  });
51
48
  }
52
49
 
53
- useOnFinishHydrationGlobal((s) => {
54
- if (settingsSelectors.currentSettings(s).language === 'auto') {
55
- switchLang('auto');
56
- }
57
- }, []);
58
-
59
50
  // handle i18n instance language change
60
51
  useEffect(() => {
61
52
  const handleLang = (e: string) => {
@@ -2,7 +2,8 @@ import { useResponsive } from 'antd-style';
2
2
  import { useRouter } from 'next/navigation';
3
3
  import { memo, useEffect } from 'react';
4
4
 
5
- import { useEffectAfterGlobalHydrated, useGlobalStore } from '@/store/global';
5
+ import { useGlobalStore } from '@/store/global';
6
+ import { useEffectAfterGlobalHydrated } from '@/store/global/hooks/useEffectAfterHydrated';
6
7
 
7
8
  const StoreHydration = memo(() => {
8
9
  const [useFetchServerConfig, useFetchUserConfig] = useGlobalStore((s) => [
@@ -1,2 +1 @@
1
- export * from './hooks';
2
1
  export * from './store';
@@ -12,6 +12,9 @@ import type { GlobalStore } from '@/store/global';
12
12
  import type { GlobalServerConfig, GlobalSettings } from '@/types/settings';
13
13
  import { merge } from '@/utils/merge';
14
14
  import { setNamespace } from '@/utils/storeDebug';
15
+ import { switchLang } from '@/utils/switchLang';
16
+
17
+ import { settingsSelectors } from '../settings/selectors';
15
18
 
16
19
  const n = setNamespace('common');
17
20
 
@@ -82,6 +85,11 @@ export const createCommonSlice: StateCreator<
82
85
  if (!data) return;
83
86
 
84
87
  set({ avatar: data.avatar, settings: data.settings }, false, n('fetchUserConfig', data));
88
+
89
+ const { language } = settingsSelectors.currentSettings(get());
90
+ if (language === 'auto') {
91
+ switchLang('auto');
92
+ }
85
93
  },
86
94
  revalidateOnFocus: false,
87
95
  },
@@ -1,3 +0,0 @@
1
- export * from './useEffectAfterHydrated';
2
- export * from './useOnFinishHydrationGlobal';
3
-
@@ -1,16 +0,0 @@
1
- import { useEffect } from 'react';
2
-
3
- import { GlobalStore, useGlobalStore } from '../store';
4
-
5
- /**
6
- * 当 Session 水合完毕后才会执行的 useEffect
7
- * @param fn
8
- * @param deps
9
- */
10
- export const useOnFinishHydrationGlobal = (fn: (state: GlobalStore) => void, deps: any[] = []) => {
11
- useEffect(() => {
12
- useGlobalStore.persist.onFinishHydration(() => {
13
- fn(useGlobalStore.getState());
14
- });
15
- }, deps);
16
- };