fix: configurable changelog url (#2418)

This commit is contained in:
Peng Xiao
2023-05-18 07:16:22 +08:00
committed by GitHub
parent 53c4fc6dfa
commit f875b37641
19 changed files with 94 additions and 73 deletions

View File

@@ -13,6 +13,12 @@ export const root = style({
userSelect: 'none',
cursor: 'pointer',
padding: '0 24px',
transition: 'background 0.2s ease',
selectors: {
'&:active': {
background: 'var(--affine-white-40)',
},
},
});
export const icon = style({

View File

@@ -1,3 +1,5 @@
import { config } from '@affine/env/config';
import { Unreachable } from '@affine/env/constant';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { CloseIcon, NewIcon, ResetIcon } from '@blocksuite/icons';
import clsx from 'clsx';
@@ -46,18 +48,11 @@ export function AppUpdaterButton({ className, style }: AddPageButtonProps) {
const updateAvailable = useAtomValue(updateAvailableAtom);
const currentVersion = useAtomValue(currentVersionAtom);
const downloadProgress = useAtomValue(downloadProgressAtom);
const onReadOrDismissChangelog = useSetAtom(changelogCheckedAtom);
const onReadOrDismissCurrentChangelog = (visit: boolean) => {
if (visit) {
window.open(
`https://github.com/toeverything/AFFiNE/releases/tag/v${currentVersion}`,
'_blank'
);
}
const setChangelogCheckAtom = useSetAtom(changelogCheckedAtom);
const onDismissCurrentChangelog = () => {
startTransition(() =>
onReadOrDismissChangelog(mapping => {
setChangelogCheckAtom(mapping => {
return {
...mapping,
[currentVersion!]: true,
@@ -79,10 +74,19 @@ export function AppUpdaterButton({ className, style }: AddPageButtonProps) {
onClick={() => {
if (updateReady) {
window.apis?.updater.quitAndInstall();
} else if (updateAvailable?.allowAutoUpdate) {
// wait for download to finish
} else if (updateAvailable || currentChangelogUnread) {
onReadOrDismissCurrentChangelog(true);
} else if (updateAvailable) {
if (updateAvailable.allowAutoUpdate) {
// wait for download to finish
} else {
window.open(
`https://github.com/toeverything/AFFiNE/releases/tag/v${currentVersion}`,
'_blank'
);
}
} else if (currentChangelogUnread) {
window.open(config.changelogUrl, '_blank');
} else {
throw new Unreachable();
}
}}
>
@@ -155,7 +159,7 @@ export function AppUpdaterButton({ className, style }: AddPageButtonProps) {
<div
className={styles.closeIcon}
onClick={e => {
onReadOrDismissCurrentChangelog(false);
onDismissCurrentChangelog();
e.stopPropagation();
}}
>