style: enable no-non-null-assertion rule (#2723)

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
LongYinan
2023-06-08 15:23:20 +08:00
committed by GitHub
parent 1ad2e629ac
commit 18dc427bc3
16 changed files with 196 additions and 147 deletions

View File

@@ -33,7 +33,7 @@ export const createBroadCastChannelProvider = (
case 'doc:diff': {
const [, diff, clientId] = event.data;
const update = Y.encodeStateAsUpdate(doc, diff);
broadcastChannel!.postMessage(['doc:update', update, clientId]);
broadcastChannel?.postMessage(['doc:update', update, clientId]);
break;
}
case 'doc:update': {
@@ -47,7 +47,7 @@ export const createBroadCastChannelProvider = (
const [, clientId] = event.data;
const clients = getClients(awareness);
const update = encodeAwarenessUpdate(awareness, clients);
broadcastChannel!.postMessage(['awareness:update', update, clientId]);
broadcastChannel?.postMessage(['awareness:update', update, clientId]);
break;
}
case 'awareness:update': {

View File

@@ -162,8 +162,7 @@ const sqliteOrigin = Symbol('sqlite-provider-origin');
const createSQLiteProvider = (
blockSuiteWorkspace: BlockSuiteWorkspace
): SQLiteProvider => {
const apis = window.apis!;
const events = window.events!;
const { apis, events } = window;
// make sure it is being used in Electron with APIs
assertExists(apis);
assertExists(events);
@@ -216,7 +215,7 @@ const createSQLiteProvider = (
const createSQLiteDBDownloadProvider = (
blockSuiteWorkspace: BlockSuiteWorkspace
): SQLiteDBDownloadProvider => {
const apis = window.apis!;
const { apis } = window;
let disconnected = false;
let _resolve: () => void;
@@ -273,7 +272,7 @@ const createSQLiteDBDownloadProvider = (
return;
}
return window.apis?.db.addBlob(
return apis?.db.addBlob(
blockSuiteWorkspace.id,
k,
new Uint8Array(await blob.arrayBuffer())

View File

@@ -65,9 +65,10 @@ export function createEmptyBlockSuiteWorkspace(
const blobStorages: StoreOptions['blobStorages'] = [];
if (flavour === WorkspaceFlavour.AFFINE) {
blobStorages.push(id =>
createAffineBlobStorage(id, config!.workspaceApis!)
);
if (config && config.workspaceApis) {
const workspaceApis = config.workspaceApis;
blobStorages.push(id => createAffineBlobStorage(id, workspaceApis));
}
} else {
if (typeof window !== 'undefined') {
blobStorages.push(createIndexeddbStorage);