-
Notifications
You must be signed in to change notification settings - Fork 210
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
Pinning channels for the current user #3518
Conversation
Generated by 🚫 Danger |
SDK Size
|
SDK Performance
|
SDK Size
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me ✅ Can you also do this in the SwiftUI app? Most of the stuff is already in place.
Quality Gate passedIssues Measures |
@@ -11,7 +11,7 @@ final class DemoChatChannelListItemView: ChatChannelListItemView { | |||
if content?.searchResult?.message != nil { | |||
return super.contentBackgroundColor | |||
} | |||
if AppConfig.shared.demoAppConfig.isChannelPinningEnabled && content?.channel.isPinned == true { | |||
if content?.channel.isPinned == true { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope (but not intended 😄 ) but in the future if we have global pinning, we might need to have more than 1 property to distinguish isPinned
from local only or global only 🤔
public enum ChannelPinningScope: String { | ||
/// Channel is pinned only for the currently connected user. Other channel members do not see channels as pinned. | ||
case me | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this not meant to be used by the customer to perform switching it should be fine. But in theory, adding a new case would be a breaking change. But I guess it is fine in this case 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! ✅
🔗 Issue Links
Part of IOS-553
🎯 Goal
Add a new feature enabling users to pin channels (pinned status is tied to the user, not a global action)
📝 Summary
Chat.pin(scope:)
andChat.unpin(scope:)
ChatChannelController.pin(scope:completion:)
andChatChannelController.unpin(scope:completion:)
ChannelPinningScope
with only one supported option ofme
(pinning the channel for everyone is not supported)FilterKey.pinned
for filtering channel listsChannelListSortingKey.pinnedAt
ChatChannel.membership.pinnedAt
ChatChannel.isPinned
pinned_at
in member payloadspinned: true
using the newMemberUpdatePayload
type or unsettingpinned
🛠 Implementation
Pinning and unpinning works by calling partial update on the chat channel member (current user) and setting either
pinned: true
or unsetting this. Therefore, one could also useChatChannelMemberController.partialUpdate(extraData:unsetProperties:completion:)
where the user if is the current user id and extra data is["pinned": .boolean(true)]
or unsetProperties is set to["pinned"]
. New high-level pin and unpinning methods end up calling the same member updater's code, just make it more natural and discoverable.Note: Pinning is per user. Meaning that if user A pins a channel with user B, then user B does not get the pinned state.
🧪 Manual Testing Notes
Pin and unpin channel
Result: Pinned channel gets a yellow background (demo app has a custom message cell)
Result: yellow background is removed
Querying pinned channels
Result: Only pinned channels are displayed
Result: channel list removes the unpinned channel
Sorting
Change the demo app: DemoAppCoordinator+DemoApp.swift:L98 to
☑️ Contributor Checklist