Skip to content

Conversation

dmitrysimkin
Copy link
Contributor

@dmitrysimkin dmitrysimkin commented Aug 15, 2025

TaskWPB-19515 [iOS] Handle reactions

Issue

Added logic to show live changes in messages reactions

Testing

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-08-18.at.15.55.37.mp4

Copy link
Contributor

github-actions bot commented Aug 15, 2025

Test Results

4 371 tests   4 344 ✅  6m 51s ⏱️
  571 suites     27 💤
    3 files        0 ❌

Results for commit cc83a63.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Nice work. I left a few suggestions.

Comment on lines +29 to +30
senderNameObserverProvider: SenderNameObserverProvider?,
reactionsObserverProvider: ReactionsObserverProvider?
Copy link
Contributor

Choose a reason for hiding this comment

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

question: I'm not sure why these are optional but maybe I'm missing something?

public import Combine

public protocol ReactionsObserverProtocol {
var reactionsPublisher: AnyPublisher<ReactionsModel, Never>? { get }
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Same question here. Why is the result optional?

// also performs mapping of domain model which is just raw string
// to UI model which is Attributed string
package struct AnySenderNameObserverProvider: @unchecked Sendable {
package struct AnyObserverProvider: @unchecked Sendable {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Rename ObserverProviderbecause:

  1. I think the fact that it is type erasing is kind of an implementation detail.
  2. I imagine Any type erasers to be very generic objects but this isn't.

import Foundation
import WireMessagingDomain

class ReactionsViewModel: ObservableObject {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Make final

case exists(ReactionsModel)
}

@Published var state: State
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: This could be @Published var state: ReactionsModel. It saves some boilerplate although if there are going to be more states the current version is certainly better.

return
}

self?.reactionsPublisher = NSManagedObject.publisher(for: message, in: viewContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Return the publisher and set self.reactionsPublisher outside the closure. That way reactionsPublisher can be a let.


final class ReactionsObserver: ReactionsObserverProtocol {

var reactionsPublisher: AnyPublisher<ReactionsModel, Never>?
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I personally really don't like that this is optional as it this optionality then propagates everywhere. How about, if we can't create it because the message doesn't exist (which I guess is a bug), we assign a type erased https://developer.apple.com/documentation/combine/empty publisher. That way we can get rid of the optional.

Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Please update it or close it in case is not relevant anymore.

@github-actions github-actions bot added the stale label Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants