-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement in-app update notifications
1 parent
59d792a
commit 7a33eb5
Showing
9 changed files
with
189 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import packageJson from '@root/package.json'; | ||
import { compare } from 'compare-versions'; | ||
|
||
import { useMemo } from 'react'; | ||
|
||
import { useAppSelector } from '@/store'; | ||
|
||
const useHasNewAppVersion = () => { | ||
const appRelease = useAppSelector( | ||
state => state.github.latestAppRelease?.data, | ||
); | ||
|
||
return useMemo(() => { | ||
if (!appRelease) return [false, null] as const; | ||
|
||
const newAppVersionAvailable = compare( | ||
appRelease?.tag_name, | ||
packageJson.version, | ||
'>', | ||
); | ||
|
||
return [newAppVersionAvailable, appRelease] as const; | ||
}, [appRelease]); | ||
}; | ||
|
||
export default useHasNewAppVersion; |
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