Skip to content

Commit

Permalink
(sample-app) spotless, api dump
Browse files Browse the repository at this point in the history
  • Loading branch information
kanat authored and JcMinarro committed Mar 1, 2024
1 parent fe783b6 commit d205b7f
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ sealed class ChatInfoItem {
get() = isHidden
}


sealed class Stateful : Option() {
abstract val isChecked: Boolean

Expand All @@ -140,4 +139,4 @@ sealed class ChatInfoItem {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
Expand Down Expand Up @@ -213,22 +213,26 @@ class GroupChatInfoFragment : Fragment() {

private fun subscribeForChannelVisibilityEvents() {
ChatClient.instance().subscribeFor<ChannelHiddenEvent>(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<ChannelVisibleEvent>(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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -204,7 +208,9 @@ class GroupChatInfoViewModel(
data class ChannelMutesUpdated(val channelMutes: List<ChannelMute>) : 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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-2024 Stream.io Inc. All rights reserved.
Licensed under the Stream License;
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-2024 Stream.io Inc. All rights reserved.
Licensed under the Stream License;
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="960" android:viewportWidth="960"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2014-2024 Stream.io Inc. All rights reserved.
Licensed under the Stream License;
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
Expand Down

0 comments on commit d205b7f

Please sign in to comment.