mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-07-28 00:22:26 +02:00
fixed the discord end time stamp issue. fixes #282
This commit is contained in:
@@ -23,6 +23,7 @@ export const settings = {
|
||||
discord: {
|
||||
detailsPrefix: "discord.detailsPrefix",
|
||||
buttonText: "discord.buttonText",
|
||||
includeTimestamps: "discord.includeTimestamps",
|
||||
},
|
||||
ListenBrainz: {
|
||||
root: "ListenBrainz",
|
||||
|
@@ -48,6 +48,7 @@ let adBlock: HTMLInputElement,
|
||||
listenbrainz_delay: HTMLInputElement,
|
||||
enableWaylandSupport: HTMLInputElement,
|
||||
discord_details_prefix: HTMLInputElement,
|
||||
discord_include_timestamps: HTMLInputElement,
|
||||
discord_button_text: HTMLInputElement;
|
||||
|
||||
addCustomCss(app);
|
||||
@@ -135,6 +136,7 @@ function refreshSettings() {
|
||||
ListenBrainzToken.value = settingsStore.get(settings.ListenBrainz.token);
|
||||
listenbrainz_delay.value = settingsStore.get(settings.ListenBrainz.delay);
|
||||
discord_details_prefix.value = settingsStore.get(settings.discord.detailsPrefix);
|
||||
discord_include_timestamps.checked = settingsStore.get(settings.discord.includeTimestamps);
|
||||
discord_button_text.value = settingsStore.get(settings.discord.buttonText);
|
||||
|
||||
// set state of all switches with additional settings
|
||||
@@ -246,6 +248,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
ListenBrainzAPI = get("ListenBrainzAPI");
|
||||
ListenBrainzToken = get("ListenBrainzToken");
|
||||
discord_details_prefix = get("discord_details_prefix");
|
||||
discord_include_timestamps = get("discord_include_timestamps");
|
||||
listenbrainz_delay = get("listenbrainz_delay");
|
||||
discord_button_text = get("discord_button_text");
|
||||
|
||||
@@ -280,5 +283,6 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
addInputListener(ListenBrainzToken, settings.ListenBrainz.token);
|
||||
addInputListener(listenbrainz_delay, settings.ListenBrainz.delay);
|
||||
addInputListener(discord_details_prefix, settings.discord.detailsPrefix);
|
||||
addInputListener(discord_include_timestamps, settings.discord.includeTimestamps);
|
||||
addInputListener(discord_button_text, settings.discord.buttonText);
|
||||
});
|
||||
|
@@ -216,6 +216,17 @@
|
||||
</label>
|
||||
</div>
|
||||
<div id="discord_options">
|
||||
<div class="group__option" class="hidden">
|
||||
<div class="group__description">
|
||||
<h4>Include timestamps</h4>
|
||||
<p>Show current/end playtime in the Discord client</p>
|
||||
</div>
|
||||
<label class="switch">
|
||||
<input id="discord_include_timestamps" type="checkbox" />
|
||||
<span class="switch__slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="group__option" class="hidden">
|
||||
<div class="group__description">
|
||||
<h4>Details prefix</h4>
|
||||
|
@@ -45,7 +45,7 @@ const elements = {
|
||||
media: '*[data-test="current-media-imagery"]',
|
||||
image: "img",
|
||||
current: '*[data-test="current-time"]',
|
||||
duration: '*[data-test="duration"]',
|
||||
duration: '*[class^=playbackControlsContainer] *[data-test="duration"]',
|
||||
bar: '*[data-test="progress-bar"]',
|
||||
footer: "#footerPlayer",
|
||||
mediaItem: "[data-type='mediaItem']",
|
||||
|
@@ -30,30 +30,38 @@ const observer = () => {
|
||||
settingsStore.get<string, string>(settings.discord.detailsPrefix) ?? "Listening to ";
|
||||
const buttonText =
|
||||
settingsStore.get<string, string>(settings.discord.buttonText) ?? "Play on TIDAL";
|
||||
const includeTimestamps =
|
||||
settingsStore.get<string, boolean>(settings.discord.includeTimestamps) ?? true;
|
||||
|
||||
let activity = {
|
||||
...idleStatus,
|
||||
...{
|
||||
startTimestamp: includeTimestamps ? now : undefined,
|
||||
endTimestamp: includeTimestamps ? remaining : undefined,
|
||||
},
|
||||
};
|
||||
if (mediaInfo.url) {
|
||||
rpc.setActivity({
|
||||
...idleStatus,
|
||||
activity = {
|
||||
...activity,
|
||||
...{
|
||||
details: `${detailsPrefix}${mediaInfo.title}`,
|
||||
state: mediaInfo.artists ? mediaInfo.artists : "unknown artist(s)",
|
||||
startTimestamp: now,
|
||||
endTimestamp: remaining,
|
||||
largeImageKey: mediaInfo.image,
|
||||
largeImageText: mediaInfo.album ? mediaInfo.album : `${idleStatus.largeImageText}`,
|
||||
buttons: [{ label: buttonText, url: mediaInfo.url }],
|
||||
},
|
||||
});
|
||||
};
|
||||
} else {
|
||||
rpc.setActivity({
|
||||
...idleStatus,
|
||||
activity = {
|
||||
...activity,
|
||||
...{
|
||||
details: `Watching ${mediaInfo.title}`,
|
||||
state: mediaInfo.artists,
|
||||
startTimestamp: now,
|
||||
endTimestamp: remaining,
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
rpc.setActivity(activity);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -21,6 +21,7 @@ export const settingsStore = new Store({
|
||||
discord: {
|
||||
detailsPrefix: "Listening to ",
|
||||
buttonText: "Play on Tidal",
|
||||
includeTimestamps: true,
|
||||
},
|
||||
ListenBrainz: {
|
||||
enabled: false,
|
||||
@@ -61,6 +62,13 @@ export const settingsStore = new Store({
|
||||
migrationStore.get(settings.ListenBrainz.delay) ?? 5000
|
||||
);
|
||||
},
|
||||
"5.8.0": (migrationStore) => {
|
||||
console.log("running migrations for 5.8.0");
|
||||
migrationStore.set(
|
||||
settings.discord.includeTimestamps,
|
||||
migrationStore.get(settings.discord.includeTimestamps) ?? true
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user