Skip to content

Commit

Permalink
fix(editor): data in the database will be completely overwritten in s…
Browse files Browse the repository at this point in the history
…ome cases
  • Loading branch information
zzj3720 committed Feb 20, 2025
1 parent 5fcc402 commit 6f50afd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
8 changes: 0 additions & 8 deletions blocksuite/affine/block-database/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import {
} from './properties/index.js';
import {
addProperty,
applyCellsUpdate,
applyPropertyUpdate,
copyCellsByProperty,
deleteRows,
deleteView,
Expand Down Expand Up @@ -169,7 +167,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
columnId: propertyId,
value: newValue,
});
applyCellsUpdate(this._model);
}
}

Expand Down Expand Up @@ -199,7 +196,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
insertToPosition,
property.create(this.newPropertyName())
);
applyPropertyUpdate(this._model);
return result;
}

Expand Down Expand Up @@ -283,7 +279,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
propertyDataSet(propertyId: string, data: Record<string, unknown>): void {
this._runCapture();
this.updateProperty(propertyId, () => ({ data }));
applyPropertyUpdate(this._model);
}

propertyDataTypeGet(propertyId: string): TypeInstance | undefined {
Expand Down Expand Up @@ -337,7 +332,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
schema
);
copyCellsByProperty(this._model, copyId, id);
applyPropertyUpdate(this._model);
return id;
}

Expand Down Expand Up @@ -366,7 +360,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
propertyNameSet(propertyId: string, name: string): void {
this.doc.captureSync();
this.updateProperty(propertyId, () => ({ name }));
applyPropertyUpdate(this._model);
}

override propertyReadonlyGet(propertyId: string): boolean {
Expand Down Expand Up @@ -421,7 +414,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
}
});
updateCells(this._model, propertyId, cells);
applyPropertyUpdate(this._model);
}

rowAdd(insertPosition: InsertToPosition | number): string {
Expand Down
20 changes: 0 additions & 20 deletions blocksuite/affine/block-database/src/utils/block-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ export function addProperty(
return id;
}

export function applyCellsUpdate(model: DatabaseBlockModel) {
model.doc.updateBlock(model, {
cells: model.cells,
});
}

export function applyPropertyUpdate(model: DatabaseBlockModel) {
model.doc.updateBlock(model, {
columns: model.columns,
});
}

export function applyViewsUpdate(model: DatabaseBlockModel) {
model.doc.updateBlock(model, {
views: model.views,
});
}

export function copyCellsByProperty(
model: DatabaseBlockModel,
fromId: Column['id'],
Expand Down Expand Up @@ -156,7 +138,6 @@ export function moveViewTo(
arr => insertPositionToIndex(position, arr)
);
});
applyViewsUpdate(model);
}

export function updateCell(
Expand Down Expand Up @@ -255,6 +236,5 @@ export const updateView = <ViewData extends ViewBasicDataType>(
return { ...v, ...update(v as ViewData) };
});
});
applyViewsUpdate(model);
};
export const DATABASE_CONVERT_WHITE_LIST = ['affine:list', 'affine:paragraph'];

0 comments on commit 6f50afd

Please sign in to comment.