aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/SelectionManager.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-04-07 11:52:25 -0400
committerBob Zeleznik <zzzman@gmail.com>2020-04-07 11:52:25 -0400
commit892174ef482f3d45167a0c2d1c3163e6b9443c66 (patch)
tree6457eeb1db901920001ea6bf69e3bb8574fcde48 /src/client/util/SelectionManager.ts
parent8b02394f24e4f15674bf18192f49ee2385d67655 (diff)
got rid of some run-time errors/warnings related to CORS-ifying imagebox requests, and avoiding memoizing messages for computedFn's outside reactions.
Diffstat (limited to 'src/client/util/SelectionManager.ts')
-rw-r--r--src/client/util/SelectionManager.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index 2a6e3bf8a..6c386d684 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -55,11 +55,13 @@ export namespace SelectionManager {
manager.SelectDoc(docView, ctrlPressed);
}
-
+ // computed functions, such as used in IsSelected generate errors if they're called outside of a
+ // reaction context. Specifying the context with 'outsideReaction' allows an efficiency feature
+ // to avoid unnecessary mobx invalidations when running inside a reaction.
export function IsSelected(doc: DocumentView, outsideReaction?: boolean): boolean {
return outsideReaction ?
- manager.SelectedDocuments.get(doc) ? true : false :
- computedFn(function isSelected(doc: DocumentView) {
+ manager.SelectedDocuments.get(doc) ? true : false : // get() accesses a hashtable -- setting anything in the hashtable generates a mobx invalidation for every get()
+ computedFn(function isSelected(doc: DocumentView) { // wraapping get() in a computedFn only generates mobx() invalidations when the return value of the function for the specific get parameters has changed
return manager.SelectedDocuments.get(doc) ? true : false;
})(doc);
}