From 4eb77d56b16e818c3e08d316ac4c493e6d914bf1 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Wed, 6 Mar 2024 08:21:59 -0800 Subject: [PATCH] fix: error logs --- src/stores/playingList.ts | 13 +++++++++++-- src/utils/mediafetch/fetcher.ts | 1 - src/utils/mediafetch/paginatedfetch.ts | 1 - 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/stores/playingList.ts b/src/stores/playingList.ts index 7adbe9c50..c6bffdac5 100644 --- a/src/stores/playingList.ts +++ b/src/stores/playingList.ts @@ -5,6 +5,7 @@ import TrackPlayer, { RepeatMode } from 'react-native-track-player'; import { clearPlaylistUninterrupted } from '@utils/RNTPUtils'; import { NoxRepeatMode } from '../enums/RepeatMode'; import { savePlayMode } from '@utils/ChromeStorage'; +import logger from '@utils/Logger'; interface NoxPlaylistStore { playingList: Array; @@ -26,10 +27,18 @@ const playlistStore = createStore(() => ({ })); export const setPlayingIndex = (index = 0, songId?: string) => { + const currentQueue = getCurrentTPQueue(); if (songId) { - index = getCurrentTPQueue().findIndex(v => v.id === songId); + index = currentQueue.findIndex(v => v.id === songId); } else { - songId = getCurrentTPQueue()[index].id; + try { + songId = currentQueue[index].id; + } catch { + logger.warn( + `[setPlayingIndex] could not get index ${index} from current queue: ${JSON.stringify(currentQueue)} ` + ); + return; + } } playlistStore.setState({ currentPlayingIndex: index, diff --git a/src/utils/mediafetch/fetcher.ts b/src/utils/mediafetch/fetcher.ts index efb5e428d..4e1c8fe69 100644 --- a/src/utils/mediafetch/fetcher.ts +++ b/src/utils/mediafetch/fetcher.ts @@ -91,7 +91,6 @@ export const fetchPaginatedAPI = async ({ }) .catch((err: any) => { console.error(err, pages); - pages.text().then(console.log); }); }) ); diff --git a/src/utils/mediafetch/paginatedfetch.ts b/src/utils/mediafetch/paginatedfetch.ts index c26226754..50bb28a8f 100644 --- a/src/utils/mediafetch/paginatedfetch.ts +++ b/src/utils/mediafetch/paginatedfetch.ts @@ -86,7 +86,6 @@ export const fetchPaginatedAPI = async ({ }) .catch((err: any) => { console.error(err, pages); - pages.text().then(console.log); }); }) );