mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
fix(editor): view recorded in storage may not exist (#9788)
fix: BS-2415
This commit is contained in:
@@ -84,7 +84,7 @@ export interface DataSource {
|
||||
viewMetaGet(type: string): ViewMeta;
|
||||
viewMetaGet$(type: string): ReadonlySignal<ViewMeta | undefined>;
|
||||
|
||||
viewMetaGetById(viewId: string): ViewMeta;
|
||||
viewMetaGetById(viewId: string): ViewMeta | undefined;
|
||||
viewMetaGetById$(viewId: string): ReadonlySignal<ViewMeta | undefined>;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ export abstract class DataSourceBase implements DataSource {
|
||||
|
||||
abstract viewDataDuplicate(id: string): string;
|
||||
|
||||
abstract viewDataGet(viewId: string): DataViewDataType;
|
||||
abstract viewDataGet(viewId: string): DataViewDataType | undefined;
|
||||
|
||||
viewDataGet$(viewId: string): ReadonlySignal<DataViewDataType | undefined> {
|
||||
return computed(() => this.viewDataGet(viewId));
|
||||
@@ -236,7 +236,7 @@ export abstract class DataSourceBase implements DataSource {
|
||||
return computed(() => this.viewMetaGet(type));
|
||||
}
|
||||
|
||||
abstract viewMetaGetById(viewId: string): ViewMeta;
|
||||
abstract viewMetaGetById(viewId: string): ViewMeta | undefined;
|
||||
|
||||
viewMetaGetById$(viewId: string): ReadonlySignal<ViewMeta | undefined> {
|
||||
return computed(() => this.viewMetaGetById(viewId));
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface ViewManager {
|
||||
|
||||
views$: ReadonlySignal<string[]>;
|
||||
|
||||
viewGet(id: string): SingleView;
|
||||
viewGet(id: string): SingleView | undefined;
|
||||
|
||||
viewAdd(type: DataViewMode): string;
|
||||
|
||||
@@ -86,7 +86,7 @@ export class ViewManagerBase implements ViewManager {
|
||||
}
|
||||
|
||||
viewChangeType(id: string, type: string): void {
|
||||
const from = this.viewGet(id).type;
|
||||
const from = this.viewGet(id)?.type;
|
||||
const meta = this.dataSource.viewMetaGet(type);
|
||||
this.dataSource.viewDataUpdate(id, old => {
|
||||
let data = {
|
||||
@@ -122,8 +122,9 @@ export class ViewManagerBase implements ViewManager {
|
||||
this.setCurrentView(newId);
|
||||
}
|
||||
|
||||
viewGet(id: string): SingleView {
|
||||
viewGet(id: string): SingleView | undefined {
|
||||
const meta = this.dataSource.viewMetaGetById(id);
|
||||
if (!meta) return;
|
||||
return new meta.model.dataViewManager(this, id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user