mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-21 21:13:00 +01:00
added functionality to favorite a song. fixes #323
This commit is contained in:
parent
1d19857977
commit
5e82c18d8a
@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Updated dependencies to latest
|
||||
- added theme files to stylelint ignore
|
||||
- fixed other stylelint errors
|
||||
- Added functionality to favorite a song ([fixes #323](https://github.com/Mastermindzh/tidal-hifi/issues/323))
|
||||
- Added a hotkey to favorite ("Add to collection") songs: Control+a
|
||||
- Added the "favorite" field in the `mediaInfo` and the API `/current` endpoint
|
||||
- Added an endpoint to toggle favoriting a song: `http://localhost:47836/favorite/toggle`
|
||||
|
||||
## [5.7.1]
|
||||
|
||||
|
@ -12,4 +12,5 @@ export const globalEvents = {
|
||||
error: "error",
|
||||
whip: "whip",
|
||||
log: "log",
|
||||
toggleFavorite: "toggleFavorite",
|
||||
};
|
||||
|
@ -10,4 +10,5 @@ export interface MediaInfo {
|
||||
current: string;
|
||||
duration: string;
|
||||
image: string;
|
||||
favorite: boolean;
|
||||
}
|
||||
|
@ -9,4 +9,5 @@ export interface Options {
|
||||
"app-name": string;
|
||||
image: string;
|
||||
icon: string;
|
||||
favorite: boolean;
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ const elements = {
|
||||
album_name_cell: '[class^="album"]',
|
||||
tracklist_row: '[data-test="tracklist-row"]',
|
||||
volume: '*[data-test="volume"]',
|
||||
favorite: '*[data-test="footer-favorite-button"]',
|
||||
/**
|
||||
* Get an element from the dom
|
||||
* @param {*} key key in elements object to fetch
|
||||
@ -131,6 +132,10 @@ const elements = {
|
||||
return this.get("volume").getAttribute("aria-checked") === "false"; // it's muted if aria-checked is false
|
||||
},
|
||||
|
||||
isFavorite: function () {
|
||||
return this.get("favorite").getAttribute("aria-checked") === "true";
|
||||
},
|
||||
|
||||
/**
|
||||
* Shorthand function to get the text of a dom element
|
||||
* @param {*} key key in elements object to fetch
|
||||
@ -208,6 +213,10 @@ function addHotKeys() {
|
||||
handleLogout();
|
||||
});
|
||||
|
||||
addHotkey("Control+a", function () {
|
||||
elements.click("favorite");
|
||||
});
|
||||
|
||||
addHotkey("Control+h", function () {
|
||||
elements.click("home");
|
||||
});
|
||||
@ -306,6 +315,9 @@ function addIPCEventListeners() {
|
||||
case globalEvents.pause:
|
||||
elements.click("pause");
|
||||
break;
|
||||
case globalEvents.toggleFavorite:
|
||||
elements.click("favorite");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -516,6 +528,7 @@ setInterval(function () {
|
||||
"app-name": appName,
|
||||
image: "",
|
||||
icon: "",
|
||||
favorite: elements.isFavorite(),
|
||||
};
|
||||
|
||||
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
||||
|
@ -40,6 +40,9 @@ export const startExpress = (mainWindow: BrowserWindow) => {
|
||||
|
||||
if (settingsStore.get(settings.playBackControl)) {
|
||||
expressApp.get("/play", (req, res) => handleGlobalEvent(res, globalEvents.play));
|
||||
expressApp.post("/favorite/toggle", (req, res) =>
|
||||
handleGlobalEvent(res, globalEvents.toggleFavorite)
|
||||
);
|
||||
expressApp.get("/pause", (req, res) => handleGlobalEvent(res, globalEvents.pause));
|
||||
expressApp.get("/next", (req, res) => handleGlobalEvent(res, globalEvents.next));
|
||||
expressApp.get("/previous", (req, res) => handleGlobalEvent(res, globalEvents.previous));
|
||||
|
@ -11,6 +11,7 @@ export const mediaInfo = {
|
||||
current: "",
|
||||
duration: "",
|
||||
image: "tidal-hifi-icon",
|
||||
favorite: false,
|
||||
};
|
||||
|
||||
export const updateMediaInfo = (arg: MediaInfo) => {
|
||||
@ -23,6 +24,7 @@ export const updateMediaInfo = (arg: MediaInfo) => {
|
||||
mediaInfo.current = propOrDefault(arg.current);
|
||||
mediaInfo.duration = propOrDefault(arg.duration);
|
||||
mediaInfo.image = propOrDefault(arg.image);
|
||||
mediaInfo.favorite = arg.favorite;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user