Skip to content
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

[AND-190] Add "Unblock user" as message option in the UI SDKs. #5533

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

VelikovPetar
Copy link
Contributor

@VelikovPetar VelikovPetar commented Dec 23, 2024

🎯 Goal

Linear: https://linear.app/stream/issue/AND-190/implement-unblock-user-message-menu-option
Implements the "Unblock user" message option, which would be shown in the default message menu instead of the "Block user" option if the user is already blocked.
Additionally we expose two ways of fetching/observing the current user's blocked users:

  • Via the GlobalState (in the StatePlugin)
  • Via ClientState.user (in case the StatePlugin is not applied)

🛠 Implementation details

Client / State

  • Add blockedUserIds field in the User model. Can be read for the currently logged in user.
  • Add blockedUserIds field in the GlobalState. Can be observed from ChatClient.globalState from the StatePlugin.
  • The blockedUserIds field is delivered via HasOwnUser WS events.
  • Add handling for HasOwnUser events in EventHandlerSequential to ensure the data is up-to-date.
  • Add BlockUserListener/UnblockUserListener/QueryBlockedUsersListener as part of the Plugin.
  • Implement BlockUserListenerState/UnblockUserListenerState/QueryBlockedUsersListenerState to ensure the GlobalState.blockedUserIds is up-to-date.
  • Extend the ChatClient blockUser/unblockUser with logic updating the mutableClientState and userStateService. This makes sure that the blockedUserIds data stored in the ChatClient current user is up-to-date. (relevant for customers not using the state plugin)

UI

  • Extend the logic for showing the "Block user" message menu item: It will now toggle between "Block user" and "Unblock user" based on the block status of the sender message.
  • The visibility option for the "Unblock user" is handled together with the "Block user" option.

🎨 UI Changes

Compose Demo
block-unblock-user-demo-compose.mp4

🧪 Testing

  1. Open any of the sample apps (compose/xml)
  2. Open a channel
  3. Long press on a message (not your)
  4. Tap on "Block user" / "Unblock user"
  5. (The user should be blocked/unblocked in the background)
  6. Long press on a message from the same user
  7. The option should now have to changed to the opposite option (unblock/block)

@VelikovPetar VelikovPetar changed the title [AND-190] Add "Unblock user" as message options in the UI SDKs. [AND-190] Add "Unblock user" as message option in the UI SDKs. Dec 23, 2024
@VelikovPetar VelikovPetar marked this pull request as ready for review December 23, 2024 16:24
@VelikovPetar VelikovPetar requested a review from a team as a code owner December 23, 2024 16:24
@JcMinarro JcMinarro merged commit 31c0b6b into develop Dec 24, 2024
9 checks passed
@JcMinarro JcMinarro deleted the feature/unblock-user-ui branch December 24, 2024 00:54
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.

2 participants