-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PWN-8982 - fix metadata and user status load on topup
- Loading branch information
1 parent
5cf0e9d
commit 555fa3b
Showing
30 changed files
with
335 additions
and
178 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
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
40 changes: 40 additions & 0 deletions
40
app/src/main/java/org/p2p/wallet/auth/interactor/MetadataChangesLogger.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,40 @@ | ||
package org.p2p.wallet.auth.interactor | ||
|
||
import androidx.core.content.edit | ||
import android.content.SharedPreferences | ||
import com.google.gson.Gson | ||
import org.p2p.wallet.BuildConfig | ||
import org.p2p.wallet.auth.gateway.repository.model.GatewayOnboardingMetadata | ||
import org.p2p.wallet.utils.DateTimeUtils | ||
|
||
private const val KEY_CHANGES_LOG = "KEY_CHANGES_LOG" | ||
|
||
class MetadataChangesLogger( | ||
private val sharedPreferences: SharedPreferences, | ||
private val gson: Gson | ||
) { | ||
val logs: Set<String> | ||
get() = sharedPreferences.getStringSet(KEY_CHANGES_LOG, emptySet()).orEmpty() | ||
|
||
fun logChange( | ||
metadataOld: GatewayOnboardingMetadata?, | ||
metadataNew: GatewayOnboardingMetadata | ||
) { | ||
if (BuildConfig.DEBUG) { | ||
val metadataLogs = | ||
sharedPreferences.getStringSet(KEY_CHANGES_LOG, emptySet()) ?: mutableSetOf() | ||
|
||
val logEntry = buildString { | ||
append(DateTimeUtils.getFormattedDateAndTime(System.currentTimeMillis())) | ||
append(":") | ||
appendLine() | ||
append("before=${gson.toJson(metadataOld)}") | ||
appendLine() | ||
append("after=${gson.toJson(metadataNew)}") | ||
appendLine() | ||
} | ||
val newMetadataLogs = HashSet(metadataLogs).plus(logEntry) | ||
sharedPreferences.edit { putStringSet(KEY_CHANGES_LOG, newMetadataLogs) } | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.