mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
refactor(editor): remove assert functions (#10629)
This commit is contained in:
@@ -11,7 +11,6 @@ import { DebugLogger } from '@affine/debug';
|
||||
import type { ListHistoryQuery } from '@affine/graphql';
|
||||
import { listHistoryQuery, recoverDocMutation } from '@affine/graphql';
|
||||
import { i18nTime } from '@affine/i18n';
|
||||
import { assertEquals } from '@blocksuite/affine/global/utils';
|
||||
import type { Workspace } from '@blocksuite/affine/store';
|
||||
import { useService } from '@toeverything/infra';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
@@ -291,7 +290,9 @@ export const useRestorePage = (docCollection: Workspace, pageId: string) => {
|
||||
}
|
||||
const pageDocId = page.spaceDoc.guid;
|
||||
revertUpdate(page.spaceDoc, update, key => {
|
||||
assertEquals(key, 'blocks'); // only expect this value is 'blocks'
|
||||
if (key !== 'blocks') {
|
||||
throw new Error('Only expect this value is "blocks"');
|
||||
}
|
||||
return 'Map';
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { assertEquals } from '@blocksuite/affine/global/utils';
|
||||
import { Service } from '@toeverything/infra';
|
||||
import { applyUpdate } from 'yjs';
|
||||
|
||||
@@ -26,7 +25,11 @@ export class WorkspaceTransformService extends Service {
|
||||
accountId: string,
|
||||
flavour: string
|
||||
): Promise<WorkspaceMetadata> => {
|
||||
assertEquals(local.flavour, 'local');
|
||||
if (local.flavour !== 'local') {
|
||||
throw new Error(
|
||||
'Only local workspace can be transformed to cloud workspace'
|
||||
);
|
||||
}
|
||||
|
||||
const localDocStorage = local.engine.doc.storage;
|
||||
const localDocList = Array.from(local.docCollection.docs.keys());
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import type { ToastOptions } from '@affine/component';
|
||||
import { toast as basicToast } from '@affine/component';
|
||||
import { assertEquals } from '@blocksuite/affine/global/utils';
|
||||
|
||||
export const toast = (message: string, options?: ToastOptions) => {
|
||||
const modal = document.querySelector(
|
||||
'[role=presentation]'
|
||||
) as HTMLDivElement | null;
|
||||
if (modal) {
|
||||
assertEquals(modal.constructor, HTMLDivElement, 'modal should be div');
|
||||
const modal = document.querySelector<HTMLDivElement>('[role=presentation]');
|
||||
if (modal && !(modal instanceof HTMLDivElement)) {
|
||||
throw new Error('modal should be div');
|
||||
}
|
||||
return basicToast(message, {
|
||||
portal: modal || document.body,
|
||||
|
||||
Reference in New Issue
Block a user