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 uid: String,
val type: SongType, val type: SongType,
val reqUid: String?, val reqUid: String?,
val reqName: String?,
val current: YoutubeVideo? = null, val current: YoutubeVideo? = null,
val next: YoutubeVideo? = null, val next: YoutubeVideo? = null,
val delUrl: String? = null, val delUrl: String? = null,

View File

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