diff --git a/src/components/PlaylistTable.jsx b/src/components/PlaylistTable.jsx index f74c707..4350778 100644 --- a/src/components/PlaylistTable.jsx +++ b/src/components/PlaylistTable.jsx @@ -79,25 +79,29 @@ class PlaylistTable extends React.Component { this.playlistSearch.current.clear() } - const playlists = await this.playlistsData.slice( - ((this.state.currentPage - 1) * this.PAGE_SIZE), - ((this.state.currentPage - 1) * this.PAGE_SIZE) + this.PAGE_SIZE - ).catch(apiCallErrorHandler) - - // FIXME: Handle unmounting - this.setState( - { - initialized: true, - searching: false, - playlists: playlists, - playlistCount: await this.playlistsData.total() - }, - () => { - const min = ((this.state.currentPage - 1) * this.PAGE_SIZE) + 1 - const max = Math.min(min + this.PAGE_SIZE - 1, this.state.playlistCount) - this.setSubtitle(`${min}-${max} of ${this.state.playlistCount} playlists for ${this.userId}`) - } - ) + try { + const playlists = await this.playlistsData.slice( + ((this.state.currentPage - 1) * this.PAGE_SIZE), + ((this.state.currentPage - 1) * this.PAGE_SIZE) + this.PAGE_SIZE + ) + + // FIXME: Handle unmounting + this.setState( + { + initialized: true, + searching: false, + playlists: playlists, + playlistCount: await this.playlistsData.total() + }, + () => { + const min = ((this.state.currentPage - 1) * this.PAGE_SIZE) + 1 + const max = Math.min(min + this.PAGE_SIZE - 1, this.state.playlistCount) + this.setSubtitle(`${min}-${max} of ${this.state.playlistCount} playlists for ${this.userId}`) + } + ) + } catch(error) { + apiCallErrorHandler(error) + } } handlePlaylistsLoadingStarted = () => {