This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun setReactions( | |
message: AmityMessage, | |
isLiked: Boolean | |
) { | |
if (isLiked) { | |
message.react().addReaction(CommunityReactions.LIKE.reactionName).subscribe() | |
} else { | |
message.react().removeReaction(CommunityReactions.LIKE.reactionName).subscribe() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChannelDetailViewModel : BaseViewModel() { | |
private var _messagesUiState = MutableStateFlow<ChatsUiState>(ChatsUiState.Loading) | |
var messagesUiState: StateFlow<ChatsUiState> = _messagesUiState | |
fun getChannelMessages(subChannelId: String) { | |
messagesUiState = | |
AmityChatClient.newMessageRepository().getMessages(subChannelId).includeDeleted(false) | |
.build().query() | |
.asFlow().cachedIn(viewModelScope) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Sport { HIKE, RUN, TOURING_BICYCLE, E_TOURING_BICYCLE } | |
data class Summary(val sport: Sport, val distance: Int) | |
fun main() { | |
val sportStats = listOf( | |
Summary(Sport.HIKE, 92), | |
Summary(Sport.RUN, 77), | |
Summary(Sport.TOURING_BICYCLE, 322), | |
Summary(Sport.E_TOURING_BICYCLE, 656) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val group = listOf('a', 'b', 'c', 'd', 'e','f','g','h','i') | |
fun main() { | |
val potentialCards = getPotentialCards(4, group) | |
println(potentialCards) | |
println(potentialCards.size) | |
val builtCards = selectCards(potentialCards) | |
println(builtCards) | |
println(builtCards.size) |