Skip to content

Commit

Permalink
Click to relaunch after update to maybe avoid install problem?
Browse files Browse the repository at this point in the history
  • Loading branch information
abrenneke committed Nov 14, 2023
1 parent db3f916 commit f621e81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 10 additions & 10 deletions packages/app/src/components/UpdateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useState, type FC, useEffect } from 'react';
import { useState, type FC } from 'react';

import Modal, { ModalTransition, ModalBody, ModalFooter, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
import { useRecoilState, useSetRecoilState } from 'recoil';
import { skippedMaxVersionState, updateModalOpenState, updateStatusState } from '../state/settings';
import Button from '@atlaskit/button';
import useAsyncEffect from 'use-async-effect';
import { checkUpdate, installUpdate, onUpdaterEvent } from '@tauri-apps/api/updater';
import { checkUpdate, installUpdate } from '@tauri-apps/api/updater';
import { getVersion } from '@tauri-apps/api/app';
import { css } from '@emotion/react';
import { relaunch } from '@tauri-apps/api/process';
import { useMarkdown } from '../hooks/useMarkdown';
import { relaunch } from '@tauri-apps/api/process';

const bodyStyle = css`
pre {
Expand Down Expand Up @@ -60,12 +60,6 @@ export const UpdateModal: FC = () => {
setModalOpen(false);
};

useAsyncEffect(async () => {
if (updateStatus === 'Installed.') {
await relaunch();
}
}, [updateStatus]);

const skipUpdate = () => {
setSkippedMaxVersion(latestVersion);
handleModalClose();
Expand Down Expand Up @@ -93,7 +87,13 @@ export const UpdateModal: FC = () => {
</ModalBody>
<ModalFooter>
{isUpdating ? (
<div>{updateStatus}</div>
updateStatus === 'Installed.' ? (
<Button appearance="primary" onClick={relaunch}>
Update complete! Click to restart.
</Button>
) : (
<div>{updateStatus}</div>
)
) : (
<>
<Button appearance="primary" onClick={doUpdate}>
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/hooks/useMonitorUpdateStatus.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { useEffect } from 'react';
import { isInTauri } from '../utils/tauri';
import { onUpdaterEvent } from '@tauri-apps/api/updater';
import { useSetRecoilState } from 'recoil';
import { updateStatusState } from '../state/settings';
import { match } from 'ts-pattern';
import useAsyncEffect from 'use-async-effect';
import { relaunch } from '@tauri-apps/api/process';

export function useMonitorUpdateStatus() {
const setUpdateStatus = useSetRecoilState(updateStatusState);
Expand Down

0 comments on commit f621e81

Please sign in to comment.