Skip to content

Commit

Permalink
feat: duplicated song warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlauer-Hax committed Sep 30, 2024
1 parent 4568910 commit 3d56920
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pages/music/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ export function uploadSongToDrop(songs: Reference<Song[]>, artists: ArtistRef[],
uploadingSongs.setValue(uploadingSongs.getValue().map((x) => ({ ...x, [uploadId]: 100 })));
},
credentials: () => API.getToken(),
backendResponse: async (id: string) => {
backendResponse: async (response) => {
uploadingSongs.setValue(uploadingSongs.getValue().filter((x) => !x[uploadId]));
if (response.startsWith("duplicate:")) {
alert(`You already uploaded this song. Please use the add existing song button instead.`);
songs.setValue(songs.getValue().filter((x) => x._id !== uploadId));
// TODO: Open Dropover to automatically add the song using split at :
return;
}
const song = await API.music.songs.create({
title: cleanedUpTitle,
artists,
Expand All @@ -46,9 +52,9 @@ export function uploadSongToDrop(songs: Reference<Song[]>, artists: ArtistRef[],
primaryGenre,
secondaryGenre,
year: new Date().getFullYear(),
file: id,
file: response,
}).then(stupidErrorAlert);
songs.setValue(songs.getValue().map((x) => x._id == uploadId ? { ...x, _id: song.id, file: id } : x));
songs.setValue(songs.getValue().map((x) => x._id == uploadId ? { ...x, _id: song.id, file: response } : x));
},
// deno-lint-ignore require-await
onUploadTick: async (percentage) => {
Expand Down

0 comments on commit 3d56920

Please sign in to comment.