forked from equinor/witsml-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX-2361 Support multiple windows in desktop app (equinor#2388)
- Loading branch information
1 parent
6ac6a63
commit f100d0f
Showing
11 changed files
with
150 additions
and
94 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
38 changes: 0 additions & 38 deletions
38
Src/WitsmlExplorer.Frontend/components/CloseDesktopAppHandler.tsx
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
50 changes: 50 additions & 0 deletions
50
Src/WitsmlExplorer.Frontend/components/DesktopAppEventHandler.tsx
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,50 @@ | ||
import JobStatus from "models/jobStatus"; | ||
import { ReactElement, useCallback, useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import JobService from "services/jobService"; | ||
|
||
export function DesktopAppEventHandler(): ReactElement { | ||
const navigate = useNavigate(); | ||
|
||
const onCloseWindowListener = useCallback(async () => { | ||
const jobInfos = await JobService.getAllJobInfos(); | ||
|
||
const unfinishedJobs = jobInfos.filter( | ||
(jobInfo) => jobInfo.status === JobStatus.Started | ||
); | ||
|
||
if (unfinishedJobs.length > 0) { | ||
// @ts-ignore | ||
window.electronAPI.closeWindowResponse(true); | ||
} else { | ||
// @ts-ignore | ||
window.electronAPI.closeWindowResponse(false); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
// @ts-ignore | ||
window.electronAPI.onCloseWindow(onCloseWindowListener); | ||
|
||
return () => { | ||
// @ts-ignore | ||
window.electronAPI.removeCloseWindowListener(onCloseWindowListener); | ||
}; | ||
}, [onCloseWindowListener]); | ||
|
||
const onNavigateListener = useCallback((route: string) => { | ||
navigate(route); | ||
}, []); | ||
|
||
useEffect(() => { | ||
// @ts-ignore | ||
window.electronAPI.onNavigate(onNavigateListener); | ||
|
||
return () => { | ||
// @ts-ignore | ||
window.electronAPI.removeNavigateListener(onNavigateListener); | ||
}; | ||
}, [onNavigateListener]); | ||
|
||
return null; | ||
} |
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.