mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 11:59:51 +08:00
fix(editor): view recorded in storage may not exist (#9788)
fix: BS-2415
This commit is contained in:
@@ -473,7 +473,7 @@ export class DatabaseBlockDataSource extends DataSourceBase {
|
||||
return duplicateView(this._model, id);
|
||||
}
|
||||
|
||||
viewDataGet(viewId: string): DataViewDataType {
|
||||
viewDataGet(viewId: string): DataViewDataType | undefined {
|
||||
return this.viewDataList$.value.find(data => data.id === viewId)!;
|
||||
}
|
||||
|
||||
@@ -499,8 +499,11 @@ export class DatabaseBlockDataSource extends DataSourceBase {
|
||||
return view;
|
||||
}
|
||||
|
||||
viewMetaGetById(viewId: string): ViewMeta {
|
||||
viewMetaGetById(viewId: string): ViewMeta | undefined {
|
||||
const view = this.viewDataGet(viewId);
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
return this.viewMetaGet(view.mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,12 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
|
||||
this._dataSource = new DatabaseBlockDataSource(this.model);
|
||||
this._dataSource.contextSet(HostContextKey, this.host);
|
||||
const id = currentViewStorage.getCurrentView(this.model.id);
|
||||
if (id) {
|
||||
if (id && this.dataSource.viewManager.viewGet(id)) {
|
||||
console.log(
|
||||
'set current view',
|
||||
id,
|
||||
this._dataSource.viewManager.viewGet(id)
|
||||
);
|
||||
this.dataSource.viewManager.setCurrentView(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user