diff --git a/ios/Wrappers/DecodedMessageWrapper.swift b/ios/Wrappers/DecodedMessageWrapper.swift index 4310711a2..23817259b 100644 --- a/ios/Wrappers/DecodedMessageWrapper.swift +++ b/ios/Wrappers/DecodedMessageWrapper.swift @@ -60,9 +60,9 @@ struct ContentJson { } else if let reaction = obj["reaction"] as? [String: Any] { return ContentJson(type: ContentTypeReaction, content: Reaction( reference: reaction["reference"] as? String ?? "", - action: ReactionAction(rawValue: reaction["action"] as? String ?? "") ?? .added, + action: ReactionAction(rawValue: reaction["action"] as? String ?? "") , content: reaction["content"] as? String ?? "", - schema: ReactionSchema(rawValue: reaction["schema"] as? String ?? "") ?? .unicode + schema: ReactionSchema(rawValue: reaction["schema"] as? String ?? "") )) } else if let reply = obj["reply"] as? [String: Any] { guard let nestedContent = reply["content"] as? [String: Any] else { diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 4355a9157..430d8bb75 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -250,11 +250,13 @@ public class XMTPModule: Module { throw Error.conversationNotFound("no conversation found for \(topic)") } + let sortDirection: Int = (direction != nil && direction == "SORT_DIRECTION_ASCENDING") ? 1 : 2 + let decodedMessages = try await conversation.messages( limit: limit, before: beforeDate, after: afterDate, - direction: PagingInfoSortDirection(rawValue: direction ?? "SORT_DIRECTION_DESCENDING") + direction: PagingInfoSortDirection(rawValue: sortDirection) ) return decodedMessages.compactMap { (msg) in @@ -298,7 +300,8 @@ public class XMTPModule: Module { } if let directionStr = jsonObj["direction"] as? String { - direction = PagingInfoSortDirection(rawValue: direction ?? "SORT_DIRECTION_DESCENDING") + let sortDirection: Int = (directionStr == "SORT_DIRECTION_ASCENDING") ? 1 : 2 + direction = PagingInfoSortDirection(rawValue: sortDirection) ?? .descending } let page = Pagination(