Skip to content

Commit

Permalink
add function for deleting database
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 23, 2024
1 parent 880ec58 commit 277b853
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public final class Client {
let apiClient: ApiClient
let v3Client: LibXMTP.FfiXmtpClient?
public let libXMTPVersion: String = getVersionInfo()
let dbPath: String = ""

/// Access ``Conversations`` for this Client.
public lazy var conversations: Conversations = .init(client: self)
Expand Down Expand Up @@ -450,6 +451,18 @@ public final class Client {
public func subscribe(topics: [Topic]) -> AsyncThrowingStream<Envelope, Error> {
return subscribe(topics: topics.map(\.description))
}

public func deleteLocalDatabase() {
let fm = FileManager.default
let url = URL(string: dbPath)
if (url != nil) {
do {
try fm.removeItem(at: url!)
} catch {
print("Error deleting file: \(dbPath)")
}
}
}

func getUserContact(peerAddress: String) async throws -> ContactBundle? {
let peerAddress = EthereumAddress(peerAddress).toChecksumAddress()
Expand Down

0 comments on commit 277b853

Please sign in to comment.