Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: render weekData error #1598

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default {
artists: [],
mvs: [],
cloudDisk: [],
playHistory: {
weekData: [],
allData: [],
},
},
contextMenu: {
clickObjectID: 0,
Expand Down
20 changes: 10 additions & 10 deletions src/utils/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ function setTitle(track) {
? `${track.name} · ${track.ar[0].name} - YesPlayMusic`
: 'YesPlayMusic';
if (isCreateTray) {
ipcRenderer.send('updateTrayTooltip', document.title);
ipcRenderer?.send('updateTrayTooltip', document.title);
}
store.commit('updateTitle', document.title);
}

function setTrayLikeState(isLiked) {
if (isCreateTray) {
ipcRenderer.send('updateTrayLikeState', isLiked);
ipcRenderer?.send('updateTrayLikeState', isLiked);
}
}

Expand Down Expand Up @@ -223,7 +223,7 @@ export default class {
_setPlaying(isPlaying) {
this._playing = isPlaying;
if (isCreateTray) {
ipcRenderer.send('updateTrayPlayState', this._playing);
ipcRenderer?.send('updateTrayPlayState', this._playing);
}
}
_setIntervals() {
Expand All @@ -235,7 +235,7 @@ export default class {
this._progress = this._howler.seek();
localStorage.setItem('playerCurrentTrackTime', this._progress);
if (isCreateMpris) {
ipcRenderer.send('playerCurrentTrackTime', this._progress);
ipcRenderer?.send('playerCurrentTrackTime', this._progress);
}
}, 1000);
}
Expand Down Expand Up @@ -561,7 +561,7 @@ export default class {

navigator.mediaSession.metadata = new window.MediaMetadata(metadata);
if (isCreateMpris) {
ipcRenderer.send('metadata', metadata);
ipcRenderer?.send('metadata', metadata);
}
}
_updateMediaSessionPositionState() {
Expand Down Expand Up @@ -617,7 +617,7 @@ export default class {
}
let copyTrack = { ...track };
copyTrack.dt -= seekTime * 1000;
ipcRenderer.send('playDiscordPresence', copyTrack);
ipcRenderer?.send('playDiscordPresence', copyTrack);
}
_pauseDiscordPresence(track) {
if (
Expand All @@ -626,7 +626,7 @@ export default class {
) {
return null;
}
ipcRenderer.send('pauseDiscordPresence', track);
ipcRenderer?.send('pauseDiscordPresence', track);
}

currentTrackID() {
Expand Down Expand Up @@ -867,7 +867,7 @@ export default class {
sendSelfToIpcMain() {
if (process.env.IS_ELECTRON !== true) return false;
let liked = store.state.liked.songs.includes(this.currentTrack.id);
ipcRenderer.send('player', {
ipcRenderer?.send('player', {
playing: this.playing,
likedCurrentTrack: liked,
});
Expand All @@ -883,13 +883,13 @@ export default class {
this.repeatMode = 'on';
}
if (isCreateMpris) {
ipcRenderer.send('switchRepeatMode', this.repeatMode);
ipcRenderer?.send('switchRepeatMode', this.repeatMode);
}
}
switchShuffle() {
this.shuffle = !this.shuffle;
if (isCreateMpris) {
ipcRenderer.send('switchShuffle', this.shuffle);
ipcRenderer?.send('switchShuffle', this.shuffle);
}
}
switchReversed() {
Expand Down
5 changes: 3 additions & 2 deletions src/views/library.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default {
// Pick 3 or fewer lyrics based on the lyric lines.
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 startLyricLineIndex = randomNum(0, randomUpperBound - 1);

Expand All @@ -292,7 +292,8 @@ export default {
playHistoryList() {
if (this.show && this.playHistoryMode === 'week') {
return this.liked.playHistory.weekData;
} else if (this.show && this.playHistoryMode === 'all') {
}
if (this.show && this.playHistoryMode === 'all') {
return this.liked.playHistory.allData;
}
return [];
Expand Down