Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some fix #1408

Merged
merged 7 commits into from
Mar 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: dock manager
agalwood committed Mar 28, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 680fdac38b02a5e2bb2aedcadcdd024e274e737d
14 changes: 8 additions & 6 deletions src/main/ui/DockManager.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
APP_RUN_MODE
} from '@shared/constants'

const isMac = is.macOS()
const enabled = is.macOS()

export default class DockManager extends EventEmitter {
constructor (options) {
@@ -20,7 +20,7 @@ export default class DockManager extends EventEmitter {
}
}

show = isMac
show = enabled
? () => {
if (app.dock.isVisible()) {
return
@@ -30,7 +30,7 @@ export default class DockManager extends EventEmitter {
}
: () => {}

hide = isMac
hide = enabled
? () => {
if (!app.dock.isVisible()) {
return
@@ -40,21 +40,23 @@ export default class DockManager extends EventEmitter {
}
: () => {}

setBadge = isMac
// macOS setBadge not working
// @see https://github.com/electron/electron/issues/25745#issuecomment-702826143
setBadge = enabled
? (text) => {
app.dock.setBadge(text)
}
: (text) => {}

handleSpeedChange = isMac
handleSpeedChange = enabled
? (speed) => {
const { downloadSpeed } = speed
const text = downloadSpeed > 0 ? `${bytesToSize(downloadSpeed)}/s` : ''
this.setBadge(text)
}
: (text) => {}

openDock = isMac
openDock = enabled
? (path) => {
app.dock.downloadFinished(path)
}