refactor: environment setup (#2898)

Co-authored-by: Simon He <57086651+Simon-He95@users.noreply.github.com>
This commit is contained in:
Alex Yang
2023-06-28 19:19:19 +08:00
committed by GitHub
parent 80c2a78273
commit 5496969e58
72 changed files with 255 additions and 242 deletions

View File

@@ -1,3 +1,4 @@
import { isBrowser } from '@affine/env/constant';
import type { WorkspaceFlavour } from '@affine/env/workspace';
import type { WorkspaceVersion } from '@affine/env/workspace';
import type { EditorContainer } from '@blocksuite/editor';
@@ -44,14 +45,12 @@ export const rootWorkspacesMetadataAtom = atomWithStorage<
export const rootCurrentWorkspaceIdAtom = atom<string | null>(null);
rootCurrentWorkspaceIdAtom.onMount = set => {
if (typeof window !== 'undefined') {
if (isBrowser) {
const callback = (url: string) => {
const value = url.split('/')[2];
if (value) {
set(value);
if (typeof window !== 'undefined') {
localStorage.setItem('last_workspace_id', value);
}
localStorage.setItem('last_workspace_id', value);
} else {
set(null);
}
@@ -68,7 +67,7 @@ rootCurrentWorkspaceIdAtom.onMount = set => {
export const rootCurrentPageIdAtom = atom<string | null>(null);
rootCurrentPageIdAtom.onMount = set => {
if (typeof window !== 'undefined') {
if (isBrowser) {
const callback = (url: string) => {
const value = url.split('/')[3];
if (value) {