Merge branch 'master' of github.com:Mastermindzh/tidal-hifi

This commit is contained in:
Ottomated
2024-05-16 19:33:18 -07:00
9 changed files with 32 additions and 7 deletions

View File

@@ -2,6 +2,8 @@ import { TidalState } from "../models/tidalState";
export const mainTidalState: TidalState = {
status: "Stopped",
repeat: "Off",
shuffle: false,
};
export function getLegacyMediaInfo() {
@@ -25,5 +27,10 @@ export function getLegacyMediaInfo() {
durationInSeconds: mainTidalState.currentTrack?.duration ?? 0,
image: "tidal-hifi-icon",
favorite: false,
player: {
status: mainTidalState.status.toLowerCase(),
shuffle: mainTidalState.shuffle,
repeat: mainTidalState.repeat,
},
};
}

View File

@@ -1,5 +1,7 @@
export type TidalState = {
status: "Playing" | "Paused" | "Stopped";
repeat: "Off" | "All" | "Single";
shuffle: boolean;
currentTrack?: {
id: number;
title: string;

View File

@@ -433,7 +433,7 @@
<h4>TIDAL Hi-Fi</h4>
<div class="about-section__version">
<a target="_blank" rel="noopener"
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.11.0">5.11.0</a>
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.12.0">5.12.0</a>
</div>
<div class="about-section__links">
<a target="_blank" rel="noopener" href="https://github.com/mastermindzh/tidal-hifi/"

View File

@@ -85,7 +85,7 @@ export type ReduxState = {
};
};
const enum RepeatMode {
export const enum RepeatMode {
REPEAT_OFF = 0,
REPEAT_ALL = 1,
REPEAT_SINGLE = 2,

View File

@@ -1,4 +1,4 @@
import { getTidalReduxStore, ReduxState, TidalReduxStore } from "./redux";
import { getTidalReduxStore, ReduxState, RepeatMode, TidalReduxStore } from "./redux";
import { createStore } from "zustand/vanilla";
import { ipcRenderer } from "electron";
import { globalEvents } from "../constants/globalEvents";
@@ -7,6 +7,8 @@ import { TidalState } from "../models/tidalState";
export const $tidalState = createStore<TidalState>(() => ({
status: "Stopped",
repeat: "Off",
shuffle: false,
}));
export let reduxStore: TidalReduxStore | undefined;
@@ -133,8 +135,10 @@ export const coverArtPaths = new Map<string, Promise<string>>();
};
}
const oldState = $tidalState.getState();
const newState = {
const newState: TidalState = {
status: playbackStatusMap[state.playbackControls.playbackState] ?? "Stopped",
repeat: repeatModeMap[state.playQueue.repeatMode] ?? "Off",
shuffle: state.playQueue.shuffleModeEnabled,
currentTrack: track,
};
if (!equal(oldState, newState)) {
@@ -153,3 +157,9 @@ const playbackStatusMap = {
IDLE: "Stopped",
STALLED: "Stopped",
} as const;
const repeatModeMap = {
[RepeatMode.REPEAT_OFF]: "Off",
[RepeatMode.REPEAT_ALL]: "All",
[RepeatMode.REPEAT_SINGLE]: "Single",
} as const;

View File

@@ -3,4 +3,6 @@ import { TidalState } from "../models/tidalState";
// This object is globally mutated
export const tidalState: TidalState = {
status: "Stopped",
repeat: "Off",
shuffle: false,
};