Clear camera store when cameras are initialized.
This commit is contained in:
@@ -24,8 +24,8 @@ export class CameraManagerEngineFactory {
|
||||
this._resolvedMediaCache = resolvedMediaCache;
|
||||
}
|
||||
|
||||
public async createEngine(engine: Engine): Promise<CameraManagerEngine | null> {
|
||||
let cameraManagerEngine: CameraManagerEngine | null = null;
|
||||
public async createEngine(engine: Engine): Promise<CameraManagerEngine> {
|
||||
let cameraManagerEngine: CameraManagerEngine;
|
||||
switch (engine) {
|
||||
case Engine.Generic:
|
||||
const { GenericCameraManagerEngine } = await import('./generic/engine-generic');
|
||||
|
||||
@@ -129,6 +129,8 @@ export class CameraManager {
|
||||
return;
|
||||
}
|
||||
|
||||
this._store.reset();
|
||||
|
||||
// For each camera merge the config (which has no defaults) into the camera
|
||||
// global config (which does have defaults). The merging must happen in this
|
||||
// order, to ensure that the defaults in the cameras global config do not
|
||||
|
||||
@@ -41,6 +41,13 @@ export class CameraManagerStore implements CameraManagerReadOnlyConfigStore {
|
||||
this._enginesByType.set(engine.getEngineType(), engine);
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this._allConfigs.clear();
|
||||
this._visibleConfigs.clear();
|
||||
this._enginesByCamera.clear();
|
||||
this._enginesByType.clear();
|
||||
}
|
||||
|
||||
public getCameraConfig(cameraID: string): CameraConfig | null {
|
||||
return this._allConfigs.get(cameraID) ?? null;
|
||||
}
|
||||
@@ -74,11 +81,7 @@ export class CameraManagerStore implements CameraManagerReadOnlyConfigStore {
|
||||
}
|
||||
|
||||
public getCameraConfigForMedia(media: ViewMedia): CameraConfig | null {
|
||||
const cameraID = media.getCameraID();
|
||||
if (!cameraID) {
|
||||
return null;
|
||||
}
|
||||
return this.getCameraConfig(cameraID);
|
||||
return this.getCameraConfig(media.getCameraID());
|
||||
}
|
||||
|
||||
public getEngineOfType(engine: Engine): CameraManagerEngine | null {
|
||||
@@ -108,11 +111,7 @@ export class CameraManagerStore implements CameraManagerReadOnlyConfigStore {
|
||||
}
|
||||
|
||||
public getEngineForMedia(media: ViewMedia): CameraManagerEngine | null {
|
||||
const cameraID = media.getCameraID();
|
||||
if (!cameraID) {
|
||||
return null;
|
||||
}
|
||||
return this.getEngineForCameraID(cameraID);
|
||||
return this.getEngineForCameraID(media.getCameraID());
|
||||
}
|
||||
|
||||
public getAllEngines(): CameraManagerEngine[] {
|
||||
|
||||
Reference in New Issue
Block a user