This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from arthyn/adding-auto-updates-pt2
adding auto update support for mac
- Loading branch information
Showing
9 changed files
with
724 additions
and
6 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,69 @@ | ||
import React, { useEffect } from 'react' | ||
import { useStore } from '../App'; | ||
import { listen, send } from '../client/ipc'; | ||
import { Spinner } from './Spinner'; | ||
import * as Popover from '@radix-ui/react-popover'; | ||
import { Close } from '../icons/Close'; | ||
import { Button } from './Button'; | ||
|
||
const PopoverContent: any = Popover.Content; | ||
|
||
export const UpdateNotifier = () => { | ||
const status = useStore(state => state.updateStatus); | ||
|
||
function install() { | ||
send('install-updates'); | ||
} | ||
|
||
useEffect(() => { | ||
const unlistenAvailable = listen('update-available', () => { | ||
useStore.setState({ updateStatus: 'available' }); | ||
}); | ||
|
||
const unlistenDownloaded = listen('update-downloaded', () => { | ||
useStore.setState({ updateStatus: 'downloaded' }); | ||
}) | ||
|
||
return () => { | ||
unlistenAvailable(); | ||
unlistenDownloaded(); | ||
} | ||
}, []); | ||
|
||
if (status === 'initial') { | ||
return null; | ||
} | ||
|
||
return ( | ||
<span className="flex items-center ml-4 mr-2 text-xs leading-none text-gray-400 dark:text-gray-500"> | ||
{status === 'available' && | ||
<> | ||
<Spinner className="w-4 h-4 mr-2" /> | ||
<span>Getting Updates</span> | ||
</> | ||
} | ||
{status === 'downloaded' && | ||
<> | ||
<Popover.Root defaultOpen={true}> | ||
<Popover.Trigger className="hover:text-black dark:hover:text-white default-ring"> | ||
Updates Ready | ||
</Popover.Trigger> | ||
<PopoverContent | ||
align="end" | ||
sideOffset={20} | ||
onOpenAutoFocus={event => event.preventDefault()} | ||
onPointerDownOutside={event => event.preventDefault()} | ||
className="relative -right-8 flex items-center p-2 text-sm text-gray-400 dark:text-gray-500 bg-gray-100 dark:bg-gray-900 default-ring rounded" | ||
> | ||
<Popover.Close className="mr-2 text-gray-300 dark:text-gray-700 hover:text-gray-400 dark:hover:text-gray-500 focus:text-gray-400 dark:focus:text-gray-500 default-ring rounded"> | ||
<Close className="w-5 h-5" primary="fill-current" /> | ||
</Popover.Close> | ||
<h2><strong>Update Available</strong></h2> | ||
<Popover.Close as={Button} className="ml-6" onClick={install}>Quit and Install</Popover.Close> | ||
</PopoverContent> | ||
</Popover.Root> | ||
</> | ||
} | ||
</span> | ||
); | ||
} |
Oops, something went wrong.