-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from xmtp/np/database-fetch-enhancements
Add new fetch methods for V3 local DB
- Loading branch information
Showing
11 changed files
with
375 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/AuthParamsWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.JsonParser | ||
|
||
class AuthParamsWrapper( | ||
val environment: String, | ||
val appVersion: String?, | ||
val enableV3: Boolean = false, | ||
val dbDirectory: String?, | ||
val historySyncUrl: String?, | ||
) { | ||
companion object { | ||
fun authParamsFromJson(authParams: String): AuthParamsWrapper { | ||
val jsonOptions = JsonParser.parseString(authParams).asJsonObject | ||
return AuthParamsWrapper( | ||
jsonOptions.get("environment").asString, | ||
if (jsonOptions.has("appVersion")) jsonOptions.get("appVersion").asString else null, | ||
if (jsonOptions.has("enableV3")) jsonOptions.get("enableV3").asBoolean else false, | ||
if (jsonOptions.has("dbDirectory")) jsonOptions.get("dbDirectory").asString else null, | ||
if (jsonOptions.has("historySyncUrl")) jsonOptions.get("historySyncUrl").asString else null | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// AuthParamsWrapper.swift | ||
// XMTPReactNative | ||
// | ||
// Created by Naomi Plasterer on 6/24/24. | ||
// | ||
|
||
import Foundation | ||
import XMTP | ||
|
||
struct AuthParamsWrapper { | ||
let environment: String | ||
let appVersion: String? | ||
let enableV3: Bool | ||
let dbDirectory: String? | ||
let historySyncUrl: String? | ||
|
||
init(environment: String, appVersion: String?, enableV3: Bool, dbDirectory: String?, historySyncUrl: String?) { | ||
self.environment = environment | ||
self.appVersion = appVersion | ||
self.enableV3 = enableV3 | ||
self.dbDirectory = dbDirectory | ||
self.historySyncUrl = historySyncUrl | ||
} | ||
|
||
static func authParamsFromJson(_ authParams: String) -> AuthParamsWrapper { | ||
guard let data = authParams.data(using: .utf8), | ||
let jsonOptions = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { | ||
return AuthParamsWrapper(environment: "dev", appVersion: nil, enableV3: false, dbDirectory: nil, historySyncUrl: nil) | ||
} | ||
|
||
let environment = jsonOptions["environment"] as? String ?? "dev" | ||
let appVersion = jsonOptions["appVersion"] as? String | ||
let enableV3 = jsonOptions["enableV3"] as? Bool ?? false | ||
let dbDirectory = jsonOptions["dbDirectory"] as? String | ||
let historySyncUrl = jsonOptions["historySyncUrl"] as? String | ||
|
||
return AuthParamsWrapper( | ||
environment: environment, | ||
appVersion: appVersion, | ||
enableV3: enableV3, | ||
dbDirectory: dbDirectory, | ||
historySyncUrl: historySyncUrl | ||
) | ||
} | ||
} |
Oops, something went wrong.