Allow disable listen along (#426)

This commit is contained in:
Constantin Piber
2021-10-11 15:02:24 +02:00
parent 587818b91e
commit b9dbd8bd4d
4 changed files with 21 additions and 6 deletions

View File

@ -70,7 +70,7 @@ let clearActivity;
*/
let updateActivity;
module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
module.exports = (win, {activityTimoutEnabled, activityTimoutTime, listenAlong}) => {
window = win;
// We get multiple events
// Next song: PAUSE(n), PAUSE(n+1), PLAY(n+1)
@ -106,11 +106,11 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
largeImageKey: "logo",
largeImageText: [
songInfo.uploadDate,
songInfo.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " views"
songInfo.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " views",
].join(' || '),
buttons: [
buttons: listenAlong ? [
{ label: "Listen Along", url: songInfo.url },
],
] : undefined,
};
if (songInfo.isPaused) {
@ -119,7 +119,7 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
activityInfo.smallImageText = "idle/paused";
// Set start the timer so the activity gets cleared after a while if enabled
if (activityTimoutEnabled)
clearActivity = setTimeout(() => info.rpc.clearActivity().catch(console.error), activityTimoutTime || 10000);
clearActivity = setTimeout(() => info.rpc.clearActivity().catch(console.error), activityTimoutTime ?? 10000);
} else {
// Add the start and end time of the song
const songStartTime = Date.now() - songInfo.elapsedSeconds * 1000;

View File

@ -29,6 +29,15 @@ module.exports = (win, options, refreshMenu) => {
setOptions('discord', options);
},
},
{
label: "Listen Along",
type: "checkbox",
checked: options.listenAlong,
click: (item) => {
options.listenAlong = item.checked;
setOptions('discord', options);
},
},
{
label: "Set timeout time in config",
// open config.json