MCPcopy
hub / github.com/watsonbox/exportify / loadSlice

Method loadSlice

src/components/data/PlaylistsData.ts:92–111  ·  view source on GitHub ↗
(start = 0, end = start + this.PLAYLIST_LIMIT)

Source from the content-addressed store, hash-verified

90 }
91
92 private async loadSlice(start = 0, end = start + this.PLAYLIST_LIMIT) {
93 if (this.dataInitialized) {
94 const loadedData = this.data.slice(start, end)
95
96 if (loadedData.filter(i => i != null && Object.keys(i).length === 0).length === 0) {
97 return loadedData
98 }
99 }
100
101 const playlistsUrl = `https://api.spotify.com/v1/users/${this.userId}/playlists?offset=${start}&limit=${end - start}`
102 const playlistsResponse = await apiCall(playlistsUrl, this.accessToken)
103 const playlistsData = playlistsResponse.data
104
105 if (!this.dataInitialized) {
106 this.data = Array(playlistsData.total).fill(this.PLACEHOLDER)
107 this.dataInitialized = true
108 }
109
110 this.data.splice(start, playlistsData.items.length, ...playlistsData.items)
111 }
112
113 private async loadLikedTracksPlaylist() {
114 if (this.likedTracksPlaylist !== null) {

Callers 3

totalMethod · 0.95
sliceMethod · 0.95
loadAllMethod · 0.95

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected