Skip to content

Commit bfb2db1

Browse files
committed
Fix update-addons - closes #3197
1 parent d188f53 commit bfb2db1

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/app.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import path from 'path';
2929
import expressHandlebars from 'express-handlebars';
3030
import ipRegex from 'ip-regex';
3131
import * as SegfaultHandler from 'segfault-handler';
32+
import { Device as DeviceSchema } from 'gateway-addon/lib/schema';
3233

3334
// Keep these imports here to prevent circular dependencies
3435
import './plugin/outlet-proxy';
@@ -45,6 +46,7 @@ import Router from './router';
4546
import RulesController from './controllers/rules_controller';
4647
import sleep from './sleep';
4748
import Things from './models/things';
49+
import { ThingDescription } from './models/thing';
4850
import TunnelService from './tunnel-service';
4951
import { WiFiSetupApp, isWiFiConfigured } from './wifi-setup';
5052
import { AddressInfo } from 'net';
@@ -400,3 +402,18 @@ TunnelService.switchToHttps = () => {
400402
}
401403
});
402404
};
405+
406+
AddonManager.on(Constants.THING_ADDED, (thing: ThingDescription) => {
407+
Things.handleNewThing(thing);
408+
});
409+
410+
AddonManager.on(Constants.THING_REMOVED, (thing: DeviceSchema) => {
411+
Things.handleThingRemoved(thing);
412+
});
413+
414+
AddonManager.on(
415+
Constants.CONNECTED,
416+
({ device, connected }: { device: DeviceSchema; connected: boolean }) => {
417+
Things.handleConnected(device.id, connected);
418+
}
419+
);

src/models/things.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -499,21 +499,4 @@ class Things extends EventEmitter {
499499
}
500500
}
501501

502-
const instance = new Things();
503-
504-
AddonManager.on(Constants.THING_ADDED, (thing: ThingDescription) => {
505-
instance.handleNewThing(thing);
506-
});
507-
508-
AddonManager.on(Constants.THING_REMOVED, (thing: DeviceSchema) => {
509-
instance.handleThingRemoved(thing);
510-
});
511-
512-
AddonManager.on(
513-
Constants.CONNECTED,
514-
({ device, connected }: { device: DeviceSchema; connected: boolean }) => {
515-
instance.handleConnected(device.id, connected);
516-
}
517-
);
518-
519-
export default instance;
502+
export default new Things();

tools/update-addons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const migrate = require('../build/migrate');
2-
const db = require('../build/db');
1+
const migrate = require('../build/migrate').default;
2+
const db = require('../build/db').default;
33
db.open();
44

5-
const AddonManager = require('../build/addon-manager');
5+
const AddonManager = require('../build/addon-manager').default;
66

77
migrate()
88
.then(() => {

0 commit comments

Comments
 (0)