From 40040561c76414ba29a0a7d654bfe5cf3b4a322b Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Tue, 14 Nov 2023 16:06:59 -0500 Subject: [PATCH 01/15] fix: DIA-666: [FE] Semantic search polish --- src/components/DataManager/DataManager.js | 7 +++++++ src/components/Filters/types/String.js | 7 ------- src/stores/DataStores/tasks.js | 7 +++++-- src/stores/Tabs/tab.js | 18 ++++++++++++------ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/components/DataManager/DataManager.js b/src/components/DataManager/DataManager.js index 71899ab3..06608ca2 100644 --- a/src/components/DataManager/DataManager.js +++ b/src/components/DataManager/DataManager.js @@ -12,6 +12,7 @@ import { DataView } from "../MainView"; import "./DataManager.styl"; import { Toolbar } from "./Toolbar/Toolbar"; +const SIMILARITY_UPPER_LIMIT_PRECISION = 10; const injector = inject(({ store }) => { const { sidebarEnabled, sidebarVisible } = store.viewsStore ?? {}; @@ -33,11 +34,17 @@ const summaryInjector = inject(({ store }) => { SDK, }; } else { + const similarityUpperLimit = taskStore?.similarityUpperLimit ? + (Math.ceil(taskStore?.similarityUpperLimit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION) + : + null; + return { totalTasks: project?.task_count ?? project?.task_number ?? 0, totalFoundTasks: taskStore?.total ?? 0, totalAnnotations: taskStore?.totalAnnotations ?? 0, totalPredictions: taskStore?.totalPredictions ?? 0, + similarityUpperLimit, cloudSync: project.target_syncing ?? project.source_syncing ?? false, }; } diff --git a/src/components/Filters/types/String.js b/src/components/Filters/types/String.js index 02a25365..00c93fc2 100644 --- a/src/components/Filters/types/String.js +++ b/src/components/Filters/types/String.js @@ -1,7 +1,6 @@ import { observer } from "mobx-react"; import React from "react"; import { FilterInput } from "../FilterInput"; -import { VariantSelect } from "./List"; const BaseInput = observer(({ value, onChange, placeholder }) => { return ( @@ -46,10 +45,4 @@ export const StringFilter = [ valueType: "single", input: (props) => , }, - { - key: "similar_to", - label: "similar to", - valueType: "list", - input: (props) => , - }, ]; diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index 1ea7c0e1..11b4e532 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -218,17 +218,19 @@ export const create = (columns) => { }, postProcessData(data) { - const { total_annotations, total_predictions } = data; + const { total_annotations, total_predictions, similarity_score_upper_limit } = data; if (total_annotations !== null) self.totalAnnotations = total_annotations; if (total_predictions !== null) self.totalPredictions = total_predictions; + if (total_predictions !== null) + self.similarityUpperLimit = similarity_score_upper_limit; }, })) .preProcessSnapshot((snapshot) => { - const { total_annotations, total_predictions, ...sn } = snapshot; + const { total_annotations, total_predictions, similarity_score_upper_limit, ...sn } = snapshot; return { ...sn, @@ -239,6 +241,7 @@ export const create = (columns) => { })), totalAnnotations: total_annotations, totalPredictions: total_predictions, + similarityUpperLimit: similarity_score_upper_limit, }; }); }; diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index 72b81e54..9b8bd475 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -17,8 +17,6 @@ import { History } from '../../utils/history'; import { FF_DEV_1470, FF_LOPS_12, isFF } from "../../utils/feature-flags"; import { CustomJSON, StringOrNumberID, ThresholdType } from "../types"; -const DEFAULT_THRESHOLD = { min: 0, max: 10 }; - export const Tab = types .model("View", { id: StringOrNumberID, @@ -53,7 +51,7 @@ export const Tab = types editable: true, deletable: true, semantic_search: types.optional(types.array(CustomJSON), []), - threshold: types.optional(ThresholdType, DEFAULT_THRESHOLD), + threshold: types.optional(types.maybeNull(ThresholdType), null), }) .volatile(() => { const defaultWidth = getComputedStyle(document.body).getPropertyValue("--menu-sidebar-width").replace("px", "").trim(); @@ -218,7 +216,7 @@ export const Tab = types columnsDisplayType: self.columnsDisplayType.toPOJO(), gridWidth: self.gridWidth, semantic_search: self.semantic_search?.toJSON() ?? [], - threshold: self.threshold?.toJSON() ?? DEFAULT_THRESHOLD, + threshold: self.threshold?.toJSON(), }; if (self.saved || apiVersion === 1) { @@ -305,9 +303,12 @@ export const Tab = types self.selected = ids; }, - setSemanticSearch(semanticSearchList) { + setSemanticSearch(semanticSearchList, save = true) { self.semantic_search = semanticSearchList ?? []; - return self.save(); + if (self.semantic_search.length === 0) { + self.threshold = null; + } + return save && self.save(); }, setSemanticSearchThreshold(min, max) { @@ -315,6 +316,11 @@ export const Tab = types return self.save(); }, + clearSemanticSearchThreshold(save = true) { + self.threshold = null; + return save && self.save(); + }, + selectAll() { self.selected.toggleSelectedAll(); }, From e9eef24569d899d8af2f5f2c23348f2d3eaf24ef Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Tue, 14 Nov 2023 18:19:47 -0500 Subject: [PATCH 02/15] fixing where the upper limit is being set --- src/components/DataManager/DataManager.js | 7 ------- src/stores/DataStores/tasks.js | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/DataManager/DataManager.js b/src/components/DataManager/DataManager.js index 06608ca2..71899ab3 100644 --- a/src/components/DataManager/DataManager.js +++ b/src/components/DataManager/DataManager.js @@ -12,7 +12,6 @@ import { DataView } from "../MainView"; import "./DataManager.styl"; import { Toolbar } from "./Toolbar/Toolbar"; -const SIMILARITY_UPPER_LIMIT_PRECISION = 10; const injector = inject(({ store }) => { const { sidebarEnabled, sidebarVisible } = store.viewsStore ?? {}; @@ -34,17 +33,11 @@ const summaryInjector = inject(({ store }) => { SDK, }; } else { - const similarityUpperLimit = taskStore?.similarityUpperLimit ? - (Math.ceil(taskStore?.similarityUpperLimit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION) - : - null; - return { totalTasks: project?.task_count ?? project?.task_number ?? 0, totalFoundTasks: taskStore?.total ?? 0, totalAnnotations: taskStore?.totalAnnotations ?? 0, totalPredictions: taskStore?.totalPredictions ?? 0, - similarityUpperLimit, cloudSync: project.target_syncing ?? project.source_syncing ?? false, }; } diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index 11b4e532..93fb25ea 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -7,6 +7,7 @@ import { DynamicModel, registerModel } from "../DynamicModel"; import { CustomJSON } from "../types"; import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags"; +const SIMILARITY_UPPER_LIMIT_PRECISION = 10; const fileAttributes = types.model({ "certainty": types.optional(types.maybeNull(types.number), 0), "distance": types.optional(types.maybeNull(types.number), 0), @@ -225,7 +226,7 @@ export const create = (columns) => { if (total_predictions !== null) self.totalPredictions = total_predictions; if (total_predictions !== null) - self.similarityUpperLimit = similarity_score_upper_limit; + self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); }, })) From 3a23b25dfcd9f0270ea5655899b1da3feb86ad14 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Tue, 14 Nov 2023 20:29:38 -0500 Subject: [PATCH 03/15] fixing a null check --- src/stores/DataStores/tasks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index 93fb25ea..fd8a3b74 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -225,7 +225,7 @@ export const create = (columns) => { self.totalAnnotations = total_annotations; if (total_predictions !== null) self.totalPredictions = total_predictions; - if (total_predictions !== null) + if (similarity_score_upper_limit !== null) self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); }, From 46f36d5f99cc591b58a3a23c59cf1c5a7c5923f2 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Thu, 16 Nov 2023 12:43:21 -0500 Subject: [PATCH 04/15] applying precision update to similiary upper limit --- src/stores/DataStores/tasks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index fd8a3b74..9a279a3c 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -7,7 +7,7 @@ import { DynamicModel, registerModel } from "../DynamicModel"; import { CustomJSON } from "../types"; import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags"; -const SIMILARITY_UPPER_LIMIT_PRECISION = 10; +const SIMILARITY_UPPER_LIMIT_PRECISION = 1000; const fileAttributes = types.model({ "certainty": types.optional(types.maybeNull(types.number), 0), "distance": types.optional(types.maybeNull(types.number), 0), From ead12270dfeba15bb1f13ecff073a19e92cf1b07 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Thu, 16 Nov 2023 12:59:01 -0500 Subject: [PATCH 05/15] its possible to provide 0 as the max which we cant do defaulting to 10 --- src/stores/DataStores/tasks.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index 9a279a3c..c87e9bdf 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -8,6 +8,7 @@ import { CustomJSON } from "../types"; import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags"; const SIMILARITY_UPPER_LIMIT_PRECISION = 1000; +const SIMILARITY_UPPER_LIMIT_DEFAULT = 10; const fileAttributes = types.model({ "certainty": types.optional(types.maybeNull(types.number), 0), "distance": types.optional(types.maybeNull(types.number), 0), @@ -226,7 +227,11 @@ export const create = (columns) => { if (total_predictions !== null) self.totalPredictions = total_predictions; if (similarity_score_upper_limit !== null) - self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); + self.similarityUpperLimit = similarity_score_upper_limit ?( + (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION) + ) : ( + SIMILARITY_UPPER_LIMIT_DEFAULT + ); }, })) From e69cbd6caa367e0facdebff50a59daf88dd2e879 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Thu, 16 Nov 2023 13:21:40 -0500 Subject: [PATCH 06/15] dont need to send default - if upper limit undefined just dont show the semantic search stuff as its not ready yet --- src/stores/DataStores/tasks.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index c87e9bdf..9a279a3c 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -8,7 +8,6 @@ import { CustomJSON } from "../types"; import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags"; const SIMILARITY_UPPER_LIMIT_PRECISION = 1000; -const SIMILARITY_UPPER_LIMIT_DEFAULT = 10; const fileAttributes = types.model({ "certainty": types.optional(types.maybeNull(types.number), 0), "distance": types.optional(types.maybeNull(types.number), 0), @@ -227,11 +226,7 @@ export const create = (columns) => { if (total_predictions !== null) self.totalPredictions = total_predictions; if (similarity_score_upper_limit !== null) - self.similarityUpperLimit = similarity_score_upper_limit ?( - (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION) - ) : ( - SIMILARITY_UPPER_LIMIT_DEFAULT - ); + self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); }, })) From 6872fe2d6ec38b890f8d3f169cf76def3d44bb65 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Mon, 20 Nov 2023 10:08:29 -0500 Subject: [PATCH 07/15] we now invoke an event on view reload --- src/stores/Tabs/tab.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index 9b8bd475..3135a6e6 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -387,6 +387,8 @@ export const Tab = types } else if (isFF(FF_LOPS_12) && self.root.SDK.type === 'labelops') { yield self.dataStore.reload({ query: self.query, interaction }); } + + getRoot(self).SDK.invoke("tabReloaded", self); }), deleteFilter(filter) { From 6a748bd2990aa35880fa058465fff67effc6985a Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Mon, 20 Nov 2023 14:22:11 -0500 Subject: [PATCH 08/15] setting a safe fallback for when there is no upper limit --- src/stores/DataStores/tasks.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index 9a279a3c..d4805436 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -8,6 +8,7 @@ import { CustomJSON } from "../types"; import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags"; const SIMILARITY_UPPER_LIMIT_PRECISION = 1000; +const SIMILARITY_UPPER_LIMIT = 10; const fileAttributes = types.model({ "certainty": types.optional(types.maybeNull(types.number), 0), "distance": types.optional(types.maybeNull(types.number), 0), @@ -220,13 +221,14 @@ export const create = (columns) => { postProcessData(data) { const { total_annotations, total_predictions, similarity_score_upper_limit } = data; + const similarityUpperLimit = similarity_score_upper_limit ?? SIMILARITY_UPPER_LIMIT; if (total_annotations !== null) self.totalAnnotations = total_annotations; if (total_predictions !== null) self.totalPredictions = total_predictions; if (similarity_score_upper_limit !== null) - self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); + self.similarityUpperLimit = (Math.ceil(similarityUpperLimit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); }, })) From f51cf82c2e4011e2f2d59a504883efece2fe3b4e Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Mon, 20 Nov 2023 17:20:33 -0500 Subject: [PATCH 09/15] Revert "setting a safe fallback for when there is no upper limit" This reverts commit 6a748bd2990aa35880fa058465fff67effc6985a. --- src/stores/DataStores/tasks.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index d4805436..9a279a3c 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -8,7 +8,6 @@ import { CustomJSON } from "../types"; import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags"; const SIMILARITY_UPPER_LIMIT_PRECISION = 1000; -const SIMILARITY_UPPER_LIMIT = 10; const fileAttributes = types.model({ "certainty": types.optional(types.maybeNull(types.number), 0), "distance": types.optional(types.maybeNull(types.number), 0), @@ -221,14 +220,13 @@ export const create = (columns) => { postProcessData(data) { const { total_annotations, total_predictions, similarity_score_upper_limit } = data; - const similarityUpperLimit = similarity_score_upper_limit ?? SIMILARITY_UPPER_LIMIT; if (total_annotations !== null) self.totalAnnotations = total_annotations; if (total_predictions !== null) self.totalPredictions = total_predictions; if (similarity_score_upper_limit !== null) - self.similarityUpperLimit = (Math.ceil(similarityUpperLimit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); + self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); }, })) From 4f098f49e774bf5035c96ffbdb2b5a3515a96064 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Mon, 20 Nov 2023 18:13:40 -0500 Subject: [PATCH 10/15] send it back if its any nan --- src/stores/DataStores/tasks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/DataStores/tasks.js b/src/stores/DataStores/tasks.js index 9a279a3c..fdd76210 100644 --- a/src/stores/DataStores/tasks.js +++ b/src/stores/DataStores/tasks.js @@ -225,7 +225,7 @@ export const create = (columns) => { self.totalAnnotations = total_annotations; if (total_predictions !== null) self.totalPredictions = total_predictions; - if (similarity_score_upper_limit !== null) + if (!isNaN(similarity_score_upper_limit)) self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION); }, From cf7ad7893ee6e66392dc1f3e2c224c2d0575d0bd Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Tue, 21 Nov 2023 10:36:28 -0500 Subject: [PATCH 11/15] we dont need to save threshold if there is no semantic search --- src/stores/Tabs/tab.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index 3135a6e6..afcd6444 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -312,8 +312,10 @@ export const Tab = types }, setSemanticSearchThreshold(min, max) { - self.threshold = { min, max }; - return self.save(); + if (self.semantic_search.length === 0) { + self.threshold = { min, max }; + return self.save(); + } }, clearSemanticSearchThreshold(save = true) { From 61b3f3af6221b5f351dcc3cf92d4c4b4eb7ce939 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Tue, 21 Nov 2023 10:51:37 -0500 Subject: [PATCH 12/15] oops inverse logic --- src/stores/Tabs/tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index afcd6444..5786bb68 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -312,7 +312,7 @@ export const Tab = types }, setSemanticSearchThreshold(min, max) { - if (self.semantic_search.length === 0) { + if (self.semantic_search?.length) { self.threshold = { min, max }; return self.save(); } From 094fafceea06737b57deb79a38e148c5267e44b3 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Thu, 23 Nov 2023 13:27:51 -0500 Subject: [PATCH 13/15] this'll prevent a bad min from being saved --- src/stores/Tabs/tab.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index 5786bb68..8b685bd2 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -16,6 +16,10 @@ import { TabSelectedItems } from "./tab_selected_items"; import { History } from '../../utils/history'; import { FF_DEV_1470, FF_LOPS_12, isFF } from "../../utils/feature-flags"; import { CustomJSON, StringOrNumberID, ThresholdType } from "../types"; +import { clamp } from "../../utils/helpers"; + +const THRESHOLD_MIN = 0; +const THRESHOLD_MIN_DIFF = 0.001; export const Tab = types .model("View", { @@ -311,7 +315,9 @@ export const Tab = types return save && self.save(); }, - setSemanticSearchThreshold(min, max) { + setSemanticSearchThreshold(_min, max) { + const min = clamp(_min ?? THRESHOLD_MIN, THRESHOLD_MIN, max - THRESHOLD_MIN_DIFF); + if (self.semantic_search?.length) { self.threshold = { min, max }; return self.save(); From fb5f46a3c034acaac988a5663aedf3cc3b69c70a Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Fri, 24 Nov 2023 06:38:01 -0500 Subject: [PATCH 14/15] preventing total failure on null for threshold min/max but preventing it occuring in the first place --- src/stores/Tabs/tab.js | 2 +- src/stores/types.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index 8b685bd2..f6020919 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -318,7 +318,7 @@ export const Tab = types setSemanticSearchThreshold(_min, max) { const min = clamp(_min ?? THRESHOLD_MIN, THRESHOLD_MIN, max - THRESHOLD_MIN_DIFF); - if (self.semantic_search?.length) { + if (self.semantic_search?.length && !isNaN(min) && !isNaN(max)) { self.threshold = { min, max }; return self.save(); } diff --git a/src/stores/types.js b/src/stores/types.js index 0c18ed0a..28d7c70d 100644 --- a/src/stores/types.js +++ b/src/stores/types.js @@ -58,6 +58,6 @@ export const HtmlOrReact = types.custom({ }); export const ThresholdType = types.model("ThresholdType", { - min: types.number, - max: types.number, + min: types.maybeNull(types.number), + max: types.maybeNull(types.number), }); \ No newline at end of file From 9bb8caf884b346524b1a1a6aa8b60ec7dcfc3c86 Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Tue, 28 Nov 2023 10:41:47 -0500 Subject: [PATCH 15/15] small change to help reduce the number of times we save the view --- src/stores/Tabs/tab.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stores/Tabs/tab.js b/src/stores/Tabs/tab.js index f6020919..204f61ee 100644 --- a/src/stores/Tabs/tab.js +++ b/src/stores/Tabs/tab.js @@ -307,12 +307,16 @@ export const Tab = types self.selected = ids; }, - setSemanticSearch(semanticSearchList, save = true) { + setSemanticSearch(semanticSearchList, min, max) { self.semantic_search = semanticSearchList ?? []; + /* if no semantic search we have to clean up threshold */ if (self.semantic_search.length === 0) { self.threshold = null; + return self.save(); } - return save && self.save(); + /* if we have a min and max we need to make sure we save that too. + this prevents firing 2 view save requests to accomplish the same thing */ + return ( !isNaN(min) && !isNaN(max) ) ? self.setSemanticSearchThreshold(min, max) : self.save(); }, setSemanticSearchThreshold(_min, max) {