mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor: environment setup (#2898)
Co-authored-by: Simon He <57086651+Simon-He95@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { env } from '@affine/env/config';
|
||||
import { isBrowser } from '@affine/env/constant';
|
||||
import { atomWithObservable, atomWithStorage } from 'jotai/utils';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@@ -22,7 +22,7 @@ function rpcToObservable<
|
||||
return new Observable<T>(subscriber => {
|
||||
subscriber.next(initialValue);
|
||||
onSubscribe?.();
|
||||
if (typeof window === 'undefined' || !env.isDesktop || !event) {
|
||||
if (!isBrowser || !environment.isDesktop || !event) {
|
||||
subscriber.complete();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { config } from '@affine/env/config';
|
||||
import { Unreachable } from '@affine/env/constant';
|
||||
import { isBrowser, Unreachable } from '@affine/env/constant';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { CloseIcon, NewIcon, ResetIcon } from '@blocksuite/icons';
|
||||
import clsx from 'clsx';
|
||||
@@ -20,7 +19,7 @@ interface AddPageButtonProps {
|
||||
}
|
||||
|
||||
const currentVersionAtom = atom(async () => {
|
||||
if (typeof window === 'undefined') {
|
||||
if (!isBrowser) {
|
||||
return null;
|
||||
}
|
||||
const currentVersion = await window.apis?.updater.currentVersion();
|
||||
@@ -28,7 +27,7 @@ const currentVersionAtom = atom(async () => {
|
||||
});
|
||||
|
||||
const currentChangelogUnreadAtom = atom(async get => {
|
||||
if (typeof window === 'undefined') {
|
||||
if (!isBrowser) {
|
||||
return false;
|
||||
}
|
||||
const mapping = get(changelogCheckedAtom);
|
||||
@@ -79,7 +78,7 @@ export function AppUpdaterButton({ className, style }: AddPageButtonProps) {
|
||||
);
|
||||
}
|
||||
} else if (currentChangelogUnread) {
|
||||
window.open(config.changelogUrl, '_blank');
|
||||
window.open(runtimeConfig.changelogUrl, '_blank');
|
||||
onDismissCurrentChangelog();
|
||||
} else {
|
||||
throw new Unreachable();
|
||||
|
||||
Reference in New Issue
Block a user