From d0664d282931c7aad9f8995e2e1d191b50a99f56 Mon Sep 17 00:00:00 2001 From: SivanA-Kaltura <88330203+SivanA-Kaltura@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:15:48 +0300 Subject: [PATCH] use array includes --- src/dash-adapter.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dash-adapter.ts b/src/dash-adapter.ts index 4740a42..14de99f 100644 --- a/src/dash-adapter.ts +++ b/src/dash-adapter.ts @@ -1563,17 +1563,18 @@ export default class DashAdapter extends BaseMediaSourceAdapter { } public setCachedUrls(cachedUrls: string[]): void { - if (!Array.isArray(cachedUrls)) return; - const newUrls = new Set(cachedUrls); - const existingUrls = new Set(this.assetCache?.list()); - for (const url of newUrls) { - if (!existingUrls.has(url)) { - this.assetCache?.add(url); + if (!Array.isArray(cachedUrls) || !this.assetCache) return; + + const existingUrls = this.assetCache.list(); + + for (const url of cachedUrls) { + if (!existingUrls.includes(url)) { + this.assetCache.add(url); } } for (const url of existingUrls) { - if (!newUrls.has(url)) { - this.assetCache?.remove(url, true); + if (!cachedUrls.includes(url)) { + this.assetCache.remove(url, true); } } }