-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:Detect new upgrade on launch (#2783)
* feat:Detect new upgrade on launch * refactor: Refactor update logic * feat: Add log for electron updater. * Fix: Add badge for unexpanded and add icon for update --------- Co-authored-by: Jun Ma <[email protected]>
- Loading branch information
1 parent
0d23958
commit 34fff73
Showing
14 changed files
with
239 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Dispatch, SetStateAction, useCallback, useMemo, useState } from 'react' | ||
import { cancelCheckUpdates, cancelDownloadUpdate, checkForUpdates } from 'services/remote' | ||
|
||
export const useUpdateDownloadStatus = ({ | ||
setShowCheckDialog, | ||
downloadProgress, | ||
}: { | ||
setShowCheckDialog: Dispatch<SetStateAction<boolean>> | ||
downloadProgress: number | ||
}) => { | ||
const [showUpdateDownloadStatus, setShowUpdateDownloadStatus] = useState(false) | ||
const openShowUpdateDownloadStatus = useCallback(() => { | ||
setShowUpdateDownloadStatus(true) | ||
}, []) | ||
const onCheckUpdate = useCallback(() => { | ||
setShowCheckDialog(true) | ||
checkForUpdates() | ||
}, [setShowCheckDialog]) | ||
const hasStartDownload = useMemo(() => downloadProgress >= 0, [downloadProgress]) | ||
return { | ||
showUpdateDownloadStatus, | ||
openShowUpdateDownloadStatus, | ||
onCheckUpdate, | ||
onCancel: useCallback(() => { | ||
if (hasStartDownload) { | ||
cancelDownloadUpdate() | ||
} | ||
setShowUpdateDownloadStatus(false) | ||
}, [hasStartDownload]), | ||
} | ||
} | ||
|
||
export const useCheckUpdate = () => { | ||
const [showCheckDialog, setShowCheckDialog] = useState(false) | ||
const onCancelCheckUpdates = useCallback(() => { | ||
if (showCheckDialog) { | ||
cancelCheckUpdates() | ||
} | ||
setShowCheckDialog(false) | ||
}, [showCheckDialog]) | ||
return { | ||
showCheckDialog, | ||
setShowCheckDialog, | ||
onCancelCheckUpdates, | ||
} | ||
} |
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 |
---|---|---|
|
@@ -187,3 +187,8 @@ $hover-bg-color: #3cc68a4d; | |
margin: unset; | ||
} | ||
} | ||
|
||
.unexpandedBadge::after { | ||
top: 0; | ||
right: 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import '../../styles/theme.scss'; | ||
|
||
.badge { | ||
position: relative; | ||
|
||
&::after { | ||
content: ''; | ||
width: 8px; | ||
height: 8px; | ||
border-radius: 50%; | ||
background-color: #ff1e1e; | ||
position: absolute; | ||
top: 20%; | ||
margin-left: 4px; | ||
} | ||
} |
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,9 @@ | ||
import React from 'react' | ||
import { clsx } from 'utils' | ||
import styles from './badge.module.scss' | ||
|
||
const Badge = ({ children, className }: { children: React.ReactChild; className?: string }) => { | ||
return <div className={clsx(styles.badge, className)}>{children}</div> | ||
} | ||
|
||
export default Badge |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
34fff73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packaging for test is done in 5760722029
34fff73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packaging for test is done in 5760722126