Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanTGold committed Jul 14, 2024
1 parent 8ad8da7 commit 6fac7bf
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Download extends KalturaPlayer.core.BasePlugin {
private componentDisposers: Array<typeof Function> = [];
private downloadPluginManager: DownloadPluginManager;
private _pluginButtonRef: HTMLButtonElement | null = null;
private downloadMetadata?: DownloadMetadata;
public triggeredByKeyboard = false;
private store: any;

Expand All @@ -50,10 +49,6 @@ class Download extends KalturaPlayer.core.BasePlugin {
return true;
}

public isAudioPlayerSupported(): boolean {
return true;
}

private get upperBarManager(): UpperBarManager {
return this.player.getService('upperBarManager') as UpperBarManager;
}
Expand Down Expand Up @@ -145,9 +140,9 @@ class Download extends KalturaPlayer.core.BasePlugin {
);
}

public isEntrySupported(): boolean {
if (!this.downloadMetadata) return false;
const {flavors, captions, attachments, imageDownloadUrl} = this.downloadMetadata;
public isEntrySupported(downloadMetadata: DownloadMetadata): boolean {
if (!downloadMetadata) return false;
const {flavors, captions, attachments, imageDownloadUrl} = downloadMetadata;
const {displayCaptions, displayAttachments, displaySources} = this.downloadPluginManager.downloadPlugin.config;
return (
(displaySources && (flavors.length || imageDownloadUrl)) || (displayCaptions && captions.length) || (displayAttachments && attachments.length)
Expand All @@ -158,11 +153,11 @@ class Download extends KalturaPlayer.core.BasePlugin {
await this.ready;

this.downloadPluginManager.setShowOverlay(false, false);
this.downloadMetadata = await this.downloadPluginManager.getDownloadMetadata(true);
const downloadMetadata = await this.downloadPluginManager.getDownloadMetadata(true);

if (this.isEntrySupported()) {
if (this.isEntrySupported(downloadMetadata)) {
this.logger.debug('Download is supported for current entry');
this.injectOverlayComponents(this.downloadMetadata);
this.injectOverlayComponents(downloadMetadata);
}
}

Expand All @@ -172,7 +167,6 @@ class Download extends KalturaPlayer.core.BasePlugin {
}

reset() {
this.downloadMetadata = null;
this.upperBarManager?.remove(this.iconId);
this.iconId = -1;
this._pluginButtonRef = null;
Expand Down

0 comments on commit 6fac7bf

Please sign in to comment.