package: use debounce util from qsupackage
This commit is contained in:
1 parent
901fd78c15
commit
f225b4e54a
5 files changed
+157
-25
No files matched your search
+3
-3
@@ -1,7 +1,7 @@
|
||||
import { app, screen, Menu, Tray, BrowserWindow } from 'electron'
|
||||
import Constants from './utils/Constants'
|
||||
import { debounce } from './utils/Util'
|
||||
import { join } from 'path'
|
||||
import { debounce } from 'qsu'
|
||||
let tray
|
||||
let trayOptions
|
||||
|
||||
@@ -40,10 +40,10 @@ export function createTray(window: BrowserWindow, options) {
|
||||
} else {
|
||||
// handle click on tray icon
|
||||
tray.on('right-click', function () {
|
||||
debounce(() => toggleWindow(window))
|
||||
debounce(() => toggleWindow(window), 200)
|
||||
})
|
||||
tray.on('click', function () {
|
||||
debounce(() => toggleWindow(window))
|
||||
debounce(() => toggleWindow(window), 200)
|
||||
})
|
||||
// no menu for tray window
|
||||
window.setMenu(null)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
export function debounce(func, timeout = 200) {
|
||||
let timer
|
||||
return (function (...args) {
|
||||
if (!timer) {
|
||||
func.apply(this, args)
|
||||
}
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
timer = undefined
|
||||
}, timeout)
|
||||
})()
|
||||
}
|
||||
Reference in new issue
Block a user