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

Add message pagination #23

Merged
merged 3 commits into from
May 1, 2023
Merged

Add message pagination #23

merged 3 commits into from
May 1, 2023

Conversation

nplasterer
Copy link
Contributor

Closes #6
Adds the ability to paginate the message list.

@nplasterer nplasterer requested a review from a team as a code owner April 28, 2023 16:06
@nplasterer nplasterer self-assigned this Apr 28, 2023
Copy link
Contributor

@michaelx11 michaelx11 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +151 to +162
AsyncFunction("loadMessages") { (conversationTopic: String, conversationID: String?, limit: Int?, before: Double?, after: Double?) -> [String] in
guard let client else {
throw Error.noClient
}

guard let conversation = try await findConversation(topic: conversationTopic, conversationID: conversationID) else {
throw Error.conversationNotFound("no conversation found for \(conversationTopic)")
}
let beforeDate = before != nil ? Date(timeIntervalSince1970: before!) : nil
let afterDate = after != nil ? Date(timeIntervalSince1970: after!) : nil

return try await conversation.messages(after: Date.init(timeIntervalSince1970: 0)).map { try DecodedMessageWrapper.encode($0) }
return try await conversation.messages(limit: limit, before: beforeDate, after: afterDate).map { try DecodedMessageWrapper.encode($0) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if I did this swift thing right so going to wait till @nakajima comes back to review.

Copy link
Contributor

@nakajima nakajima left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@nplasterer nplasterer merged commit 5cfbc67 into main May 1, 2023
@nplasterer nplasterer deleted the np/add-message-pagination branch May 1, 2023 15:33
@github-actions
Copy link
Contributor

🎉 This PR is included in version 1.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add message pagination
3 participants