Skip to content

Commit

Permalink
🐛 fix: fix url config import after user state init (lobehub#4072)
Browse files Browse the repository at this point in the history
* 🐛 fix: settings import

* ♻️ refactor: remove selctor

* ♻️ refactor: add pr ref
  • Loading branch information
cy948 authored Sep 24, 2024
1 parent 7f032d2 commit 18a240c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/layout/GlobalProvider/StoreInitialization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ const StoreInitialization = memo(() => {
useTranslation('error');

const router = useRouter();
const [isLogin, isSignedIn, useInitUserState, importUrlShareSettings] = useUserStore((s) => [
authSelectors.isLogin(s),
s.isSignedIn,
s.useInitUserState,
s.importUrlShareSettings,
]);
const [isLogin, isSignedIn, useInitUserState, importUrlShareSettings, isUserStateInit] =
useUserStore((s) => [
authSelectors.isLogin(s),
s.isSignedIn,
s.useInitUserState,
s.importUrlShareSettings,
s.isUserStateInit,
]);

const { serverConfig } = useServerConfigStore();

Expand Down Expand Up @@ -74,8 +76,10 @@ const StoreInitialization = memo(() => {
// Import settings from the url
const searchParam = useSearchParams().get(LOBE_URL_IMPORT_NAME);
useEffect(() => {
importUrlShareSettings(searchParam);
}, [searchParam]);
// Why use `usUserStateInit`,
// see: https://github.com/lobehub/lobe-chat/pull/4072
if (searchParam && isUserStateInit) importUrlShareSettings(searchParam);
}, [searchParam, isUserStateInit]);

useEffect(() => {
if (mobile) {
Expand Down

0 comments on commit 18a240c

Please sign in to comment.