Merge pull request #1598 from hawtim/fix-history-list-error

fix: render weekData error
master
Hawtim 3 years ago committed by GitHub
commit 9e787bab03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,10 @@ export default {
artists: [], artists: [],
mvs: [], mvs: [],
cloudDisk: [], cloudDisk: [],
playHistory: {
weekData: [],
allData: [],
},
}, },
contextMenu: { contextMenu: {
clickObjectID: 0, clickObjectID: 0,

@ -35,14 +35,14 @@ function setTitle(track) {
? `${track.name} · ${track.ar[0].name} - YesPlayMusic` ? `${track.name} · ${track.ar[0].name} - YesPlayMusic`
: 'YesPlayMusic'; : 'YesPlayMusic';
if (isCreateTray) { if (isCreateTray) {
ipcRenderer.send('updateTrayTooltip', document.title); ipcRenderer?.send('updateTrayTooltip', document.title);
} }
store.commit('updateTitle', document.title); store.commit('updateTitle', document.title);
} }
function setTrayLikeState(isLiked) { function setTrayLikeState(isLiked) {
if (isCreateTray) { if (isCreateTray) {
ipcRenderer.send('updateTrayLikeState', isLiked); ipcRenderer?.send('updateTrayLikeState', isLiked);
} }
} }
@ -223,7 +223,7 @@ export default class {
_setPlaying(isPlaying) { _setPlaying(isPlaying) {
this._playing = isPlaying; this._playing = isPlaying;
if (isCreateTray) { if (isCreateTray) {
ipcRenderer.send('updateTrayPlayState', this._playing); ipcRenderer?.send('updateTrayPlayState', this._playing);
} }
} }
_setIntervals() { _setIntervals() {
@ -235,7 +235,7 @@ export default class {
this._progress = this._howler.seek(); this._progress = this._howler.seek();
localStorage.setItem('playerCurrentTrackTime', this._progress); localStorage.setItem('playerCurrentTrackTime', this._progress);
if (isCreateMpris) { if (isCreateMpris) {
ipcRenderer.send('playerCurrentTrackTime', this._progress); ipcRenderer?.send('playerCurrentTrackTime', this._progress);
} }
}, 1000); }, 1000);
} }
@ -561,7 +561,7 @@ export default class {
navigator.mediaSession.metadata = new window.MediaMetadata(metadata); navigator.mediaSession.metadata = new window.MediaMetadata(metadata);
if (isCreateMpris) { if (isCreateMpris) {
ipcRenderer.send('metadata', metadata); ipcRenderer?.send('metadata', metadata);
} }
} }
_updateMediaSessionPositionState() { _updateMediaSessionPositionState() {
@ -617,7 +617,7 @@ export default class {
} }
let copyTrack = { ...track }; let copyTrack = { ...track };
copyTrack.dt -= seekTime * 1000; copyTrack.dt -= seekTime * 1000;
ipcRenderer.send('playDiscordPresence', copyTrack); ipcRenderer?.send('playDiscordPresence', copyTrack);
} }
_pauseDiscordPresence(track) { _pauseDiscordPresence(track) {
if ( if (
@ -626,7 +626,7 @@ export default class {
) { ) {
return null; return null;
} }
ipcRenderer.send('pauseDiscordPresence', track); ipcRenderer?.send('pauseDiscordPresence', track);
} }
currentTrackID() { currentTrackID() {
@ -867,7 +867,7 @@ export default class {
sendSelfToIpcMain() { sendSelfToIpcMain() {
if (process.env.IS_ELECTRON !== true) return false; if (process.env.IS_ELECTRON !== true) return false;
let liked = store.state.liked.songs.includes(this.currentTrack.id); let liked = store.state.liked.songs.includes(this.currentTrack.id);
ipcRenderer.send('player', { ipcRenderer?.send('player', {
playing: this.playing, playing: this.playing,
likedCurrentTrack: liked, likedCurrentTrack: liked,
}); });
@ -883,13 +883,13 @@ export default class {
this.repeatMode = 'on'; this.repeatMode = 'on';
} }
if (isCreateMpris) { if (isCreateMpris) {
ipcRenderer.send('switchRepeatMode', this.repeatMode); ipcRenderer?.send('switchRepeatMode', this.repeatMode);
} }
} }
switchShuffle() { switchShuffle() {
this.shuffle = !this.shuffle; this.shuffle = !this.shuffle;
if (isCreateMpris) { if (isCreateMpris) {
ipcRenderer.send('switchShuffle', this.shuffle); ipcRenderer?.send('switchShuffle', this.shuffle);
} }
} }
switchReversed() { switchReversed() {

@ -269,7 +269,7 @@ export default {
// Pick 3 or fewer lyrics based on the lyric lines. // Pick 3 or fewer lyrics based on the lyric lines.
const lyricsToPick = Math.min(lyricLine.length, 3); const lyricsToPick = Math.min(lyricLine.length, 3);
// The upperbound of the lyric line to pick // The upperBound of the lyric line to pick
const randomUpperBound = lyricLine.length - lyricsToPick; const randomUpperBound = lyricLine.length - lyricsToPick;
const startLyricLineIndex = randomNum(0, randomUpperBound - 1); const startLyricLineIndex = randomNum(0, randomUpperBound - 1);
@ -294,7 +294,8 @@ export default {
playHistoryList() { playHistoryList() {
if (this.show && this.playHistoryMode === 'week') { if (this.show && this.playHistoryMode === 'week') {
return this.liked.playHistory.weekData; return this.liked.playHistory.weekData;
} else if (this.show && this.playHistoryMode === 'all') { }
if (this.show && this.playHistoryMode === 'all') {
return this.liked.playHistory.allData; return this.liked.playHistory.allData;
} }
return []; return [];

Loading…
Cancel
Save