- Separates Application dependencies into an AppModules class to create only after the OnCreate event.
- Switches TorSettings to be per Application and not per Account anymore - Since TorSettings is now global, moves the okHttpClient determinations out of the Account-based classes into the Application. - Since TorSettings is now global, set's up Coil's image loader only once when creating the Application - Moves UISettings state to App Modules instead of viewmodel - Migrates TorSettings and UISettings to DataStore - Accounts now have their own coroutine scopes to allow cancellation when they are unloaded/logged off - New tor evaluator service for relay connections now uses all account's trusted relays and dm relays at the same time. - Migrates composable-state-based UISettings to Flow-based UI settings, while observing connectivity status - Removes the displayFeatures and windowSizeClass from the shared model - Fixes not requesting Notification Permissions for APIs older than Tiramisu in the FDroid flavor - Moves the NIP-11 document cache from singleton to the App Modules - Avoids using AccountViewModel to check NIP-11 Relay documents - Moves the UI Settings usage in composables to functions that do not observe the state since they don't need to refresh the screen when changed. - Refactors UI Settings screen to separate components and remove the sharedViewModel - Only starts Internal Tor if that option is selected in the TorSettings. - Turn TorSettings into a data class to observe changes to it - Drops the SharedPreferences ViewModel to use UISettingsFlow directly from App Modules - Reorganizes OTS Events after simplification of the OkHttp based on TorSettings.
This commit is contained in:
+1
-1
@@ -459,7 +459,7 @@ open class BasicRelayClient(
|
||||
)
|
||||
}
|
||||
socket?.let {
|
||||
// Log.d(logTag, "Sending: $str")
|
||||
Log.d(logTag, "Sending: $str")
|
||||
val result = it.send(str)
|
||||
listener.onSend(this@BasicRelayClient, str, result)
|
||||
stats.addBytesSent(str.bytesUsedInMemory())
|
||||
|
||||
+9
-13
@@ -24,35 +24,31 @@ import android.util.LruCache
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
|
||||
class VerificationStateCache {
|
||||
class VerificationStateCache(
|
||||
val otsResolverBuilder: OtsResolverBuilder,
|
||||
) {
|
||||
private val cache = LruCache<HexKey, VerificationState>(200)
|
||||
|
||||
fun verify(
|
||||
event: OtsEvent,
|
||||
resolverBuilder: OtsResolverBuilder,
|
||||
): VerificationState {
|
||||
fun verify(event: OtsEvent): VerificationState {
|
||||
cache.put(event.id, VerificationState.Verifying)
|
||||
return event.verifyState(resolverBuilder.build()).also { cache.put(event.id, it) }
|
||||
return event.verifyState(otsResolverBuilder.build()).also { cache.put(event.id, it) }
|
||||
}
|
||||
|
||||
fun cacheVerify(
|
||||
event: OtsEvent,
|
||||
resolverBuilder: OtsResolverBuilder,
|
||||
): VerificationState =
|
||||
fun cacheVerify(event: OtsEvent): VerificationState =
|
||||
when (val verif = cache[event.id]) {
|
||||
is VerificationState.Verifying -> verif
|
||||
is VerificationState.Verified -> verif
|
||||
is VerificationState.NetworkError -> {
|
||||
// try again in 5 mins
|
||||
if (verif.time < TimeUtils.fiveMinutesAgo()) {
|
||||
event.verifyState(resolverBuilder.build()).also { cache.put(event.id, it) }
|
||||
event.verifyState(otsResolverBuilder.build()).also { cache.put(event.id, it) }
|
||||
} else {
|
||||
verify(event, resolverBuilder)
|
||||
verify(event)
|
||||
}
|
||||
}
|
||||
is VerificationState.Error -> verif
|
||||
else -> {
|
||||
verify(event, resolverBuilder)
|
||||
verify(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user