Skip to content

Fix long press menu not showing when start a thread #5817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.util.Date
import io.getstream.chat.android.ui.common.state.messages.Flag as FlagMessage
Expand Down Expand Up @@ -734,17 +735,19 @@ public class MessageListController(
) {
threadJob = scope.launch {
user.onEach {
_threadListState.value = _threadListState.value.copy(currentUser = it)
_threadListState.update { state -> state.copy(currentUser = it) }
}.launchIn(this)

endOfOlderMessages.onEach {
_threadListState.value = _threadListState.value.copy(
endOfOldMessagesReached = it,
isLoadingOlderMessages = when {
it -> false
else -> _threadListState.value.isLoadingOlderMessages
},
)
_threadListState.update { state ->
state.copy(
endOfOldMessagesReached = it,
isLoadingOlderMessages = when {
it -> false
else -> state.isLoadingOlderMessages
},
)
}
}.launchIn(this)

combine(
Expand Down Expand Up @@ -1190,13 +1193,13 @@ public class MessageListController(
return
}

_threadListState.value = _threadListState.value.copy(isLoadingOlderMessages = true)
_threadListState.update { state -> state.copy(isLoadingOlderMessages = true) }
chatClient.getRepliesMore(
messageId = threadMode.parentMessage.id,
firstId = threadMode.threadState.oldestInThread.value?.id ?: threadMode.parentMessage.id,
limit = messageLimit,
).enqueue {
_threadListState.value = _threadListState.value.copy(isLoadingOlderMessages = false)
_threadListState.update { state -> state.copy(isLoadingOlderMessages = false) }
}
}

Expand Down Expand Up @@ -1293,7 +1296,7 @@ public class MessageListController(
*/
public fun enterNormalMode() {
_mode.value = MessageMode.Normal
_threadListState.value = MessageListState()
_threadListState.update { MessageListState() }
lastLoadedThreadMessage = null
threadJob?.cancel()
}
Expand Down Expand Up @@ -1505,7 +1508,7 @@ public class MessageListController(
*/
private fun changeSelectMessageState(selectedMessageState: SelectedMessageState?) {
if (isInThread) {
_threadListState.value = _threadListState.value.copy(selectedMessageState = selectedMessageState)
_threadListState.update { state -> state.copy(selectedMessageState = selectedMessageState) }
} else {
setMessageListState(_messageListState.value.copy(selectedMessageState = selectedMessageState))
}
Expand Down Expand Up @@ -1601,7 +1604,7 @@ public class MessageListController(
*/
public fun removeOverlay() {
logger.v { "[removeOverlay] no args" }
_threadListState.value = _threadListState.value.copy(selectedMessageState = null)
_threadListState.update { state -> state.copy(selectedMessageState = null) }
setMessageListState(_messageListState.value.copy(selectedMessageState = null))
}

Expand Down Expand Up @@ -2008,7 +2011,7 @@ public class MessageListController(
public fun clearNewMessageState() {
logger.d { "[clearNewMessageState] no args" }
if (!messagesState.endOfNewMessagesReached) return
_threadListState.value = _threadListState.value.copy(newMessageState = null, unreadCount = 0)
_threadListState.update { state -> state.copy(newMessageState = null, unreadCount = 0) }
setMessageListState(_messageListState.value.copy(newMessageState = null, unreadCount = 0))
}

Expand Down
Loading