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

Archiving channels for the current user #3524

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Dec 4, 2024

🔗 Issue Links

Part of IOS-553

🎯 Goal

Add a new feature enabling users to archive channels (archived status is tied to the user, not a global action)

📝 Summary

  • Public API changes:
    • Add Chat.archive(scope:) and Chat.unarchive(scope:)
    • Add ChatChannelController.archive(scope:completion:) and ChatChannelController.unarchive(scope:completion:)
    • Add ChannelArchivingScope with only one supported option of me (archiving the channel for everyone is not supported)
    • Add FilterKey.archived for filtering channel lists
    • Add ChatChannel.membership.archivedAt
    • Add ChatChannel.isArchived
  • Parse archived_at in member payloads
  • Add supporting code for calling member's partial update with archive: true with the MemberUpdatePayload type or unsetting archived
  • Demo app: added channel list filter for archived channels and archive and unarchive debug actions.

🛠 Implementation

Archiving and unarchiving works by calling partial update on the chat channel member (current user) and setting either archived: true or unsetting it. Therefore, one could also use ChatChannelMemberController.partialUpdate(extraData:unsetProperties:completion:) where the user if is the current user id and extra data is ["archived": .boolean(true)] or unsetProperties is set to ["archived"]. New high-level archive and unarchive methods end up calling the same member updater's code, just make it more natural and discoverable.

Note: Archiving is per user. Meaning that if user A archives an channel with user B, then user B does not see it archived.

🧪 Manual Testing Notes

Archiving and unarchiving

  1. Open the channel list
  2. Archive a channel (debug menu > Archive channel)
    Result: Nothing happens because default channel list includes archived channels
  3. Open "Filter channels" menu in the toolbar > Archived channels
    Result: archived channel is shown
  4. Unarchive the channel
    Result: channel list is empty

Filtering archived channels

Open DemoAppCoordinator+DemoApp.swift:L98 and change the initial channels query to:

            channelListQuery = .init(
                filter: .and([
                    .containMembers(userIds: [userCredentials.id]),
                    .equal(.archived, to: false)
                ])
            )
  1. Open the channel list
  2. Archive a channel (debug menu > Archive channel)
    Result: Channel is removed because we filter out archived channels
  3. Open "Filter channels" menu in the toolbar > Archived channels
    Result: Archived channel is shown
  4. Unarchive the channel
    Result: Channel list is empty
  5. Open "Filter channels" menu in the toolbar > Initial channels
  6. The unarchived channel is part of the channel list

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (docusaurus, tutorial, CMS)

@laevandus laevandus added 🔧 WIP A PR that is Work in Progress 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK ✅ Feature An issue or PR related to a feature labels Dec 4, 2024
@laevandus laevandus requested a review from a team as a code owner December 4, 2024 11:33
@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamChat 6.98 MB 7.0 MB +17 KB 🟢
StreamChatUI 4.77 MB 4.77 MB 0 KB 🟢

@Stream-SDK-Bot
Copy link
Collaborator

SDK Performance

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 3.34 ms 66.6% 🔼 🟢
Duration 2.6 s 2.55 s 1.92% 🔼 🟢
Hitch time ratio 4 ms per s 1.31 ms per s 67.25% 🔼 🟢
Frame rate 75 fps 78.52 fps 4.69% 🔼 🟢
Number of hitches 1 0.4 60.0% 🔼 🟢

Copy link

github-actions bot commented Dec 4, 2024

2 Warnings
⚠️ Big PR
⚠️ The changes should be manually QAed before the Pull Request will be merged

Generated by 🚫 Danger

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Dec 5, 2024

SDK Size

title develop branch diff status
StreamChat 7.0 MB 7.03 MB +33 KB 🟢
StreamChatUI 4.77 MB 4.77 MB 0 KB 🟢

@laevandus laevandus changed the title [WIP] Channel archiving [WIP] Archiving channels for the current user Dec 5, 2024
@laevandus laevandus added the 🤞 Ready For QA A PR that is Ready for QA label Dec 5, 2024
Base automatically changed from feature/channel-pinning to develop December 5, 2024 13:20
@laevandus laevandus force-pushed the feature/channel-archiving branch from 39a7ad7 to 3fdd3e9 Compare December 5, 2024 13:35
@laevandus laevandus changed the title [WIP] Archiving channels for the current user Archiving channels for the current user Dec 5, 2024
@laevandus laevandus removed the 🔧 WIP A PR that is Work in Progress label Dec 5, 2024
@laevandus laevandus force-pushed the feature/channel-archiving branch from 3fdd3e9 to c1be0da Compare December 6, 2024 07:18
@laevandus laevandus force-pushed the feature/channel-archiving branch from c1be0da to c55f8c7 Compare December 6, 2024 07:36
Copy link
Member

@nuno-vieira nuno-vieira left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

LGTM ✅ Same comment about adding it to SwiftUI

Copy link

sonarcloud bot commented Dec 6, 2024

@testableapple testableapple added 🟢 QAed A PR that was QAed and removed 🤞 Ready For QA A PR that is Ready for QA labels Dec 6, 2024
@testableapple testableapple merged commit 40ac335 into develop Dec 6, 2024
14 checks passed
@testableapple testableapple deleted the feature/channel-archiving branch December 6, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Feature An issue or PR related to a feature 🟢 QAed A PR that was QAed 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants