From fc2593c6ee97d6557fe2ce4a4b1a652fe77c33fa Mon Sep 17 00:00:00 2001 From: sixteenmillimeter Date: Thu, 9 Jan 2020 18:06:18 -0500 Subject: [PATCH] Resolves #34. Added delay lib to renderer and added a magic delay before ending devices.ready(). Just works. Move on and don't question it. --- app/js/app.js | 1 + app/lib/ui/devices.js | 140 +++++++++++++++++++++----------------- app/src/index.js | 1 + app/src/lib/ui/devices.ts | 7 +- 4 files changed, 82 insertions(+), 67 deletions(-) diff --git a/app/js/app.js b/app/js/app.js index 334c713..83be058 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -2496,6 +2496,7 @@ const devices = require('./lib/ui/devices.js'); const filmout = require('./lib/ui/filmout.js'); const mse = require('./lib/ui/mscript.js'); const Mscript = require('./lib/mscript'); +const { delay } = require('./lib/delay'); let log; /****** diff --git a/app/lib/ui/devices.js b/app/lib/ui/devices.js index dad4302..376ba3d 100644 --- a/app/lib/ui/devices.js +++ b/app/lib/ui/devices.js @@ -1,4 +1,13 @@ 'use strict'; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; let devices; class Devices { constructor() { @@ -15,76 +24,79 @@ class Devices { ipcRenderer.on('intval', this.intvalCb.bind(this)); } ready(event, arg) { - //console.dir(arg) - let opt; - let devs = []; - let notify = 'Connected to '; - let p; - try { - gui.spinner(false); - gui.overlay(false); - console.log('got here'); - } - catch (err) { - console.error(err); - } - for (let i in arg) { - devs.push(arg[i].arduino); - if (arg[i].arduino && arg[i].arduino !== '/dev/fake') { - if (notify === 'Connected to ') { - notify += arg[i].arduino + ' '; - } - else { - notify += `& ${arg[i].arduino}`; - } + return __awaiter(this, void 0, void 0, function* () { + //console.dir(arg) + let opt; + let devs = []; + let notify = 'Connected to '; + let p; + //@ts-ignore + yield delay(1000); + try { + gui.spinner(false); + gui.overlay(false); } - opt = $('