refactor: Convert protected methods to private (#2358)
This commit is contained in:
@@ -106,7 +106,7 @@ export class FrigateCamera extends Camera {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async _initializeConfig(
|
||||
private async _initializeConfig(
|
||||
hass: HomeAssistant,
|
||||
entityRegistryManager: EntityRegistryManager,
|
||||
): Promise<void> {
|
||||
@@ -193,7 +193,7 @@ export class FrigateCamera extends Camera {
|
||||
};
|
||||
}
|
||||
|
||||
protected _getFrigateCameraNameFromEntity(entity: Entity): string | null {
|
||||
private _getFrigateCameraNameFromEntity(entity: Entity): string | null {
|
||||
if (
|
||||
entity.platform === 'frigate' &&
|
||||
entity.unique_id &&
|
||||
@@ -244,7 +244,7 @@ export class FrigateCamera extends Camera {
|
||||
});
|
||||
}
|
||||
|
||||
protected _getJSMPEGEndpoint(): Endpoint | null {
|
||||
private _getJSMPEGEndpoint(): Endpoint | null {
|
||||
if (!this._config.frigate.camera_name) {
|
||||
return null;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ export class FrigateCamera extends Camera {
|
||||
return { endpoint: cameraURL };
|
||||
}
|
||||
|
||||
protected async _getPTZCapabilities(
|
||||
private async _getPTZCapabilities(
|
||||
hass: HomeAssistant,
|
||||
cameraConfig: CameraConfig,
|
||||
): Promise<PTZCapabilities | null> {
|
||||
@@ -352,7 +352,7 @@ export class FrigateCamera extends Camera {
|
||||
* @param cameraConfig The camera config in question.
|
||||
* @returns The entity id of the motion sensor or null.
|
||||
*/
|
||||
protected _getMotionSensor(
|
||||
private _getMotionSensor(
|
||||
cameraConfig: CameraConfig,
|
||||
entities: Entity[],
|
||||
): string | null {
|
||||
@@ -376,7 +376,7 @@ export class FrigateCamera extends Camera {
|
||||
* @param cameraConfig The camera config in question.
|
||||
* @returns The entity id of the occupancy sensor or null.
|
||||
*/
|
||||
protected _getOccupancySensor(
|
||||
private _getOccupancySensor(
|
||||
cameraConfig: CameraConfig,
|
||||
entities: Entity[],
|
||||
): string[] | null {
|
||||
@@ -419,7 +419,7 @@ export class FrigateCamera extends Camera {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected async _subscribeToEvents(
|
||||
private async _subscribeToEvents(
|
||||
hass: HomeAssistant,
|
||||
frigateEventWatcher: FrigateWatcherSubscriptionInterface<FrigateEventChange>,
|
||||
): Promise<void> {
|
||||
@@ -441,7 +441,7 @@ export class FrigateCamera extends Camera {
|
||||
this._onDestroy(() => frigateEventWatcher.unsubscribe(request));
|
||||
}
|
||||
|
||||
protected _frigateEventHandler = (ev: FrigateEventChange): void => {
|
||||
private _frigateEventHandler = (ev: FrigateEventChange): void => {
|
||||
const snapshotChange =
|
||||
(!ev.before.has_snapshot && ev.after.has_snapshot) ||
|
||||
ev.before.snapshot?.frame_time !== ev.after.snapshot?.frame_time;
|
||||
@@ -487,7 +487,7 @@ export class FrigateCamera extends Camera {
|
||||
});
|
||||
};
|
||||
|
||||
protected async _subscribeToReviews(
|
||||
private async _subscribeToReviews(
|
||||
hass: HomeAssistant,
|
||||
frigateReviewWatcher: FrigateWatcherSubscriptionInterface<FrigateReviewChange>,
|
||||
): Promise<void> {
|
||||
@@ -512,7 +512,7 @@ export class FrigateCamera extends Camera {
|
||||
this._onDestroy(() => frigateReviewWatcher.unsubscribe(request));
|
||||
}
|
||||
|
||||
protected _frigateReviewHandler = (review: FrigateReviewChange): void => {
|
||||
private _frigateReviewHandler = (review: FrigateReviewChange): void => {
|
||||
const config = this.getConfig();
|
||||
const cameraID = this._config.id;
|
||||
|
||||
|
||||
@@ -120,14 +120,14 @@ export class FrigateCameraManagerEngine
|
||||
extends GenericCameraManagerEngine
|
||||
implements CameraManagerEngine
|
||||
{
|
||||
protected _entityRegistryManager: EntityRegistryManager;
|
||||
protected _frigateEventWatcher: FrigateEventWatcher;
|
||||
protected _frigateReviewWatcher: FrigateReviewWatcher;
|
||||
protected _recordingSegmentsCache: RecordingSegmentsCache;
|
||||
protected _requestCache: CameraManagerRequestCache;
|
||||
private _entityRegistryManager: EntityRegistryManager;
|
||||
private _frigateEventWatcher: FrigateEventWatcher;
|
||||
private _frigateReviewWatcher: FrigateReviewWatcher;
|
||||
private _recordingSegmentsCache: RecordingSegmentsCache;
|
||||
private _requestCache: CameraManagerRequestCache;
|
||||
|
||||
// Garbage collect segments at most once an hour.
|
||||
protected _throttledSegmentGarbageCollector = throttle(
|
||||
private _throttledSegmentGarbageCollector = throttle(
|
||||
this._garbageCollectSegments.bind(this),
|
||||
60 * 60 * 1000,
|
||||
{ leading: false, trailing: true },
|
||||
@@ -272,17 +272,17 @@ export class FrigateCameraManagerEngine
|
||||
* If all cameras have identical zones/labels config, creates a single batch query.
|
||||
* Otherwise fans out to per-camera queries.
|
||||
*/
|
||||
protected _generateBatchableQuery(
|
||||
private _generateBatchableQuery(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
cameraIDs: Set<string>,
|
||||
query: PartialEventQuery & { type: QueryType.Event },
|
||||
): EventQuery[] | null;
|
||||
protected _generateBatchableQuery(
|
||||
private _generateBatchableQuery(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
cameraIDs: Set<string>,
|
||||
query: PartialReviewQuery & { type: QueryType.Review },
|
||||
): ReviewQuery[] | null;
|
||||
protected _generateBatchableQuery(
|
||||
private _generateBatchableQuery(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
cameraIDs: Set<string>,
|
||||
query: (PartialEventQuery | PartialReviewQuery) & {
|
||||
@@ -368,7 +368,7 @@ export class FrigateCameraManagerEngine
|
||||
);
|
||||
}
|
||||
|
||||
protected _buildInstanceToCameraIDMapFromQuery(
|
||||
private _buildInstanceToCameraIDMapFromQuery(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
cameraIDs: Set<string>,
|
||||
): Map<string, Set<string>> {
|
||||
@@ -386,7 +386,7 @@ export class FrigateCameraManagerEngine
|
||||
return output;
|
||||
}
|
||||
|
||||
protected _getFrigateCameraNamesForCameraIDs(
|
||||
private _getFrigateCameraNamesForCameraIDs(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
cameraIDs: Set<string>,
|
||||
): Set<string> {
|
||||
@@ -725,7 +725,7 @@ export class FrigateCameraManagerEngine
|
||||
return output.size ? output : null;
|
||||
}
|
||||
|
||||
protected _getCameraIDMatch(
|
||||
private _getCameraIDMatch(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
query: CameraQuery,
|
||||
instanceID: string,
|
||||
@@ -927,7 +927,7 @@ export class FrigateCameraManagerEngine
|
||||
return null;
|
||||
}
|
||||
|
||||
protected _getQueryableCameraConfig(
|
||||
private _getQueryableCameraConfig(
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
cameraID: string,
|
||||
): CameraConfig | null {
|
||||
@@ -938,7 +938,7 @@ export class FrigateCameraManagerEngine
|
||||
return cameraConfig;
|
||||
}
|
||||
|
||||
protected _splitSubLabels(input: string): string[] {
|
||||
private _splitSubLabels(input: string): string[] {
|
||||
// A note on Frigate sub_labels: As of Frigate v0.12 sub_labels is a string
|
||||
// (not an array) per event, but may contain comma-separated values (e.g.
|
||||
// double-take (https://github.com/jakowenko/double-take) identifying two
|
||||
@@ -1058,7 +1058,7 @@ export class FrigateCameraManagerEngine
|
||||
* Garbage collect recording segments that no longer feature in the recordings
|
||||
* returned by the Frigate backend.
|
||||
*/
|
||||
protected async _garbageCollectSegments(
|
||||
private async _garbageCollectSegments(
|
||||
hass: HomeAssistant,
|
||||
store: CameraManagerReadOnlyConfigStore,
|
||||
): Promise<void> {
|
||||
@@ -1113,7 +1113,7 @@ export class FrigateCameraManagerEngine
|
||||
* @param segments An array of segments dataset items. Must be sorted from oldest to youngest.
|
||||
* @returns
|
||||
*/
|
||||
protected _getSeekTimeInSegments(
|
||||
private _getSeekTimeInSegments(
|
||||
startTime: Date,
|
||||
targetTime: Date,
|
||||
segments: RecordingSegment[],
|
||||
|
||||
@@ -25,10 +25,10 @@ import {
|
||||
} from './util';
|
||||
|
||||
export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia {
|
||||
protected _event: FrigateEvent;
|
||||
protected _contentID: string;
|
||||
protected _thumbnail: string;
|
||||
protected _subLabels: string[] | null;
|
||||
private _event: FrigateEvent;
|
||||
private _contentID: string;
|
||||
private _thumbnail: string;
|
||||
private _subLabels: string[] | null;
|
||||
|
||||
constructor(
|
||||
mediaType: ViewMediaType,
|
||||
@@ -107,10 +107,10 @@ export class FrigateEventViewMedia extends ViewMedia implements EventViewMedia {
|
||||
}
|
||||
|
||||
export class FrigateRecordingViewMedia extends ViewMedia implements RecordingViewMedia {
|
||||
protected _recording: FrigateRecording;
|
||||
protected _id: string;
|
||||
protected _contentID: string;
|
||||
protected _title: string;
|
||||
private _recording: FrigateRecording;
|
||||
private _id: string;
|
||||
private _contentID: string;
|
||||
private _title: string;
|
||||
|
||||
constructor(
|
||||
mediaType: ViewMediaType,
|
||||
@@ -156,10 +156,10 @@ export class FrigateRecordingViewMedia extends ViewMedia implements RecordingVie
|
||||
}
|
||||
|
||||
export class FrigateReviewViewMedia extends ViewMedia implements ReviewViewMedia {
|
||||
protected _review: FrigateReview;
|
||||
protected _contentID: string;
|
||||
protected _thumbnail: string | null;
|
||||
protected _title: string;
|
||||
private _review: FrigateReview;
|
||||
private _contentID: string;
|
||||
private _thumbnail: string | null;
|
||||
private _title: string;
|
||||
|
||||
constructor(
|
||||
cameraID: string,
|
||||
|
||||
Reference in New Issue
Block a user