refactor: update download ID extraction and improve optional chaining in download services

This commit is contained in:
Moyasee
2026-01-06 18:05:05 +02:00
parent 8f477072ba
commit 81b3ad3612
3 changed files with 11 additions and 11 deletions

View File

@@ -450,9 +450,9 @@ export class DownloadManager {
} | null> {
switch (download.downloader) {
case Downloader.Gofile: {
const id = download.uri.split("/").pop()!;
const id = download.uri.split("/").pop();
const token = await GofileApi.authorize();
const downloadLink = await GofileApi.getDownloadLink(id);
const downloadLink = await GofileApi.getDownloadLink(id as string);
await GofileApi.checkDownloadUrl(downloadLink);
return {
@@ -462,8 +462,8 @@ export class DownloadManager {
};
}
case Downloader.PixelDrain: {
const id = download.uri.split("/").pop()!;
const downloadUrl = await PixelDrainApi.getDownloadUrl(id);
const id = download.uri.split("/").pop();
const downloadUrl = await PixelDrainApi.getDownloadUrl(id as string);
return {
url: downloadUrl,
@@ -576,9 +576,9 @@ export class DownloadManager {
switch (download.downloader) {
case Downloader.Gofile: {
const id = download.uri.split("/").pop()!;
const id = download.uri.split("/").pop();
const token = await GofileApi.authorize();
const downloadLink = await GofileApi.getDownloadLink(id);
const downloadLink = await GofileApi.getDownloadLink(id as string);
await GofileApi.checkDownloadUrl(downloadLink);
return {
@@ -592,8 +592,8 @@ export class DownloadManager {
};
}
case Downloader.PixelDrain: {
const id = download.uri.split("/").pop()!;
const downloadUrl = await PixelDrainApi.getDownloadUrl(id);
const id = download.uri.split("/").pop();
const downloadUrl = await PixelDrainApi.getDownloadUrl(id as string);
return {
action: "start",

View File

@@ -134,7 +134,7 @@ export class JsHttpDownloader {
): Promise<void> {
const response = await fetch(url, {
headers: requestHeaders,
signal: this.abortController!.signal,
signal: this.abortController?.signal,
});
if (!response.ok && response.status !== 206) {

View File

@@ -61,7 +61,7 @@ export class JsMultiLinkDownloader {
});
const status = this.downloader.getDownloadStatus();
if (status && status.status === "complete") {
if (status?.status === "complete") {
this.completedDownloads.push({
name: status.folderName,
size: status.fileSize,
@@ -105,7 +105,7 @@ export class JsMultiLinkDownloader {
});
const status = this.downloader.getDownloadStatus();
if (status && status.status === "complete") {
if (status?.status === "complete") {
this.completedDownloads.push({
name: status.folderName,
size: status.fileSize,