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 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
9 changes: 5 additions & 4 deletions src/components/Playlists/Playlist.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@

async function retrieveOwner(playlist, playerId) {
var newOwners = [];
canModify = true;
canShare = true;

if (playlist?.customData?.owner) {
canShare = false;
if (playlist.customData.owner == 'BeatLeader') {
Expand All @@ -83,10 +86,8 @@

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

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

let owner = await playerService.fetchPlayerOrGetFromCache(element, undefined, undefined, undefined, undefined, false);
if (owner?.playerId != playerId) {
canModify = false;
}
Expand Down Expand Up @@ -135,7 +136,7 @@

$: songs = playlist.songs;
$: totalItems = songs.length;
$: updatePage(songs.length);
$: updatePage();
$: retrieveOwner(playlist, $accountStore?.player?.playerId);
$: updateExpanded(expanded);
$: description = `
Expand Down
4 changes: 2 additions & 2 deletions src/network/clients/beatleader/player/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import queue from '../../../queues/queues';
import createClient from '../../generic';
import process from './process';

const get = async ({playerId, priority = queue.PRIORITY.FG_HIGH, ...queueOptions} = {}) =>
queue.BEATLEADER_API.player(playerId, priority, queueOptions);
const get = async ({playerId, priority = queue.PRIORITY.FG_HIGH, keepOriginalId = true, ...queueOptions} = {}) =>
queue.BEATLEADER_API.player(playerId, priority, keepOriginalId, queueOptions);

const client = createClient(get, process);

Expand Down
6 changes: 3 additions & 3 deletions src/network/queues/beatleader/api-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const STEAM_API_URL = '/cors/steamapi';
export const STEAM_KEY = 'B0A7AF33E804D0ABBDE43BA9DD5DAB48';

export const BL_API_USER_URL = `${BL_API_URL}user`;
export const BL_API_PLAYER_INFO_URL = BL_API_URL + 'player/${playerId}?keepOriginalId=true';
export const BL_API_PLAYER_INFO_URL = BL_API_URL + 'player/${playerId}?keepOriginalId=${keepOriginalId}';
export const BL_API_SCORES_URL =
BL_API_URL +
'player/${playerId}/scores?page=${page}&sortBy=${sort}&order=${order}&search=${search}&diff=${diff}&mode=${mode}&requirements=${requirements}&type=${songType}&modifiers=${modifiers}&stars_from=${starsFrom}&stars_to=${starsTo}&eventId=${eventId}&count=${count}';
Expand Down Expand Up @@ -217,8 +217,8 @@ export default (options = {}) => {
const user = async (priority = PRIORITY.FG_HIGH, options = {}) =>
fetchJson(BL_API_USER_URL, {...options, retries: 0, credentials: 'include', maxAge: 1, cacheTtl: null}, priority);

const player = async (playerId, priority = PRIORITY.FG_LOW, options = {}) =>
fetchJson(substituteVars(BL_API_PLAYER_INFO_URL, {playerId}), options, priority);
const player = async (playerId, priority = PRIORITY.FG_LOW, keepOriginalId = true, options = {}) =>
fetchJson(substituteVars(BL_API_PLAYER_INFO_URL, {playerId, keepOriginalId}), options, priority);

const steamProfile = async (playerId, priority = PRIORITY.FG_LOW, options = {}) =>
fetchJson(substituteVars(STEAM_API_PROFILE_URL, {steamKey: STEAM_KEY, playerId}), options, priority);
Expand Down
17 changes: 13 additions & 4 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 All @@ -69,18 +71,24 @@ export default () => {
const isResponseCached = response => playerApiClient.isResponseCached(response);
const getDataFromResponse = response => playerApiClient.getDataFromResponse(response);

const fetchPlayer = async (playerId, priority = PRIORITY.FG_LOW, {fullResponse = false, ...options} = {}) =>
const fetchPlayer = async (playerId, priority = PRIORITY.FG_LOW, keepOriginalId = true, {fullResponse = false, ...options} = {}) =>
resolvePromiseOrWaitForPending(`apiClient/${playerId}/${fullResponse}/${options.maxAge ?? MINUTE}`, () =>
playerApiClient.getProcessed({...options, playerId, priority, fullResponse})
playerApiClient.getProcessed({...options, playerId, priority, keepOriginalId, fullResponse})
);

const findPlayer = async (query, priority = PRIORITY.FG_LOW, {fullResponse = false, ...options} = {}) =>
resolvePromiseOrWaitForPending(`apiClient/find/${query}/${fullResponse}`, () =>
playerFindApiClient.getProcessed({...options, query, priority, fullResponse})
);

const fetchPlayerOrGetFromCache = async (playerId, refreshInterval = MINUTE, priority = PRIORITY.FG_LOW, signal = null, force = false) =>
fetchPlayer(playerId, priority, {signal, cacheTtl: MINUTE, maxAge: force ? 0 : refreshInterval});
const fetchPlayerOrGetFromCache = async (
playerId,
refreshInterval = MINUTE,
priority = PRIORITY.FG_LOW,
signal = null,
force = false,
keepOriginalId = true
) => fetchPlayer(playerId, priority, keepOriginalId, {signal, cacheTtl: MINUTE, maxAge: force ? 0 : refreshInterval});

const fetchAccGraph = async (playerId, priority = PRIORITY.BG_NORMAL, throwErrors = false) => {
try {
Expand Down Expand Up @@ -120,6 +128,7 @@ export default () => {

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