Skip to content

Commit

Permalink
a few more v2 client clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 7, 2024
1 parent fde600e commit 6c63e3a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 371 deletions.
67 changes: 9 additions & 58 deletions Sources/XMTPiOS/Conversations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,6 @@ final class ConversationStreamCallback: FfiConversationCallback {
}
}

final class V2SubscriptionCallback: FfiV2SubscriptionCallback {
func onError(error: LibXMTP.GenericError) {
print("Error V2SubscriptionCallback \(error)")
}

let callback: (Envelope) -> Void

init(callback: @escaping (Envelope) -> Void) {
self.callback = callback
}

func onMessage(message: LibXMTP.FfiEnvelope) {
self.callback(message.fromFFI)
}
}

class StreamManager {
var stream: FfiV2Subscription?

func updateStream(with request: FfiV2SubscribeRequest) async throws {
try await stream?.update(req: request)
}

func endStream() async throws {
try await stream?.end()
}

func setStream(_ newStream: FfiV2Subscription?) {
self.stream = newStream
}
}

actor FfiStreamActor {
private var ffiStream: FfiStreamCloser?

Expand Down Expand Up @@ -135,9 +103,6 @@ public actor Conversations {
public func listDms(
createdAfter: Date? = nil, createdBefore: Date? = nil, limit: Int? = nil
) async throws -> [Dm] {
guard let v3Client = client.v3Client else {
return []
}
var options = FfiListConversationsOptions(
createdAfterNs: nil, createdBeforeNs: nil, limit: nil,
consentState: nil)
Expand Down Expand Up @@ -269,7 +234,7 @@ public actor Conversations {
if peerAddress.lowercased() == client.address.lowercased() {
throw ConversationError.memberCannotBeSelf
}
let canMessage = try await self.client.canMessageV3(
let canMessage = try await self.client.canMessage(
address: peerAddress)
if !canMessage {
throw ConversationError.memberNotRegistered([peerAddress])
Expand Down Expand Up @@ -340,29 +305,15 @@ public actor Conversations {
}) != nil {
throw ConversationError.memberCannotBeSelf
}
let erroredAddresses = try await withThrowingTaskGroup(
of: (String?).self
) { group in
for address in addresses {
group.addTask {
if try await self.client.canMessageV3(address: address) {
return nil
} else {
return address
}
}
}
var results: [String] = []
for try await result in group {
if let result {
results.append(result)
}
}
return results
}
if !erroredAddresses.isEmpty {
throw ConversationError.memberNotRegistered(erroredAddresses)
let addressMap = try await self.client.canMessage(addresses: addresses)
let unregisteredAddresses = addressMap
.filter { !$0.value }
.map { $0.key }

if !unregisteredAddresses.isEmpty {
throw ConversationError.memberNotRegistered(unregisteredAddresses)
}

let group = try await ffiConversations.createGroup(
accountAddresses: addresses,
opts: FfiCreateGroupOptions(
Expand Down
12 changes: 0 additions & 12 deletions Sources/XMTPiOS/Frames/FramesConstants.swift

This file was deleted.

166 changes: 0 additions & 166 deletions Sources/XMTPiOS/Frames/FramesTypes.swift

This file was deleted.

38 changes: 0 additions & 38 deletions Sources/XMTPiOS/Frames/OpenFramesProxy.swift

This file was deleted.

Loading

0 comments on commit 6c63e3a

Please sign in to comment.