fix(core-view): CB-2022 wrap set in action

This commit is contained in:
Wroud
2022-06-20 11:29:14 +03:00
parent b3e1b1e040
commit bb1c4f91fd
2 changed files with 5 additions and 3 deletions
@@ -6,7 +6,7 @@
* you may not use this file except in compliance with the License.
*/
import { makeObservable, observable } from 'mobx';
import { action, makeObservable, observable } from 'mobx';
import { MetadataMap } from '@cloudbeaver/core-utils';
@@ -25,6 +25,8 @@ export class DataContext implements IDataContext {
this.fallback = fallback;
makeObservable<this, 'map'>(this, {
set: action,
delete: action,
map: observable.shallow,
fallback: observable.ref,
});
@@ -33,8 +33,8 @@ export class DynamicDataContext implements IDataContext {
set<T>(context: DataContextGetter<T>, value: T): DeleteVersionedContextCallback {
const dynamicContext = this.contexts.get(context);
if (dynamicContext && this.get(context) === value) {
return dynamicContext;
if (this.tryGet(context) === value) {
return dynamicContext ?? ( () => {});
}
const deleteCallback = this.fallback.set(context, value);