mirror of
https://github.com/koush/scrypted.git
synced 2026-02-10 17:22:03 +00:00
server: 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.9",
|
||||
"version": "0.3.10",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.3.9",
|
||||
"version": "0.3.10",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.3.9",
|
||||
"version": "0.3.10",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||
|
||||
@@ -51,13 +51,22 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user