From 75d6b7ab302b2359415f51efd119511a44c68ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Tue, 12 Sep 2023 11:33:43 +0200 Subject: [PATCH] (core) Fixing code after core merge Summary: Fixing code after last core-merge Test Plan: Existing Reviewers: JakubSerafin Reviewed By: JakubSerafin Subscribers: JakubSerafin Differential Revision: https://phab.getgrist.com/D4038 --- app/client/components/LinkingState.ts | 8 +++++++- app/client/models/entities/ViewSectionRec.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/client/components/LinkingState.ts b/app/client/components/LinkingState.ts index 7db6f134..d35ccee0 100644 --- a/app/client/components/LinkingState.ts +++ b/app/client/components/LinkingState.ts @@ -90,7 +90,7 @@ export class LinkingState extends Disposable { // The typical pattern to deal with this is to use `srcColId = col?.colId()`, and test for `if (srcColId) {...}` this.linkTypeDescription = this.autoDispose(ko.computed((): LinkType => { - if(srcSection.isDisposed()) { + if (srcSection.isDisposed()) { //srcSection disposed can happen transiently. Can happen when deleting tables and then undoing? //nbrowser tests: LinkingErrors and RawData seem to hit this case console.warn("srcSection disposed in linkingState: linkTypeDescription"); @@ -307,6 +307,12 @@ export class LinkingState extends Disposable { //Now, create the actual observable that updates with activeRowId //(we autodispose/return it at the end of the function) is this right? TODO JV return owner.autoDispose(ko.computed(() => { + if (this._srcSection.isDisposed()) { + //srcSection disposed can happen transiently. Can happen when deleting tables and then undoing? + //nbrowser tests: LinkingErrors and RawData seem to hit this case + console.warn("srcSection disposed in LinkingState._makeFilterObs"); + return EmptyFilterState; + } //Get selector-rowId const srcRowId = this._srcSection.activeRowId(); diff --git a/app/client/models/entities/ViewSectionRec.ts b/app/client/models/entities/ViewSectionRec.ts index a30728b3..71f8226b 100644 --- a/app/client/models/entities/ViewSectionRec.ts +++ b/app/client/models/entities/ViewSectionRec.ts @@ -631,7 +631,7 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel): } catch (err) { console.warn(err); // Dispose old LinkingState in case creating the new one failed. - this._linkingState.dispose(); + this._linkingState.clear(); return null; } }));