Browse Source

Bug fix: setting saved layout for setting editor was glitchy.

Afshin Darian 7 years ago
parent
commit
1eaf329307
1 changed files with 18 additions and 9 deletions
  1. 18 9
      packages/settingeditor-extension/src/settingeditor.ts

+ 18 - 9
packages/settingeditor-extension/src/settingeditor.ts

@@ -179,11 +179,7 @@ class SettingEditor extends Widget {
     // Allow the message queue (which includes fit requests that might disrupt
     // Allow the message queue (which includes fit requests that might disrupt
     // setting relative sizes) to clear before setting sizes.
     // setting relative sizes) to clear before setting sizes.
     requestAnimationFrame(() => {
     requestAnimationFrame(() => {
-      // Set the original (default) outer dimensions.
-      this._panel.setRelativeSizes(this._presets.outer);
-      this._fetchState().then(() => {
-        this._setPresets();
-      }).catch(reason => {
+      this._fetchState().then(() => { this._setPresets(); }).catch(reason => {
         console.error('Fetching setting editor state failed', reason);
         console.error('Fetching setting editor state failed', reason);
         this._setPresets();
         this._setPresets();
       });
       });
@@ -289,18 +285,17 @@ class SettingEditor extends Widget {
     const editor = this._editor;
     const editor = this._editor;
     const list = this._list;
     const list = this._list;
     const panel = this._panel;
     const panel = this._panel;
-    const { inner, outer, plugin } = this._presets;
-
-    panel.setRelativeSizes(outer);
-    editor.sizes = inner;
+    const { plugin } = this._presets;
 
 
     if (!plugin) {
     if (!plugin) {
       editor.settings = null;
       editor.settings = null;
       list.selection = '';
       list.selection = '';
+      this._setSizes();
       return;
       return;
     }
     }
 
 
     if (editor.settings && editor.settings.plugin === plugin) {
     if (editor.settings && editor.settings.plugin === plugin) {
+      this._setSizes();
       return;
       return;
     }
     }
 
 
@@ -315,13 +310,27 @@ class SettingEditor extends Widget {
       }
       }
       editor.settings = settings;
       editor.settings = settings;
       list.selection = plugin;
       list.selection = plugin;
+      this._setSizes();
     }).catch((reason: Error) => {
     }).catch((reason: Error) => {
       console.error(`Loading settings failed: ${reason.message}`);
       console.error(`Loading settings failed: ${reason.message}`);
       list.selection = this._presets.plugin = '';
       list.selection = this._presets.plugin = '';
       editor.settings = null;
       editor.settings = null;
+      this._setSizes();
     });
     });
   }
   }
 
 
+  /**
+   * Set the layout sizes.
+   */
+  private _setSizes(): void {
+    const { inner, outer } = this._presets;
+    const editor = this._editor;
+    const panel = this._panel;
+
+    editor.sizes = inner;
+    panel.setRelativeSizes(outer);
+  }
+
   private _editor: PluginEditor;
   private _editor: PluginEditor;
   private _fetching: Promise<void> | null = null;
   private _fetching: Promise<void> | null = null;
   private _instructions: Widget;
   private _instructions: Widget;