mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
added timeout when writing volume to config
This commit is contained in:
@ -77,7 +77,18 @@ function toPercent(volume) {
|
||||
|
||||
function saveVolume(volume, options) {
|
||||
options.savedVolume = volume;
|
||||
setOptions("precise-volume", options);
|
||||
writeOptions(options);
|
||||
}
|
||||
|
||||
//without this function it would rewrite config 20 time when volume change by 20
|
||||
let writeTimeout;
|
||||
function writeOptions(options) {
|
||||
if (writeTimeout) clearTimeout(writeTimeout);
|
||||
|
||||
writeTimeout = setTimeout(() => {
|
||||
setOptions("precise-volume", options);
|
||||
writeTimeout = null;
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
/** Restore saved volume and setup tooltip */
|
||||
|
||||
Reference in New Issue
Block a user