diff --git a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/ChatInfoItem.kt b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/ChatInfoItem.kt index 851c56801f5..681e61557d8 100644 --- a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/ChatInfoItem.kt +++ b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/ChatInfoItem.kt @@ -114,7 +114,6 @@ sealed class ChatInfoItem { get() = isHidden } - sealed class Stateful : Option() { abstract val isChecked: Boolean @@ -140,4 +139,4 @@ sealed class ChatInfoItem { } } } -} \ No newline at end of file +} diff --git a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoFragment.kt b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoFragment.kt index 22e5c7f1b26..5f575dc34ae 100644 --- a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoFragment.kt +++ b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoFragment.kt @@ -168,7 +168,7 @@ class GroupChatInfoFragment : Fragment() { when (option) { is ChatInfoItem.Option.Stateful.MuteChannel -> viewModel.onAction( - GroupChatInfoViewModel.Action.MuteChannelClicked(isChecked) + GroupChatInfoViewModel.Action.MuteChannelClicked(isChecked), ) else -> throw IllegalStateException("Chat info option $option is not supported!") } @@ -213,22 +213,26 @@ class GroupChatInfoFragment : Fragment() { private fun subscribeForChannelVisibilityEvents() { ChatClient.instance().subscribeFor(viewLifecycleOwner) { - viewModel.onAction(GroupChatInfoViewModel.Action.ChannelHiddenUpdated( - cid = it.cid, - hidden = true, - clearHistory = it.clearHistory - )) + viewModel.onAction( + GroupChatInfoViewModel.Action.ChannelHiddenUpdated( + cid = it.cid, + hidden = true, + clearHistory = it.clearHistory, + ), + ) } ChatClient.instance().subscribeFor(viewLifecycleOwner) { - viewModel.onAction(GroupChatInfoViewModel.Action.ChannelHiddenUpdated( - cid = it.cid, - hidden = false - )) + viewModel.onAction( + GroupChatInfoViewModel.Action.ChannelHiddenUpdated( + cid = it.cid, + hidden = false, + ), + ) } } private fun prepareHideChannelClickedAction( - onReady: (GroupChatInfoViewModel.Action.HideChannelClicked) -> Unit + onReady: (GroupChatInfoViewModel.Action.HideChannelClicked) -> Unit, ) { val curValue = viewModel.state.value!!.channelHidden val newValue = curValue.not() diff --git a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoViewModel.kt b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoViewModel.kt index d2ad4a2641a..1b393157b8d 100644 --- a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoViewModel.kt +++ b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/chat/info/group/GroupChatInfoViewModel.kt @@ -80,8 +80,12 @@ class GroupChatInfoViewModel( ) } - // TODO we use take(1), cause ChannelState.hidden seems to be not updated properly - _state.addSource(channelState.flatMapLatest { it.hidden }.distinctUntilChanged().take(1).asLiveData()) { hidden -> + _state.addSource( + channelState.flatMapLatest { it.hidden } + .distinctUntilChanged() + .take(1) // TODO we use take(1), cause ChannelState.hidden seems to be not updated properly + .asLiveData() + ) { hidden -> logger.v { "[onHiddenChanged] hidden: $hidden" } _state.value = _state.value?.copy( channelHidden = hidden, @@ -204,7 +208,9 @@ class GroupChatInfoViewModel( data class ChannelMutesUpdated(val channelMutes: List) : Action() data class ChannelHiddenUpdated( - val cid: String, val hidden: Boolean, val clearHistory: Boolean? = null + val cid: String, + val hidden: Boolean, + val clearHistory: Boolean? = null, ) : Action() data object LeaveChannelClicked : Action() } diff --git a/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide.xml b/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide.xml index 290d0a180f8..2752922238e 100644 --- a/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide.xml +++ b/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide.xml @@ -1,3 +1,19 @@ + + diff --git a/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide_3.xml b/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide_3.xml index c65684a023e..283f7dee30c 100644 --- a/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide_3.xml +++ b/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_hide_3.xml @@ -1,3 +1,19 @@ + + diff --git a/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_show.xml b/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_show.xml index 9b10da78344..c48dc44ef62 100644 --- a/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_show.xml +++ b/stream-chat-android-ui-components-sample/src/main/res/drawable/ic_show.xml @@ -1,3 +1,19 @@ + +