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

Dismiss thread when hard deleting root message #3569

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Jan 23, 2025

🔗 Issue Links

Resolves https://linear.app/stream/issue/IOS-282/hard-delete-on-a-root-message-from-a-thread-is-broken

🎯 Goal

Fix the Thread not dismissing when the root message is hard deleted.

🛠 Implementation

I've decided to implement this on the Demo App since hard deleting is an action that only exists on the Demo App. Usually, we do not advertise the feature much since it is not recommended.

Besides that, the logic will most likely differ depending on the app. So this is mostly app logic and not SDK logic.

Either way, while doing this, I spotted some bugs:

  • The ChatThreadVC.didReceiveEvent delegate was always being called twice. This was due to the fact that we had channelEventsController and eventsController assigning both delegates to the ChatThreadVC
  • The MessageDeletedEvent was not being surfaced to the didReceiveEvent delegate. This only happened for the hard deleted message, and the reason is that this event requires a message: ChatMessage property. But, since the mesasge is hard deleted, it also does not exist in CoreData, so we can't provide the whole message, only the ID. For this reason, I created a new event MessageHardDeletedEvent and deprecated the MessageDeletedEvent.isHardDeleted property. This was the only option to avoid breaking changes.

UPDATE: In order to avoid creating a new MessageHardDeletedEvent, and diverge from the other SDKs, we decided to map the message payload directly to the model so that the MessageDeletedEvent.message is present.

🧪 Manual Testing Notes

Dismissing Thread

  1. Create / Open a Thread
  2. Hard delete the root message inside a thread
  3. Should dismiss the view

Hard Deleting Thread from Channel

  1. Create a Thread
  2. Send a reply also in channel
  3. Go back to the Channel
  4. Hard delete the root thread
  5. Should delete the thread and replies also in channel

☑️ 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
  • Documentation has been updated in the docs-content repo

@nuno-vieira nuno-vieira added the 🪧 Demo App An Issue or PR related to the Demo App label Jan 23, 2025
@nuno-vieira nuno-vieira requested a review from a team as a code owner January 23, 2025 16:30
@nuno-vieira nuno-vieira marked this pull request as draft January 23, 2025 16:55
@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Jan 23, 2025

SDK Size

title develop branch diff status
StreamChat 7.02 MB 7.05 MB +32 KB 🟢
StreamChatUI 4.77 MB 4.77 MB 0 KB 🟢

@nuno-vieira nuno-vieira added 🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK labels Jan 23, 2025
This was caused by setting 2 event delegates, one for channel events and another one for regular events
This was because when hard deleting a message it disappears from CoreData, so we can't create the Event domain model with the message model. So for this I created a different event.
@nuno-vieira nuno-vieira force-pushed the fix/thread-not-dismissing-when-message-hard-deleted branch from ad394cd to 4437e15 Compare January 23, 2025 17:25
@nuno-vieira nuno-vieira force-pushed the fix/thread-not-dismissing-when-message-hard-deleted branch from 23ed5ed to 773b01a Compare January 23, 2025 17:31
@nuno-vieira nuno-vieira marked this pull request as ready for review January 23, 2025 17:57
@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.32 ms per s 67.0% 🔼 🟢
Frame rate 75 fps 78.48 fps 4.64% 🔼 🟢
Number of hitches 1 0.4 60.0% 🔼 🟢

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Jan 24, 2025

SDK Size

title develop branch diff status
StreamChat 7.02 MB 7.02 MB 0 KB 🟢
StreamChatUI 4.77 MB 4.77 MB 0 KB 🟢

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -24,6 +24,7 @@ open class ChatThreadVC: _ViewController,
public var initialReplyId: MessageId?

/// Controller for observing typing events for this thread.
@available(*, deprecated, message: "Events are now handled by the `eventsController`.")
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we deprecate it in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ChatThreadVC.didReceiveEvent delegate was always being called twice. This was due to the fact that we had channelEventsController and eventsController assigning both delegates to the ChatThreadVC

Its in the PR description. Since it is not used anymore, it is deprecated. The delegate of this controller was conflicting with the eventsController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug An issue or PR related to a bug 🪧 Demo App An Issue or PR related to the Demo App 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants