Skip to content

Commit

Permalink
Don't notify the user if showing the file location (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton authored Mar 19, 2021
1 parent 9ab4950 commit de96d0e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/downloads.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { shell } from 'electron'
import * as path from 'path'

import { createNotification } from './notifications'

import electronDl = require('electron-dl')
import config, { ConfigKey } from './config'
import { createNotification } from './notifications'

type State = 'cancelled' | 'completed' | 'interrupted'

Expand All @@ -27,15 +25,18 @@ function onDownloadComplete(filename: string, state: State): void {
}

export function init(): void {
const openFolderWhenDone = config.get(ConfigKey.DownloadsOpenFolderWhenDone)
const handleStarted = (item: Electron.DownloadItem) => {
item.once('done', (_, state) => {
onDownloadComplete(item.getFilename(), state)
})
}

electronDl({
saveAs: config.get(ConfigKey.DownloadsShowSaveAs),
openFolderWhenDone: config.get(ConfigKey.DownloadsOpenFolderWhenDone),
openFolderWhenDone,
directory: config.get(ConfigKey.DownloadsLocation),
showBadge: false,
onStarted: (item) => {
item.once('done', (_, state) => {
onDownloadComplete(item.getFilename(), state)
})
}
onStarted: openFolderWhenDone ? undefined : handleStarted
})
}

0 comments on commit de96d0e

Please sign in to comment.