Skip to content

Commit

Permalink
a few small tweaks to installation id
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 26, 2024
1 parent 6dbda24 commit 46eb00b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/src/tests/clientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ test('can drop client from memory', async () => {
await anotherClient.dropLocalDatabaseConnection()

await client.reconnectLocalDatabase()
await Client.dropClient(anotherClient.inboxId)
await Client.dropClient(anotherClient.installationId)
try {
await anotherClient.reconnectLocalDatabase()
return false
Expand Down
29 changes: 20 additions & 9 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,25 @@ public class XMTPModule: Module {
}
}
}

enum Error: Swift.Error {
enum Error: Swift.Error, LocalizedError {
case noClient
case conversationNotFound(String)
case noMessage, invalidKeyBundle, invalidDigest
case badPreparation(String)
case mlsNotEnabled(String)
case invalidString, invalidPermissionOption
case noMessage
case invalidPermissionOption

var errorDescription: String? {
switch self {
case .noClient:
return "No client is available."
case .conversationNotFound(let id):
return "Conversation with ID '\(id)' was not found."
case .noMessage:
return "No message was provided."
case .invalidPermissionOption:
return "The permission option is invalid."
}
}
}

public func definition() -> ModuleDefinition {
Expand Down Expand Up @@ -217,7 +228,7 @@ public class XMTPModule: Module {
account: privateKey, options: options)

await clientsManager.updateClient(
key: client.inboxID, client: client)
key: client.installationID, client: client)
return try ClientWrapper.encodeToObj(client)
}

Expand Down Expand Up @@ -252,7 +263,7 @@ public class XMTPModule: Module {
let client = try await XMTP.Client.create(
account: signer, options: options)
await self.clientsManager.updateClient(
key: client.inboxID, client: client)
key: client.installationID, client: client)
self.signer = nil
self.sendEvent("authed", try ClientWrapper.encodeToObj(client))
}
Expand All @@ -271,7 +282,7 @@ public class XMTPModule: Module {
let client = try await XMTP.Client.build(
address: address, options: options)
await clientsManager.updateClient(
key: client.inboxID, client: client)
key: client.installationID, client: client)
return try ClientWrapper.encodeToObj(client)
}

Expand Down

0 comments on commit 46eb00b

Please sign in to comment.