mirror of
https://github.com/koush/scrypted.git
synced 2026-02-08 16:29:57 +00:00
snapshot: fix another spin loop in Never Wait mode
This commit is contained in:
4
plugins/snapshot/package-lock.json
generated
4
plugins/snapshot/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/snapshot",
|
||||
"version": "0.0.20",
|
||||
"version": "0.0.21",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/snapshot",
|
||||
"version": "0.0.20",
|
||||
"version": "0.0.21",
|
||||
"dependencies": {
|
||||
"@koush/axios-digest-auth": "^0.8.5",
|
||||
"@types/node": "^16.6.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/snapshot",
|
||||
"version": "0.0.20",
|
||||
"version": "0.0.21",
|
||||
"description": "Snapshot Plugin for Scrypted",
|
||||
"scripts": {
|
||||
"prepublishOnly": "NODE_ENV=production scrypted-webpack",
|
||||
|
||||
@@ -196,7 +196,8 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.pendingPicture) {
|
||||
const hadPendingPicture = !!this.pendingPicture;
|
||||
if (!hadPendingPicture) {
|
||||
const pendingPicture = (async () => {
|
||||
let picture: Buffer;
|
||||
try {
|
||||
@@ -219,9 +220,6 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
|
||||
|
||||
this.pendingPicture = pendingPicture;
|
||||
|
||||
// this triggers an event to refresh the web ui.
|
||||
this.pendingPicture.then(() => this.onDeviceEvent(ScryptedInterface.Camera, undefined));
|
||||
|
||||
// prevent infinite loop from onDeviceEvent triggering picture updates.
|
||||
// retain this promise for a bit while everything settles.
|
||||
pendingPicture.finally(() => {
|
||||
@@ -240,6 +238,11 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
|
||||
try {
|
||||
if (this.storageSettings.values.snapshotMode === 'Never Wait') {
|
||||
if (!this.currentPicture) {
|
||||
// this triggers an event to refresh the web ui.
|
||||
// but only trigger a refresh if this call fetched the picture.
|
||||
if (!hadPendingPicture)
|
||||
this.pendingPicture.then(() => this.onDeviceEvent(ScryptedInterface.Camera, undefined));
|
||||
|
||||
data = await this.createErrorImage(new NeverWaitError());
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user