storkit: merge 446_story_oauth_login_button_in_web_ui
This commit is contained in:
+28
-1
@@ -1,4 +1,5 @@
|
||||
import * as React from "react";
|
||||
import type { OAuthStatus } from "./api/client";
|
||||
import { api } from "./api/client";
|
||||
import { Chat } from "./components/Chat";
|
||||
import { SelectionScreen } from "./components/selection/SelectionScreen";
|
||||
@@ -14,6 +15,27 @@ function App() {
|
||||
const [isOpening, setIsOpening] = React.useState(false);
|
||||
const [knownProjects, setKnownProjects] = React.useState<string[]>([]);
|
||||
const [homeDir, setHomeDir] = React.useState<string | null>(null);
|
||||
const [oauthStatus, setOauthStatus] = React.useState<OAuthStatus | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
let active = true;
|
||||
function fetchOAuthStatus() {
|
||||
api
|
||||
.getOAuthStatus()
|
||||
.then((s) => {
|
||||
if (active) setOauthStatus(s);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
fetchOAuthStatus();
|
||||
const intervalId = window.setInterval(fetchOAuthStatus, 5000);
|
||||
return () => {
|
||||
active = false;
|
||||
window.clearInterval(intervalId);
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
api
|
||||
@@ -182,10 +204,15 @@ function App() {
|
||||
onCloseSuggestions={closeSuggestions}
|
||||
completionError={completionError}
|
||||
currentPartial={currentPartial}
|
||||
oauthStatus={oauthStatus}
|
||||
/>
|
||||
) : (
|
||||
<div className="workspace" style={{ height: "100%" }}>
|
||||
<Chat projectPath={projectPath} onCloseProject={closeProject} />
|
||||
<Chat
|
||||
projectPath={projectPath}
|
||||
onCloseProject={closeProject}
|
||||
oauthStatus={oauthStatus}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user