From 44aa6fe49de97998fd84a6d6331501c8a1d7a775 Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Sun, 7 Apr 2019 01:14:31 -0400
Subject: Refactored scripting to seperate compilation and execution

---
 src/client/views/nodes/KeyValueBox.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'src/client/views/nodes/KeyValueBox.tsx')

diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 283c1f732..9bd6c1052 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -40,11 +40,13 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
                 }
                 let realDoc = doc;
 
-                let script = CompileScript(this._valueInput, undefined, true);
+                let script = CompileScript(this._valueInput, { addReturn: true });
                 if (!script.compiled) {
                     return;
                 }
-                let field = script();
+                let res = script.run();
+                if (!res.success) return;
+                const field = res.result;
                 if (field instanceof Field) {
                     realDoc.Set(new Key(this._keyInput), field);
                 } else {
-- 
cgit v1.2.3-70-g09d2

