mirror of
https://github.com/koush/scrypted.git
synced 2026-09-19 10:10:39 +01:00
server: improve fix mixin table not sending final state update when complete
This commit is contained in:
4
server/package-lock.json
generated
4
server/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.3.10",
|
||||
"version": "0.4.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.3.10",
|
||||
"version": "0.4.1",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.3.10",
|
||||
"version": "0.4.1",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||
|
||||
@@ -51,22 +51,13 @@ export class PluginComponent {
|
||||
throw new Error(message);
|
||||
}
|
||||
const pluginDevice = this.scrypted.findPluginDeviceById(id);
|
||||
// immediately remove the mixin and save this state,
|
||||
// but hold off on generating the new descriptor until
|
||||
// the new table is finished.
|
||||
this.scrypted.stateManager.setPluginDeviceState(pluginDevice, ScryptedInterfaceProperty.mixins, [...new Set(mixins)]);
|
||||
this.scrypted.stateManager.updateDescriptor(pluginDevice);
|
||||
await this.scrypted.datastore.upsert(pluginDevice);
|
||||
|
||||
// device may not exist, so force creation.
|
||||
this.scrypted.rebuildPluginDeviceMixinTable(id);
|
||||
this.scrypted.getDevice(id);
|
||||
await this.scrypted.devices[id]?.handler?.ensureProxy();
|
||||
|
||||
// after the mixin table is generated, report/persist the final device descriptor
|
||||
const promises = this.scrypted.devices[id]?.handler?.mixinTable?.map(e => e.entry);
|
||||
await Promise.allSettled(promises);
|
||||
this.scrypted.stateManager.updateDescriptor(pluginDevice);
|
||||
await this.scrypted.datastore.upsert(pluginDevice);
|
||||
}
|
||||
async getIdForPluginId(pluginId: string) {
|
||||
return this.scrypted.findPluginDevice(pluginId)?._id;
|
||||
|
||||
@@ -46,12 +46,14 @@ export class ScryptedStateManager extends EventRegistry {
|
||||
if (!eventInterface)
|
||||
throw new Error(`${property} is not a valid property`);
|
||||
|
||||
const changed = setState(device, property, value) && eventInterface !== ScryptedInterface.ScryptedDevice;
|
||||
const changed = setState(device, property, value);
|
||||
|
||||
const eventTime = device?.state?.[property]?.lastEventTime;
|
||||
|
||||
if (this.notify(device?._id, eventTime, eventInterface, property, value, changed) && device) {
|
||||
this.scrypted.getDeviceLogger(device).log('i', `state change: ${property} ${value}`);
|
||||
if (eventInterface !== ScryptedInterface.ScryptedDevice) {
|
||||
if (this.notify(device?._id, eventTime, eventInterface, property, value, changed) && device) {
|
||||
this.scrypted.getDeviceLogger(device).log('i', `state change: ${property} ${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.upserts.add(device._id);
|
||||
|
||||
Reference in New Issue
Block a user