Skip to content

Commit

Permalink
fix: remove superfluous ignoreEndTill check
Browse files Browse the repository at this point in the history
  • Loading branch information
iyzana committed Feb 20, 2023
1 parent c2e90cb commit 8702ce3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/kotlin/de/randomerror/ytsync/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class Room(
var shutdownThread: Thread? = null,
var timeoutSyncAt: Instant? = null,
var ignorePauseTill: Instant? = null,
var ignoreEndTill: Instant? = null
var ignoreSkipTill: Instant? = null
) {
fun getUser(session: Session) = participants.find { it.session == session }!!

Expand Down
7 changes: 3 additions & 4 deletions backend/src/main/kotlin/de/randomerror/ytsync/Queue.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.randomerror.ytsync

import mu.KotlinLogging
import org.eclipse.jetty.websocket.api.Session
import java.time.Instant
import java.util.concurrent.ExecutorService
Expand Down Expand Up @@ -86,12 +85,12 @@ fun skip(session: Session): String {
return "skip deny"
}

val ignoreEndTill = room.ignoreEndTill
if (ignoreEndTill != null && ignoreEndTill.isAfter(Instant.now())) {
val ignoreSkipTill = room.ignoreSkipTill
if (ignoreSkipTill != null && ignoreSkipTill.isAfter(Instant.now())) {
return "skip ignore"
}
room.ignoreSkipTill = Instant.now().plusSeconds(2)

room.ignoreEndTill = Instant.now().plusSeconds(2)
playNext(session, room)
}

Expand Down
7 changes: 1 addition & 6 deletions backend/src/main/kotlin/de/randomerror/ytsync/Sync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,10 @@ fun setEnded(session: Session, queueId: String): String {
val room = getRoom(session)

synchronized(room.queue) {
val ignoreEndTill = room.ignoreEndTill
if (ignoreEndTill != null && ignoreEndTill.isAfter(Instant.now())) {
return "end ignore"
}

if (room.queue.isEmpty()) return "end empty"
if (room.queue[0].url != queueId) return "end old"

room.ignoreEndTill = Instant.now().plusSeconds(IGNORE_DURATION)
room.ignoreSkipTill = Instant.now().plusSeconds(IGNORE_DURATION)
playNext(session, room)
}

Expand Down

0 comments on commit 8702ce3

Please sign in to comment.