small optimization of panelApi.forceRefresh in onPollUpdates

This commit is contained in:
2026-03-12 17:39:47 +06:00
parent 815391d3f6
commit 53cc851944

View File

@@ -122,13 +122,22 @@ object Plugin : Plugin {
val panelApi = koin.getOrNull<PanelButtonsAPI>()
val chatConfig = koin.get<ChatConfig>()
val panelApiOnPollUpdatesUpdateTrigger: suspend (PostId) -> Unit = if (config.panelButtonText.contains(currentRatingControlSymbol)) {
{
panelApi ?.forceRefresh(it)
}
} else {
{
}
}
onPollUpdates (markerFactory = { it.id }) { poll ->
val postId = pollsToPostsIdsRepo.get(poll.id) ?: return@onPollUpdates
val newRating = poll.options.sumOf {
(variantsTransformer(it.textSources.makeSourceString()) ?.double ?.times(it.votes)) ?: 0.0
}
ratingsRepo.set(postId, Rating(newRating))
panelApi ?.forceRefresh(postId)
panelApiOnPollUpdatesUpdateTrigger(postId)
}
suspend fun attachPoll(postId: PostId): Boolean {