Skip to content

Conversation

@laevandus
Copy link
Contributor

🔗 Issue Links

Fixes: IOS-1252

🎯 Goal

Activity batch operations did not update state-layer state

📝 Summary

  • Add activityBatchUpdate for batch operations which also update state layer state with one go

🛠 Implementation

Local events are good for state layer because these contain full data where as web-socket events lack own fields.

🎨 Showcase

🧪 Manual Testing Notes

☑️ 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

@laevandus laevandus requested a review from a team as a code owner November 13, 2025 14:27
@laevandus laevandus added the ✅ Feature An issue or PR related to a feature label Nov 13, 2025
public func addActivity(request: AddActivityRequest) async throws -> ActivityData {
let activityData = try await activitiesRepository.addActivity(request: request)
for feed in request.feeds.map(FeedId.init) {
await stateLayerEventPublisher.sendEvent(.activityAdded(activityData, feed))
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 need to do this? Shouldn't this come from the WS event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same pattern is everywhere else as well. It is good because state is updated before this function returns.
I can write code where:

let feed = client.feed(for: )
try await client.addActivity(… )
let activities = feed.state.activities  // this already contains added activities, WS event has not received

Secondly WS events do not have own_ fields set, so using HTTP response data we get the most up to date data for all the own fields as well.

# Conflicts:
#	CHANGELOG.md
#	Tests/StreamFeedsTests/StateLayer/ActivityList_Tests.swift
#	Tests/StreamFeedsTests/TestTools/ActivityResponse+Testing.swift
@laevandus laevandus enabled auto-merge (squash) November 14, 2025 12:52
@github-actions
Copy link

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@github-actions
Copy link

Public Interface

 public struct ModelUpdates: Sendable  
-   public let added: [Model]
+   public internal var added: [Model]
-   public let removedIds: [String]
+   public internal var removedIds: Set<String>
-   public let updated: [Model]
+   public internal var updated: [Model]

 public final class FeedsClient: Sendable  
-   @discardableResult public func addActivity(request: AddActivityRequest)async throws -> AddActivityResponse
+   @discardableResult public func addActivity(request: AddActivityRequest)async throws -> ActivityData
-   @discardableResult public func deleteActivities(request: DeleteActivitiesRequest)async throws -> DeleteActivitiesResponse
+   @discardableResult public func deleteActivities(request: DeleteActivitiesRequest)async throws -> Set<String>

@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamFeeds 7.13 MB 7.15 MB +16 KB 🟢

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
25.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@laevandus laevandus merged commit 2aadc83 into develop Nov 14, 2025
5 of 6 checks passed
@laevandus laevandus deleted the activity-batch-update-event branch November 14, 2025 12:59
@Stream-SDK-Bot
Copy link
Collaborator

StreamFeeds XCSize

Object Diff (bytes)
ActivityListState.o +19372
FeedsClient.o +16634
FeedListState.o -15732
ActivityMarkData.o -11678
FeedState.o +7664
Show 9 more objects
Object Diff (bytes)
ActivityState.o +2288
FeedsRepository.o -1292
MemberListState.o -600
OwnCapabilitiesStateLayerEventMiddleware.o +574
ActivityCommentListState.o +464
PollListState.o +364
StateLayerEvent.o +342
Array+Extensions.o +260
OwnCapabilitiesRepository.o +124

@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Nov 19, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants