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

delete playlist after migration #218

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 10 additions & 5 deletions src/components/Playlists/Playlist.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,17 @@

for (let index = 0; index < ownersIds.length; index++) {
const element = ownersIds[index];

let playerService = createPlayerService();
let owner = await playerService.fetchPlayerOrGetFromCache(element);

let owner = playerService.fetchPlayerOrGetFromCache(element);
if (owner?.playerId != playerId) {
canModify = false;
if (playerService.isMainPlayer(owner.playerId)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cause of this issue is that I added keepOriginalId=true to the fetchPlayer request. So the player fetched by the old ID has it as a playerId property. Let's make it a param and set it here to false, so it will return a new ID.

canModify = false;
} else {
let main_id = playerService.getPlayerMain(element);
if (main_id == null || main_id != playerId) {
canModify = false;
}
}
}
if (owner) {
newOwners.push(owner);
Expand Down Expand Up @@ -135,7 +140,7 @@

$: songs = playlist.songs;
$: totalItems = songs.length;
$: updatePage(songs.length);
$: updatePage();
$: retrieveOwner(playlist, $accountStore?.player?.playerId);
$: updateExpanded(expanded);
$: description = `
Expand Down
3 changes: 3 additions & 0 deletions src/services/beatleader/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default () => {

const isPlayerMain = playerId => playerId === mainPlayerId;

const getPlayerMain = playerId => mainPlayerId;

const getProfileFreshnessDate = (player, refreshInterval = null) => {
const lastUpdated = player && player.profileLastUpdated ? player.profileLastUpdated : null;
if (!lastUpdated) return addToDate(-SECOND);
Expand Down Expand Up @@ -120,6 +122,7 @@ export default () => {

service = {
isMainPlayer,
getPlayerMain,
getAll,
getAllActive,
getPlayerGain,
Expand Down