Engage with shared bets through threaded comments and reactions.
Use CentralHubCommentingProvider to load comments for a bet share, add new replies, and mark replies as read.
class CommentingViewModel : ViewModel(), KoinComponent {
private val commentingProvider: CentralHubCommentingProvider = get()
val commentingState = commentingProvider.state
suspend fun loadComments(betShare: BetShare) {
commentingProvider.loadData(betShare)
}
suspend
CentralHubReactionsManager toggles reactions on bet shares and comments.
Use the reaction event stream to update your UI when reaction counts or user reaction state change.
data class CommentingState(
val betShare: BetShare?,
val loadingStatus: LoadingStatus,
val nextPageLoadingStatus: LoadingStatus,
val allDataLoaded: Boolean,
)class ReactionsViewModel : ViewModel(), KoinComponent {
private val reactionsManager: CentralHubReactionsManager = get()
val reactionEvents = reactionsManager.reactionEvents
suspend fun toggleReaction(
betShare: BetShare,
reactionType: ReactionType,
) {
reactionsManager.toggleReactionBetShare(
betShare = betShare,
reactionType = reactionType,
onSuccess = { /* Reaction toggled */ },
onFailure = { error -> /* Handle error */ },
)
}
suspend fun reactToComment(
reply: MessageReply,
reactionType: ReactionType,
) {
reactionsManager.toggleReactionComment(
reply = reply,
reactionType = reactionType,
onSuccess = { /* Reaction toggled */ },
onFailure = { error -> /* Handle error */ },
)
}
}