Skip to content

Conversation

@JcMinarro
Copy link
Contributor

🎯 Goal

Set updated user whenever a new message is sent
Close: https://github.com/GetStream/android-internal-board/issues/67

🧪 Testing

Applying the patch below, whenever you click on "sign out" the user name is updated.
Update the name and go into a channel. Send a message and your messages shouldn't do any flickering

Provide the patch summary here
Index: stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/message/list/adapter/viewholder/decorator/internal/FootnoteDecorator.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/message/list/adapter/viewholder/decorator/internal/FootnoteDecorator.kt b/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/message/list/adapter/viewholder/decorator/internal/FootnoteDecorator.kt
--- a/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/message/list/adapter/viewholder/decorator/internal/FootnoteDecorator.kt	(revision fbf472cc9d2d2997ec2042d51a3ad78e5c0880cb)
+++ b/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/message/list/adapter/viewholder/decorator/internal/FootnoteDecorator.kt	(date 1684148485809)
@@ -284,6 +284,8 @@
                 textView.isVisible = false
             }
         }
+        textView.text = data.message.user.name
+        textView.isVisible = true
     }
 
     /**
Index: stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/home/HomeViewModel.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/home/HomeViewModel.kt b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/home/HomeViewModel.kt
--- a/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/home/HomeViewModel.kt	(revision fbf472cc9d2d2997ec2042d51a3ad78e5c0880cb)
+++ b/stream-chat-android-ui-components-sample/src/main/kotlin/io/getstream/chat/ui/sample/feature/home/HomeViewModel.kt	(date 1684148485809)
@@ -92,9 +92,13 @@
         when (action) {
             is UiAction.LogoutClicked -> {
                 viewModelScope.launch {
-                    chatClient.disconnect(false).await()
-                    App.instance.userRepository.clearUser()
-                    _events.value = Event(UiEvent.NavigateToLoginScreenLogout)
+                    // chatClient.disconnect(false).await()
+                    // App.instance.userRepository.clearUser()
+                    // _events.value = Event(UiEvent.NavigateToLoginScreenLogout)
+                    chatClient.getCurrentUser()?.let { currentUser ->
+                        chatClient.partialUpdateUser(currentUser.id, mapOf("name" to "${currentUser.name}0"))
+                            .await()
+                    }
                 }
             }
 

🎉 GIF

@JcMinarro JcMinarro requested a review from a team as a code owner May 15, 2023 11:18
@JcMinarro JcMinarro requested a review from kanat May 15, 2023 11:18
Copy link
Contributor

@kanat kanat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kanat kanat merged commit b85920b into v5 May 15, 2023
@kanat kanat deleted the fix-send-message-current-user branch May 15, 2023 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants