From 92b1744c35edf3b090f5788dfe10cb261be1f5b5 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 21 Feb 2023 09:43:14 -0500 Subject: [PATCH] Forces conversion of the ID to make sure it's a valid Hex ID and doesn't crash the app later. --- .../java/com/vitorpamplona/amethyst/model/LocalCache.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt index c0fcbce7e..31f346958 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt @@ -58,7 +58,7 @@ object LocalCache { fun checkGetOrCreateUser(key: String): User? { return try { - val checkHex = Hex.decode(key) // Checks if this is a valid Hex + val checkHex = Hex.decode(key).toNpub() // Checks if this is a valid Hex getOrCreateUser(key) } catch (e: IllegalArgumentException) { Log.e("LocalCache", "Invalid Key to create user: $key", e) @@ -77,7 +77,7 @@ object LocalCache { fun checkGetOrCreateNote(key: String): Note? { return try { - val checkHex = Hex.decode(key) // Checks if this is a valid Hex + val checkHex = Hex.decode(key).toNote() // Checks if this is a valid Hex getOrCreateNote(key) } catch (e: IllegalArgumentException) { Log.e("LocalCache", "Invalid Key to create note: $key", e) @@ -96,7 +96,7 @@ object LocalCache { fun checkGetOrCreateChannel(key: String): Channel? { return try { - val checkHex = Hex.decode(key) // Checks if this is a valid Hex + val checkHex = Hex.decode(key).toNote() // Checks if this is a valid Hex getOrCreateChannel(key) } catch (e: IllegalArgumentException) { Log.e("LocalCache", "Invalid Key to create channel: $key", e)