mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 13:32:42 +01:00
feat: you can now set updateFrequency in the settings window
This commit is contained in:
parent
3d2a9c3992
commit
4498e8a73e
@ -9,34 +9,35 @@
|
||||
* windowBounds: { width: 800, height: 600 },
|
||||
*/
|
||||
const settings = {
|
||||
notifications: "notifications",
|
||||
api: "api",
|
||||
menuBar: "menuBar",
|
||||
playBackControl: "playBackControl",
|
||||
skipArtists: "skipArtists",
|
||||
skippedArtists: "skippedArtists",
|
||||
adBlock: "adBlock",
|
||||
disableBackgroundThrottle: "disableBackgroundThrottle",
|
||||
api: "api",
|
||||
apiSettings: {
|
||||
root: "apiSettings",
|
||||
port: "apiSettings.port",
|
||||
},
|
||||
singleInstance: "singleInstance",
|
||||
disableBackgroundThrottle: "disableBackgroundThrottle",
|
||||
disableHardwareMediaKeys: "disableHardwareMediaKeys",
|
||||
enableCustomHotkeys: "enableCustomHotkeys",
|
||||
enableDiscord: "enableDiscord",
|
||||
flags: {
|
||||
disableHardwareMediaKeys: "flags.disableHardwareMediaKeys",
|
||||
gpuRasterization: "flags.gpuRasterization",
|
||||
},
|
||||
menuBar: "menuBar",
|
||||
minimizeOnClose: "minimizeOnClose",
|
||||
mpris: "mpris",
|
||||
enableCustomHotkeys: "enableCustomHotkeys",
|
||||
notifications: "notifications",
|
||||
playBackControl: "playBackControl",
|
||||
singleInstance: "singleInstance",
|
||||
skipArtists: "skipArtists",
|
||||
skippedArtists: "skippedArtists",
|
||||
trayIcon: "trayIcon",
|
||||
enableDiscord: "enableDiscord",
|
||||
updateFrequency: "updateFrequency",
|
||||
windowBounds: {
|
||||
root: "windowBounds",
|
||||
width: "windowBounds.width",
|
||||
height: "windowBounds.height",
|
||||
},
|
||||
minimizeOnClose: "minimizeOnClose",
|
||||
};
|
||||
|
||||
module.exports = settings;
|
||||
|
@ -1,20 +1,21 @@
|
||||
let trayIcon,
|
||||
minimizeOnClose,
|
||||
mpris,
|
||||
let adBlock,
|
||||
api,
|
||||
disableBackgroundThrottle,
|
||||
disableHardwareMediaKeys,
|
||||
enableCustomHotkeys,
|
||||
enableDiscord,
|
||||
skipArtists,
|
||||
gpuRasterization,
|
||||
menuBar,
|
||||
minimizeOnClose,
|
||||
mpris,
|
||||
notifications,
|
||||
playBackControl,
|
||||
api,
|
||||
port,
|
||||
menuBar,
|
||||
skippedArtists,
|
||||
adBlock,
|
||||
disableBackgroundThrottle,
|
||||
singleInstance,
|
||||
disableHardwareMediaKeys,
|
||||
gpuRasterization;
|
||||
skipArtists,
|
||||
skippedArtists,
|
||||
trayIcon,
|
||||
updateFrequency;
|
||||
|
||||
const { store, settings } = require("./../../scripts/settings");
|
||||
const { ipcRenderer } = require("electron");
|
||||
@ -25,23 +26,24 @@ const { app } = remote;
|
||||
* Sync the UI forms with the current settings
|
||||
*/
|
||||
function refreshSettings() {
|
||||
notifications.checked = store.get(settings.notifications);
|
||||
playBackControl.checked = store.get(settings.playBackControl);
|
||||
adBlock.checked = store.get(settings.adBlock);
|
||||
api.checked = store.get(settings.api);
|
||||
port.value = store.get(settings.apiSettings.port);
|
||||
menuBar.checked = store.get(settings.menuBar);
|
||||
trayIcon.checked = store.get(settings.trayIcon);
|
||||
mpris.checked = store.get(settings.mpris);
|
||||
disableBackgroundThrottle.checked = store.get("disableBackgroundThrottle");
|
||||
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
|
||||
enableCustomHotkeys.checked = store.get(settings.enableCustomHotkeys);
|
||||
enableDiscord.checked = store.get(settings.enableDiscord);
|
||||
gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
|
||||
menuBar.checked = store.get(settings.menuBar);
|
||||
minimizeOnClose.checked = store.get(settings.minimizeOnClose);
|
||||
mpris.checked = store.get(settings.mpris);
|
||||
notifications.checked = store.get(settings.notifications);
|
||||
playBackControl.checked = store.get(settings.playBackControl);
|
||||
port.value = store.get(settings.apiSettings.port);
|
||||
singleInstance.checked = store.get(settings.singleInstance);
|
||||
skipArtists.checked = store.get(settings.skipArtists);
|
||||
skippedArtists.value = store.get(settings.skippedArtists).join("\n");
|
||||
adBlock.checked = store.get(settings.adBlock);
|
||||
singleInstance.checked = store.get(settings.singleInstance);
|
||||
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
|
||||
gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
|
||||
disableBackgroundThrottle.checked = store.get("disableBackgroundThrottle");
|
||||
trayIcon.checked = store.get(settings.trayIcon);
|
||||
updateFrequency.value = store.get(settings.updateFrequency);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,41 +111,43 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById(tab).click();
|
||||
});
|
||||
|
||||
notifications = get("notifications");
|
||||
playBackControl = get("playBackControl");
|
||||
adBlock = get("adBlock");
|
||||
api = get("apiCheckbox");
|
||||
port = get("port");
|
||||
menuBar = get("menuBar");
|
||||
trayIcon = get("trayIcon");
|
||||
minimizeOnClose = get("minimizeOnClose");
|
||||
mpris = get("mprisCheckbox");
|
||||
disableBackgroundThrottle = get("disableBackgroundThrottle");
|
||||
disableHardwareMediaKeys = get("disableHardwareMediaKeys");
|
||||
enableCustomHotkeys = get("enableCustomHotkeys");
|
||||
enableDiscord = get("enableDiscord");
|
||||
gpuRasterization = get("gpuRasterization");
|
||||
menuBar = get("menuBar");
|
||||
minimizeOnClose = get("minimizeOnClose");
|
||||
mpris = get("mprisCheckbox");
|
||||
notifications = get("notifications");
|
||||
playBackControl = get("playBackControl");
|
||||
port = get("port");
|
||||
trayIcon = get("trayIcon");
|
||||
skipArtists = get("skipArtists");
|
||||
skippedArtists = get("skippedArtists");
|
||||
adBlock = get("adBlock");
|
||||
disableBackgroundThrottle = get("disableBackgroundThrottle");
|
||||
singleInstance = get("singleInstance");
|
||||
disableHardwareMediaKeys = get("disableHardwareMediaKeys");
|
||||
gpuRasterization = get("gpuRasterization");
|
||||
updateFrequency = get("updateFrequency");
|
||||
|
||||
refreshSettings();
|
||||
|
||||
addInputListener(notifications, settings.notifications);
|
||||
addInputListener(playBackControl, settings.playBackControl);
|
||||
addInputListener(adBlock, settings.adBlock);
|
||||
addInputListener(api, settings.api);
|
||||
addInputListener(port, settings.apiSettings.port);
|
||||
addInputListener(menuBar, settings.menuBar);
|
||||
addInputListener(trayIcon, settings.trayIcon);
|
||||
addInputListener(mpris, settings.mpris);
|
||||
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
|
||||
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
|
||||
addInputListener(enableCustomHotkeys, settings.enableCustomHotkeys);
|
||||
addInputListener(enableDiscord, settings.enableDiscord);
|
||||
addInputListener(gpuRasterization, settings.flags.gpuRasterization);
|
||||
addInputListener(menuBar, settings.menuBar);
|
||||
addInputListener(minimizeOnClose, settings.minimizeOnClose);
|
||||
addInputListener(mpris, settings.mpris);
|
||||
addInputListener(notifications, settings.notifications);
|
||||
addInputListener(playBackControl, settings.playBackControl);
|
||||
addInputListener(port, settings.apiSettings.port);
|
||||
addInputListener(skipArtists, settings.skipArtists);
|
||||
addTextAreaListener(skippedArtists, settings.skippedArtists);
|
||||
addInputListener(adBlock, settings.adBlock);
|
||||
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
|
||||
addInputListener(singleInstance, settings.singleInstance);
|
||||
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
|
||||
addInputListener(gpuRasterization, settings.flags.gpuRasterization);
|
||||
addInputListener(trayIcon, settings.trayIcon);
|
||||
addInputListener(updateFrequency, settings.updateFrequency);
|
||||
});
|
||||
|
@ -160,7 +160,7 @@
|
||||
<div class="group__option">
|
||||
<div class="group__description">
|
||||
<label for="port">API port</label>
|
||||
<input id="port" type="text" class="text-input" name="port" />
|
||||
<input id="port" type="number" class="text-input" name="port" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="group__option">
|
||||
@ -212,6 +212,22 @@
|
||||
</section>
|
||||
|
||||
<section id="advanced-section" class="tabs__section">
|
||||
<div class="group">
|
||||
<p class="group__title">Settings</p>
|
||||
<div class="group__option">
|
||||
<div class="group__description">
|
||||
<h4>Update frequency</h4>
|
||||
<p>
|
||||
The amount of time, in milliseconds, that tidal-hifi will refresh its playback info by scraping the
|
||||
website.
|
||||
The default of 500 seems to work in more cases but if you are fine with a bit more resource usage you
|
||||
can decrease it as well.
|
||||
</p>
|
||||
<input id="updateFrequency" type="number" class="text-input" name="updateFrequency" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="group">
|
||||
<p class="group__title">Flags</p>
|
||||
<div class="group__option">
|
||||
|
@ -7,7 +7,7 @@ const { downloadFile } = require("./scripts/download");
|
||||
const statuses = require("./constants/statuses");
|
||||
const hotkeys = require("./scripts/hotkeys");
|
||||
const globalEvents = require("./constants/globalEvents");
|
||||
const { skipArtists } = require("./constants/settings");
|
||||
const { skipArtists, updateFrequency } = require("./constants/settings");
|
||||
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
|
||||
const appName = "Tidal Hifi";
|
||||
let currentSong = "";
|
||||
@ -74,8 +74,7 @@ const elements = {
|
||||
|
||||
if (footer) {
|
||||
const artists = footer.querySelectorAll(this.artists);
|
||||
if (artists)
|
||||
return Array.from(artists).map((artist) => artist.textContent);
|
||||
if (artists) return Array.from(artists).map((artist) => artist.textContent);
|
||||
}
|
||||
return [];
|
||||
},
|
||||
@ -86,8 +85,7 @@ const elements = {
|
||||
* @returns {String} artists
|
||||
*/
|
||||
getArtistsString: function (artistsArray) {
|
||||
if (artistsArray.length > 0)
|
||||
return artistsArray.join(", ");
|
||||
if (artistsArray.length > 0) return artistsArray.join(", ");
|
||||
return "unknown artist(s)";
|
||||
},
|
||||
|
||||
@ -145,6 +143,21 @@ const elements = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the update frequency from the store
|
||||
* make sure it returns a number, if not use the default
|
||||
*/
|
||||
function getUpdateFrequency() {
|
||||
const storeValue = store.get(updateFrequency);
|
||||
const defaultValue = 500;
|
||||
|
||||
if (!isNaN(storeValue)) {
|
||||
return storeValue;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Play or pause the current song
|
||||
*/
|
||||
@ -416,7 +429,7 @@ setInterval(function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}, getUpdateFrequency());
|
||||
|
||||
if (process.platform === "linux" && store.get(settings.mpris)) {
|
||||
try {
|
||||
|
@ -7,29 +7,30 @@ let settingsWindow;
|
||||
|
||||
const store = new Store({
|
||||
defaults: {
|
||||
notifications: true,
|
||||
api: true,
|
||||
playBackControl: true,
|
||||
skipArtists: false,
|
||||
skippedArtists: [""],
|
||||
adBlock: false,
|
||||
disableBackgroundThrottle: true,
|
||||
menuBar: true,
|
||||
api: true,
|
||||
apiSettings: {
|
||||
port: 47836,
|
||||
},
|
||||
singleInstance: true,
|
||||
disableBackgroundThrottle: true,
|
||||
disableHardwareMediaKeys: false,
|
||||
trayIcon: true,
|
||||
minimizeOnClose: false,
|
||||
mpris: false,
|
||||
enableCustomHotkeys: false,
|
||||
enableDiscord: false,
|
||||
windowBounds: { width: 800, height: 600 },
|
||||
flags: {
|
||||
gpuRasterization: true,
|
||||
disableHardwareMediaKeys: false,
|
||||
},
|
||||
menuBar: true,
|
||||
minimizeOnClose: false,
|
||||
mpris: false,
|
||||
notifications: true,
|
||||
playBackControl: true,
|
||||
singleInstance: true,
|
||||
skipArtists: false,
|
||||
skippedArtists: [""],
|
||||
trayIcon: true,
|
||||
updateFrequency: 500,
|
||||
windowBounds: { width: 800, height: 600 },
|
||||
},
|
||||
migrations: {
|
||||
"3.1.0": (migrationStore) => {
|
||||
|
Loading…
Reference in New Issue
Block a user