some fix on wsSongListRoutes

- song remove from list(database) logic add
This commit is contained in:
dalbodeule 2024-08-24 15:08:05 +09:00
parent 9f4f8e84aa
commit b87cf8cbfb
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65
2 changed files with 8 additions and 5 deletions

View File

@ -14,7 +14,6 @@ class SongEvent(
val uid: String,
val type: SongType,
val reqUid: String?,
val reqName: String?,
val current: YoutubeVideo? = null,
val next: YoutubeVideo? = null,
val delUrl: String? = null,

View File

@ -140,8 +140,7 @@ fun Routing.wsSongListRoutes() {
user.token!!,
SongType.ADD,
user.token,
user.username,
null,
CurrentSong.getSong(user),
youtubeVideo
)
)
@ -151,6 +150,13 @@ fun Routing.wsSongListRoutes() {
logger.debug("SongType.ADD Error: $uid $e")
}
} else if (data.type == SongType.REMOVE.value && data.url != null) {
val songs = SongListService.getSong(user)
val exactSong = songs.firstOrNull { it.url == data.url }
if (exactSong != null) {
SongListService.deleteSong(user, exactSong.uid, exactSong.name)
}
dispatcher.post(
SongEvent(
user.token!!,
@ -158,7 +164,6 @@ fun Routing.wsSongListRoutes() {
null,
null,
null,
null,
data.url
)
)
@ -185,7 +190,6 @@ fun Routing.wsSongListRoutes() {
user.token!!,
SongType.NEXT,
song?.uid,
song?.reqName,
youtubeVideo
)
)