Skip to content

Commit

Permalink
Show github login popup after server response (BloopAI#210)
Browse files Browse the repository at this point in the history
* show github login popup after server response

* bump release version

* fix ts error
  • Loading branch information
anastasiya1155 committed Feb 23, 2023
1 parent 0cc44c9 commit f5594b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bloop"
version = "0.1.0"
version = "0.2.2"
description = "Search code. Fast."
authors = ["Bloop AI Developers"]
license = ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "bloop",
"version": "0.2.1"
"version": "0.2.2"
},
"tauri": {
"allowlist": {
Expand Down
12 changes: 9 additions & 3 deletions client/src/components/PageTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ const PageTemplate = ({ children }: Props) => {
const { isSelfServe } = useContext(DeviceContext);
const { isAnalyticsAllowed, setIsAnalyticsAllowed } =
useContext(AnalyticsContext);
const { isGithubConnected, setOnBoardingState } = useContext(UIContext);
const { isGithubConnected, setOnBoardingState, isGithubChecked } =
useContext(UIContext);
const [isModalOpen, setModalOpen] = useState(false);

useEffect(() => {
if (!isGithubConnected && isAnalyticsAllowed && !isSelfServe) {
if (
isGithubChecked &&
!isGithubConnected &&
isAnalyticsAllowed &&
!isSelfServe
) {
setModalOpen(true);
}
}, []);
}, [isGithubChecked]);

const saveOptIn = useCallback((optIn: boolean) => {
savePlainToStorage(IS_ANALYTICS_ALLOWED_KEY, optIn ? 'true' : 'false');
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/Settings/Settings.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const Default = () => {
setBugReportModalOpen: () => {},
isGithubConnected: false,
setGithubConnected: () => {},
isGithubChecked: true,
}}
>
<RepositoriesContext.Provider
Expand Down Expand Up @@ -77,6 +78,7 @@ export const ScanErrors = () => {
setBugReportModalOpen: () => {},
isGithubConnected: false,
setGithubConnected: () => {},
isGithubChecked: true,
}}
>
<RepositoriesContext.Provider
Expand Down Expand Up @@ -201,6 +203,7 @@ export const EmailConfirmedReposSynced = () => {
setBugReportModalOpen: () => {},
isGithubConnected: true,
setGithubConnected: () => {},
isGithubChecked: true,
}}
>
<RepositoriesContext.Provider
Expand Down
4 changes: 4 additions & 0 deletions client/src/context/providers/UiContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export const UIContextProvider = ({ children }: PropsWithChildren) => {
);
const { isSelfServe } = useContext(DeviceContext);
const [isGithubConnected, setGithubConnected] = useState(isSelfServe);
const [isGithubChecked, setGithubChecked] = useState(false);

useEffect(() => {
if (!isSelfServe) {
gitHubStatus().then((d) => {
setGithubConnected(d.status === 'ok');
setGithubChecked(true);
});
}
}, []);
Expand All @@ -47,6 +49,7 @@ export const UIContextProvider = ({ children }: PropsWithChildren) => {
setBugReportModalOpen,
isGithubConnected,
setGithubConnected,
isGithubChecked,
}),
[
isSettingsOpen,
Expand All @@ -55,6 +58,7 @@ export const UIContextProvider = ({ children }: PropsWithChildren) => {
onBoardingState,
isBugReportModalOpen,
isGithubConnected,
isGithubChecked,
],
);
return (
Expand Down
2 changes: 2 additions & 0 deletions client/src/context/uiContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ContextType = {
setBugReportModalOpen: (b: boolean) => void;
isGithubConnected: boolean;
setGithubConnected: (b: boolean) => void;
isGithubChecked: boolean;
};

export const UIContext = createContext<ContextType>({
Expand All @@ -28,4 +29,5 @@ export const UIContext = createContext<ContextType>({
setBugReportModalOpen: () => {},
isGithubConnected: false,
setGithubConnected: () => {},
isGithubChecked: false,
});

0 comments on commit f5594b3

Please sign in to comment.