Skip to content

Commit

Permalink
setShowAuthModal in useEffect to ensure state is fresh
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper committed Feb 19, 2025
1 parent cf0c770 commit 80389b4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,19 @@ function Screen() {
const shouldTightBorder =
getClientConfig()?.isApp || (config.tightBorder && !isMobileScreen);
const [showAuthModal, setShowAuthModal] = useState<boolean>(
!useAccessStore.getState().isValidSiliconFlow(),
() => !useAccessStore.getState().isValidSiliconFlow(),
);
useEffect(() => {
loadAsyncGoogleFont();
return useAccessStore.subscribe((state, prevState) => {
const sub = useAccessStore.subscribe((state, prevState) => {
if (state.siliconflowApiKey !== prevState.siliconflowApiKey) {
console.log("SiliconFlow API Key changed", state.siliconflowApiKey);
setShowAuthModal(!state.siliconflowApiKey);
}
});
setShowAuthModal(!useAccessStore.getState().isValidSiliconFlow());
return sub;
}, []);

if (isArtifact) {
return (
<Routes>
Expand Down

0 comments on commit 80389b4

Please sign in to comment.