-
Notifications
You must be signed in to change notification settings - Fork 204
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
[Reactions v2] New reactions query endpoint #3167
Merged
martinmitrevski
merged 13 commits into
develop
from
add/new-reactions-v2-query-endpoint
Apr 30, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cb002b6
Add `ReactionListQuery`
nuno-vieira 656ada4
Add new Reactions Query Endpoint
nuno-vieira 3ba022e
Add ReactionListUpdater
nuno-vieira f0878dc
Add Reaction List Controller
nuno-vieira 83ec4ff
Add new Slack Reaction List View when long pressing reactions to test…
nuno-vieira 66073b1
Add SwiftUI and Combine Helpers
nuno-vieira 45e4bfa
Fix message list slack reactions view
nuno-vieira 7a21f3e
Fix LLC Tests compilation
nuno-vieira 87080d1
Fix UI Tests compilation
nuno-vieira 9c250d1
Update CHANGELOG.md
nuno-vieira 45ddf43
Fix test_removingAllData()
nuno-vieira f70c913
Fixed the reaction list query not considering the message id
martinmitrevski 645e90f
Added docs
martinmitrevski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Sources/StreamChat/APIClient/Endpoints/ReactionEndpoints.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Endpoint { | ||
static func loadReactions(messageId: MessageId, pagination: Pagination) -> Endpoint<MessageReactionsPayload> { | ||
.init( | ||
path: .reactions(messageId), | ||
method: .get, | ||
queryItems: nil, | ||
requiresConnectionId: false, | ||
body: pagination | ||
) | ||
} | ||
|
||
static func loadReactionsV2(query: ReactionListQuery) -> Endpoint<MessageReactionsPayload> { | ||
.init( | ||
path: .reactions(query.messageId), | ||
method: .post, | ||
queryItems: nil, | ||
requiresConnectionId: false, | ||
body: query | ||
) | ||
} | ||
|
||
static func addReaction( | ||
_ type: MessageReactionType, | ||
score: Int, | ||
enforceUnique: Bool, | ||
extraData: [String: RawJSON], | ||
messageId: MessageId | ||
) -> Endpoint<EmptyResponse> { | ||
let body = MessageReactionRequestPayload( | ||
enforceUnique: enforceUnique, | ||
reaction: ReactionRequestPayload( | ||
type: type, | ||
score: score, | ||
extraData: extraData | ||
) | ||
) | ||
return .init( | ||
path: .addReaction(messageId), | ||
method: .post, | ||
queryItems: nil, | ||
requiresConnectionId: false, | ||
body: body | ||
) | ||
} | ||
|
||
static func deleteReaction(_ type: MessageReactionType, messageId: MessageId) -> Endpoint<EmptyResponse> { | ||
.init( | ||
path: .deleteReaction(messageId, type), | ||
method: .delete, | ||
queryItems: nil, | ||
requiresConnectionId: false, | ||
body: nil | ||
) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ces/StreamChat/Controllers/ReactionListController/ChatClient+ReactionListController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension ChatClient { | ||
/// Creates a new `ChatReactionListController` with the provided reaction list query. | ||
/// | ||
/// - Parameter query: The query to specify which reactions should be fetch from the message. | ||
/// - Returns: A new instance of `ChatReactionListController`. | ||
public func reactionListController(query: ReactionListQuery) -> ChatReactionListController { | ||
.init(query: query, client: self) | ||
} | ||
|
||
/// Creates a new `ChatReactionListController` with the default query. | ||
/// It loads all reactions from the message. | ||
/// | ||
/// - Parameter messageId: The message id of the reactions to fetch. | ||
/// - Returns: A new instance of `ChatReactionListController`. | ||
public func reactionListController(for messageId: MessageId) -> ChatReactionListController { | ||
.init( | ||
query: ReactionListQuery( | ||
messageId: messageId, | ||
pagination: .init(pageSize: 25, offset: 0) | ||
), | ||
client: self | ||
) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It is a sample app, but just wondering why it was not using
dequeueReusableCell(withIdentifier:for:)
. Not that it makes a huge difference here. I guess because there are only a couple of cells so it does not matter. Just thinking out aloud, feel free to ignore.