Browse Source

Call expandVariable on expand

Jeremy Tuloup 5 years ago
parent
commit
dbead195a5
2 changed files with 8 additions and 10 deletions
  1. 2 2
      src/service.ts
  2. 6 8
      src/variables/body/index.tsx

+ 2 - 2
src/service.ts

@@ -339,7 +339,7 @@ export class DebugService implements IDebugger {
       newVariable = { [variable.name]: variable, ...newVariable };
     });
 
-    const newScope = this._model.variablesModel.scopes.map(scope => {
+    const newScopes = this._model.variablesModel.scopes.map(scope => {
       const findIndex = scope.variables.findIndex(
         ele => ele.variablesReference === variable.variablesReference
       );
@@ -347,7 +347,7 @@ export class DebugService implements IDebugger {
       return { ...scope };
     });
 
-    this._model.variablesModel.scopes = [...newScope];
+    this._model.variablesModel.scopes = [...newScopes];
 
     return reply.body.variables;
   };

+ 6 - 8
src/variables/body/index.tsx

@@ -45,11 +45,10 @@ const VariableComponent = ({ model }: { model: Variables.Model }) => {
         let valueOfKey =
           key === 'value' ? convertType(variable) : (variable as any)[key];
         if (typeof valueOfKey === 'object') {
-          return Object.assign(res, filterVariable(
-            valueOfKey,
-            true,
-            key
-          ) as Object);
+          return Object.assign(
+            res,
+            filterVariable(valueOfKey, true, key) as Object
+          );
         }
         if (isObject) {
           return Object.assign(res, {
@@ -66,20 +65,19 @@ const VariableComponent = ({ model }: { model: Variables.Model }) => {
   };
 
   const convertForObjectInspector = (scopes: Variables.IScope[]) => {
-    const converted = scopes.map(scope => {
+    return scopes.map(scope => {
       const newVariable = scope.variables.map(variable => {
         if (variable.haveMoreDetails || variable.variablesReference === 0) {
           return { ...filterVariable(variable) };
         } else {
           return {
-            expandVariable: model.expandVariable(variable),
+            expandVariable: () => model.expandVariable(variable),
             ...filterVariable(variable)
           };
         }
       });
       return { name: scope.name, variables: newVariable };
     });
-    return converted;
   };
 
   useEffect(() => {