Skip to content

Commit

Permalink
fix: do not show settings if license key is set
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-jianliang committed Apr 6, 2024
1 parent b418fe9 commit 4a1080f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/pages/components/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,17 @@ const ChatBox = React.forwardRef<ChatBoxHandles, Props>(
}, [showSettings]);

useEffect(() => {
apiClient.fetch('GET', '/trail').then(async response => {
const trail = await response.json();
if (trail.remaining < 0) {
setShowSettings(true);
loadSettings().then((settings: EngineSettings) => {
if (settings && settings.apiKey) {
return;
}
setRemainingTrial(trail.remaining);
apiClient.fetch('GET', '/trail').then(async response => {
const trail = await response.json();
if (trail.remaining < 0) {
setShowSettings(true);
}
setRemainingTrial(trail.remaining);
});
});
}, []);

Expand Down Expand Up @@ -264,15 +269,16 @@ const ChatBox = React.forwardRef<ChatBoxHandles, Props>(
};
}, []);

const loadSettings = () => {
getGlobalConfig(GLOBAL_CONFIG_KEY_ENGINE_SETTINGS).then((settings: EngineSettings) => {
const loadSettings = async () => {
return await getGlobalConfig(GLOBAL_CONFIG_KEY_ENGINE_SETTINGS).then((settings: EngineSettings) => {
console.log('load settings', settings);
if (!settings && remainingTrial < 0) {
setShowSettings(true);
return;
}
setSettings(settings);
setShowSettings(false);
return settings;
});
};

Expand Down

0 comments on commit 4a1080f

Please sign in to comment.