suspend fun vote()

in shared/src/commonMain/kotlin/org/jetbrains/kotlinconf/ConferenceService.kt [235:248]


    suspend fun vote(sessionId: SessionId, rating: Score?): Boolean {
        if (!checkUserId()) return false

        val localVotes = storage.getVotes().first().toMutableList()
        val existingIndex = localVotes.indexOfFirst { it.sessionId == sessionId }
        if (existingIndex != -1) {
            localVotes[existingIndex] = VoteInfo(sessionId, rating)
        } else {
            localVotes += VoteInfo(sessionId, rating)
        }
        storage.setVotes(localVotes)

        return client.vote(sessionId, rating)
    }