Disabled Clear All button when downloads include only the application update and when they also include files, clear only the files (#2294)

This commit is contained in:
Tasos Boulis
2022-10-20 16:20:51 +03:00
committed by GitHub
parent 48869a654f
commit bbf162e7d0
3 changed files with 33 additions and 7 deletions

View File

@@ -157,10 +157,16 @@ export class DownloadsManager extends JsonFileManager<DownloadedItems> {
clearDownloadsDropDown = () => {
log.debug('DownloadsManager.clearDownloadsDropDown');
this.saveAll({});
this.fileSizes = new Map();
if (this.hasUpdate()) {
this.saveAll({
[APP_UPDATE_KEY]: this.downloads[APP_UPDATE_KEY],
});
} else {
this.saveAll({});
this.toggleAppMenuDownloadsEnabled(false);
}
this.closeDownloadsDropdown();
this.toggleAppMenuDownloadsEnabled(false);
this.fileSizes = new Map();
}
showFileInFolder = (item?: DownloadedItem) => {
@@ -282,6 +288,10 @@ export class DownloadsManager extends JsonFileManager<DownloadedItems> {
WindowManager.sendToRenderer(HIDE_DOWNLOADS_DROPDOWN_BUTTON_BADGE);
}
hasUpdate = () => {
return Boolean(this.downloads[APP_UPDATE_KEY]?.type === DownloadItemTypeEnum.UPDATE);
}
private markFileAsDeleted = (item: DownloadedItem) => {
const fileId = this.getDownloadedFileId(item);
const file = this.downloads[fileId];