Skip to content

Commit d365061

Browse files
committed
feat: adapt frontend update playlist metadata with only provided fields | [AntonioMrtz#246]
1 parent 6f1b91b commit d365061

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: check-merge-conflict
1212

1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.3.7
14+
rev: v0.8.5
1515
hooks:
1616
- id: ruff
1717
args: [--fix]

Backend/app/spotify_electron/playlist/playlist_service.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,10 @@ def create_playlist(
162162

163163
def update_playlist_metadata( # noqa: C901
164164
name: str,
165+
token: TokenData,
165166
new_name: str | None = None,
166167
photo: str | None = None,
167168
description: str | None = None,
168-
*,
169-
token: TokenData,
170169
) -> None:
171170
"""
172171
Updates specified fields of a playlist's metadata.

Electron/src/pages/Playlist/Playlist.tsx

+4-11
Original file line numberDiff line numberDiff line change
@@ -269,30 +269,24 @@ export default function Playlist({ refreshSidebarData }: PropsPlaylist) {
269269
event.preventDefault();
270270

271271
try {
272-
// TODO add song to playlist instead of fetching already present songs
273-
const playlistData =
274-
await PlaylistsService.getPlaylistPlaylistsNameGet(playlistName);
275-
const newSongsPutPlaylist = [...playlistData.song_names];
276-
277272
const formPhoto =
278273
formData.photo && formData.photo.includes('http') ? formData.photo : '';
279274

280275
const formDescription = formData.description;
281276

282277
if (formData.name !== playlistName && formData.name !== '') {
283-
PlaylistsService.updatePlaylistPlaylistsNamePut(
278+
PlaylistsService.updatePlaylistMetadataPlaylistsNamePut(
284279
playlistName,
280+
formData.name,
285281
formPhoto,
286282
formDescription,
287-
newSongsPutPlaylist,
288-
formData.name,
289283
);
290284
} else {
291-
PlaylistsService.updatePlaylistPlaylistsNamePut(
285+
PlaylistsService.updatePlaylistMetadataPlaylistsNamePut(
292286
playlistName,
287+
null,
293288
formPhoto,
294289
formDescription,
295-
newSongsPutPlaylist,
296290
);
297291
}
298292

@@ -304,7 +298,6 @@ export default function Playlist({ refreshSidebarData }: PropsPlaylist) {
304298
refreshSidebarData();
305299
navigate(`/playlist/${formData.name}`, { replace: true });
306300
}, 500);
307-
refreshPlaylistData();
308301
return;
309302
}
310303

Electron/src/swagger/api/services/PlaylistsService.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,27 @@ export class PlaylistsService {
3131
});
3232
}
3333
/**
34-
* Update Playlist
35-
* Update playlist
34+
* Update Playlist Metadata
35+
* Update playlist metadata
3636
*
3737
* Args:
38-
* photo (str): playlist new photo
39-
* description (str): playlist new description
40-
* song_names (list[str], optional): playlist new song names. Defaults to Body(...).
41-
* new_name (str | None, optional): playlist new name. Defaults to None.
38+
* name (str): playlist name
39+
* new_name (str | None): new playlist name
40+
* photo (str | None): new photo URL
41+
* description (str | None): new description
42+
* token (TokenData): User authentication token
4243
* @param name
44+
* @param newName
4345
* @param photo
4446
* @param description
45-
* @param requestBody
46-
* @param newName
4747
* @returns any Successful Response
4848
* @throws ApiError
4949
*/
50-
public static updatePlaylistPlaylistsNamePut(
50+
public static updatePlaylistMetadataPlaylistsNamePut(
5151
name: string,
52-
photo: string,
53-
description: string,
54-
requestBody: Array<string>,
5552
newName?: (string | null),
53+
photo?: (string | null),
54+
description?: (string | null),
5655
): CancelablePromise<any> {
5756
return __request(OpenAPI, {
5857
method: 'PUT',
@@ -61,12 +60,10 @@ export class PlaylistsService {
6160
'name': name,
6261
},
6362
query: {
63+
'new_name': newName,
6464
'photo': photo,
6565
'description': description,
66-
'new_name': newName,
6766
},
68-
body: requestBody,
69-
mediaType: 'application/json',
7067
errors: {
7168
422: `Validation Error`,
7269
},

0 commit comments

Comments
 (0)