-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issue-64_hide-settings-and-searches' into 'master'
Hide settings and searches tab until account setup is complete See merge request c-hive/poe-sniper-electron!70
- Loading branch information
Showing
15 changed files
with
94 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
app/renderer/components/withLoggedOutRedirection/withLoggedOutRedirection.js
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
app/renderer/components/withRouteRestriction/withRouteRestriction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { ipcRenderer } from "electron"; | ||
import { Redirect } from "react-router-dom"; | ||
import { globalStore } from "../../../GlobalStore/GlobalStore"; | ||
import { storeKeys } from "../../../resources/StoreKeys/StoreKeys"; | ||
import { ipcEvents } from "../../../resources/IPCEvents/IPCEvents"; | ||
import Loader from "../UI/Loader/Loader"; | ||
|
||
const withRouteRestriction = WrappedComponent => { | ||
return ({ ...props }) => { | ||
const isLoggedIn = globalStore.get(storeKeys.IS_LOGGED_IN, false); | ||
const poeSessionId = globalStore.get(storeKeys.POE_SESSION_ID); | ||
const [isPaying, setIsPaying] = useState(false); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
ipcRenderer.send(ipcEvents.GET_PAYING_STATUS); | ||
|
||
ipcRenderer.on(ipcEvents.SEND_PAYING_STATUS, (event, payingStatus) => { | ||
setIsPaying(payingStatus); | ||
|
||
setIsLoading(false); | ||
}); | ||
|
||
return () => ipcRenderer.removeAllListeners(); | ||
}, []); | ||
|
||
function conditionsAreFulfilled() { | ||
return isLoggedIn && poeSessionId && isPaying; | ||
} | ||
|
||
if (isLoading) { | ||
return <Loader />; | ||
} | ||
|
||
if (conditionsAreFulfilled()) { | ||
return <WrappedComponent {...props} />; | ||
} | ||
|
||
return <Redirect to="/account" />; | ||
}; | ||
}; | ||
|
||
export default withRouteRestriction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.