()
| 34 | } |
| 35 | |
| 36 | apply() { |
| 37 | this.items.textContent = ""; // Remove all childs |
| 38 | this.items.append(createMenuItem("Current page", storeThisPage)); |
| 39 | this.items.append(createMenuItem("Track", storeTrack)); |
| 40 | this.items.append(createMenuItem("Track with timestamp", storeTrackWithTime)); |
| 41 | |
| 42 | const select = createSortSelect(this.filter); |
| 43 | select.onchange = (event) => { |
| 44 | this.filter = event.srcElement.selectedIndex; |
| 45 | this.apply(); |
| 46 | }; |
| 47 | this.items.append(select); |
| 48 | |
| 49 | const collection = this.getStorage(); |
| 50 | for (const item of collection) { |
| 51 | if (this.filter !== 0) { |
| 52 | const isTrack = this.isTrack(item.uri); |
| 53 | if (this.filter === 1 && isTrack) continue; |
| 54 | if (this.filter === 2 && !isTrack) continue; |
| 55 | } |
| 56 | |
| 57 | this.items.append(new CardContainer(item)); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | isTrack(uri) { |
| 62 | return uri.startsWith("spotify:track:") || uri.startsWith("spotify:episode:"); |
no test coverage detected