INNER CODE UNIT · TypeScript

updateActiveDownload

SurgeDM/Surge · extension/entrypoints/popup/store/index.ts:126

function updateActiveDownload(id: string, update: (download: DownloadStatus) => DownloadStatus): void {
  setActiveDownloads((downloads) => {
    const index = downloads.findIndex((download) => download.id === id);
    if (index < 0) return downloads;

    const next = [...downloads];
    next[index] = update(downloads[index]);
    return next;
  });
}

function createDownload(
  message: DownloadStartedMsg | DownloadQueuedMsg,
  status: DownloadStatus['status'],
  totalSize = 0,
): DownloadStatus {
  return {
    id: message.DownloadID,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…