diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES index ea4ea8e..3f00d8b 100644 --- a/KNOWN_ISSUES +++ b/KNOWN_ISSUES @@ -3,7 +3,15 @@ last updated: 0a9bec1c874a9b62000b4156ae75e23991121ed0 - Youtube web scraper integration broken - Spotify integration only finds artists, not albums or tracks - Tag management shows only top-level tags -- (Maybe) editing of items broken? +- (Maybe) patch requests broken? + - Checked and fixed track - Lots of front-end typescript warnings - When not logged in, an exception may occur trying to visit a page instead of redirecting properly +- Google Play Music still listed although the service has been + terminated by Google +- during batch linking, linking dialog closes when clicking outside. + this shouldn't happen. +- during batch linking, if the page is left or the dialog closes, + the jobs are still continuing to execute. This shouldn't happen. +- no way to exit the edit dialog diff --git a/client/src/components/windows/track/TrackWindow.tsx b/client/src/components/windows/track/TrackWindow.tsx index dc3abe6..abfafc9 100644 --- a/client/src/components/windows/track/TrackWindow.tsx +++ b/client/src/components/windows/track/TrackWindow.tsx @@ -15,6 +15,7 @@ import EditTrackDialog from './EditTrackDialog'; import EditIcon from '@material-ui/icons/Edit'; import { modifyTrack } from '../../../lib/saveChanges'; import { getTrack } from '../../../lib/backend/tracks'; +import { Artist, Id, Tag } from '../../../api/api'; export type TrackMetadata = serverApi.QueryResponseTrackDetails; @@ -142,7 +143,21 @@ export function TrackWindowControlled(props: { open={editing} onClose={() => { setEditing(false); }} onSubmit={(v: serverApi.PatchTrackRequest) => { - modifyTrack(trackId, v) + // Remove any details about linked resources and leave only their IDs. + let v_modified = { + ...v, + album: undefined, + artists: undefined, + tags: undefined, + albumId: v.albumId || v.album?.id || undefined, + artistIds: v.artistIds || v.artists?.map ( + (a: (Artist & Id)) => { return a.id } + ) || undefined, + tagIds: v.tagIds || v.tags?.map ( + (t: (Tag & Id)) => { return t.id } + ) || undefined, + }; + modifyTrack(trackId, v_modified) .then(() => dispatch({ type: TrackWindowStateActions.Reload })) diff --git a/client/src/lib/integration/spotify/SpotifyClientCreds.tsx b/client/src/lib/integration/spotify/SpotifyClientCreds.tsx index 39246f1..fa8dbc0 100644 --- a/client/src/lib/integration/spotify/SpotifyClientCreds.tsx +++ b/client/src/lib/integration/spotify/SpotifyClientCreds.tsx @@ -40,8 +40,10 @@ export default class SpotifyClientCreds extends Integration { `/integrations/${this.integrationId}/v1/search?q=queens&type=artist`); if (!response.ok) { - throw new Error("Spttify Client Credentials test failed: " + JSON.stringify(response)); + throw new Error("Spotify Client Credentials test failed: " + JSON.stringify(response)); } + + console.log("Spotify test response:", await response.json()) } async searchTrack(query: string, limit: number): Promise { @@ -49,10 +51,10 @@ export default class SpotifyClientCreds extends Integration { } async searchAlbum(query: string, limit: number): Promise { return this.search(query, SearchType.Album, limit); - } + } async searchArtist(query: string, limit: number): Promise { return this.search(query, SearchType.Artist, limit); - } + } async search(query: string, type: SearchType, limit: number): Promise { diff --git a/server/db/Track.ts b/server/db/Track.ts index e1307e8..d131c4f 100644 --- a/server/db/Track.ts +++ b/server/db/Track.ts @@ -180,19 +180,19 @@ export async function modifyTrack(userId: number, trackId: number, track: Track, // Start retrieving artists if we are modifying those. const artistIdsPromise: Promise = track.artistIds ? - trx.select('artistId') - .from('tracks_artists') - .whereIn('artistId', track.artistIds) - .then((as: any) => as.map((a: any) => a['artistId'])) + trx.select('id') + .from('artists') + .whereIn('id', track.artistIds) + .then((as: any) => as.map((a: any) => a['id'])) : (async () => undefined)(); // Start retrieving tags if we are modifying those. const tagIdsPromise = track.tagIds ? trx.select('id') - .from('tracks_tags') - .whereIn('tagId', track.tagIds) - .then((ts: any) => ts.map((t: any) => t['tagId'])) : + .from('tags') + .whereIn('id', track.tagIds) + .then((ts: any) => ts.map((t: any) => t['id'])) : (async () => undefined)(); // Start retrieving album if we are modifying that. @@ -205,15 +205,15 @@ export async function modifyTrack(userId: number, trackId: number, track: Track, .then((r: any) => (r && r[0]) ? r[0]['id'] : undefined) : (async () => undefined)(); - let blablums = await trx.select('id').from('albums'); - // Wait for the requests to finish. var [oldTrack, artists, tags, album] = await Promise.all([trackIdPromise, artistIdsPromise, tagIdsPromise, albumIdPromise]);; + console.log("Patch track: ", oldTrack, artists, tags, album); + // Check that we found all objects we need. - if ((!artists || !_.isEqual(artists.sort(), (track.artistIds || []).sort())) || - (!tags || !_.isEqual(tags.sort(), (track.tagIds || []).sort())) || - (!album && track.albumId) || + if ((track.artistIds && (!artists || !_.isEqual(artists.sort(), (track.artistIds || []).sort()))) || + (track.tagIds && (!tags || !_.isEqual(tags.sort(), (track.tagIds || []).sort()))) || + (track.albumId && !album) || !oldTrack) { throw makeNotFoundError(); }