From 060356d168d25723e08940f7de8a4b0479d869e8 Mon Sep 17 00:00:00 2001 From: Greg Solomon <88904581+ghsolomon@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:24:13 -0500 Subject: [PATCH] Fix bug where new views (created with Save As) were not being added to ViewManagerModel.views until next refresh (#3887) --- cmp/viewmanager/ViewManagerModel.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmp/viewmanager/ViewManagerModel.ts b/cmp/viewmanager/ViewManagerModel.ts index 9118912ab..d11c1a61e 100644 --- a/cmp/viewmanager/ViewManagerModel.ts +++ b/cmp/viewmanager/ViewManagerModel.ts @@ -21,7 +21,7 @@ import {fmtDateTime} from '@xh/hoist/format'; import {action, bindable, makeObservable, observable, comparer, runInAction} from '@xh/hoist/mobx'; import {olderThan, SECONDS} from '@xh/hoist/utils/datetime'; import {executeIfFunction, pluralize, throwIf} from '@xh/hoist/utils/js'; -import {find, isEqual, isNil, isNull, isUndefined, lowerCase} from 'lodash'; +import {find, isEqual, isNil, isNull, isUndefined, lowerCase, uniqBy} from 'lodash'; import {ReactNode} from 'react'; import {ViewInfo} from './ViewInfo'; import {View} from './View'; @@ -609,7 +609,7 @@ export class ViewManagerModel extends HoistModel { this.pendingValue = pendingValue; // Ensure we update meta-data as well. if (!view.isDefault) { - this.views = this.views.map(v => (v.token === view.token ? view.info : v)); + this.views = uniqBy([view.info, ...this.views], 'token'); } }