mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-24 10:32:15 +02:00
fix(core): stealth mode indicator
This commit is contained in:
parent
ae2e4c16ae
commit
ccc8000f4f
@ -9,6 +9,7 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
import me.rhunk.snapenhance.common.data.RuleState
|
||||||
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
||||||
import me.rhunk.snapenhance.core.features.Feature
|
import me.rhunk.snapenhance.core.features.Feature
|
||||||
import me.rhunk.snapenhance.core.features.impl.spying.StealthMode
|
import me.rhunk.snapenhance.core.features.impl.spying.StealthMode
|
||||||
@ -30,7 +31,7 @@ class StealthModeIndicator : Feature("StealthModeIndicator") {
|
|||||||
private fun requestUpdate(conversationId: String) {
|
private fun requestUpdate(conversationId: String) {
|
||||||
fetchJob?.cancel()
|
fetchJob?.cancel()
|
||||||
fetchJob = context.coroutineScope.launch {
|
fetchJob = context.coroutineScope.launch {
|
||||||
val isStealth = stealthMode.getState(conversationId)
|
val isStealth = stealthMode.canUseRule(conversationId)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
listener(isStealth)
|
listener(isStealth)
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ class StealthModeIndicator : Feature("StealthModeIndicator") {
|
|||||||
|
|
||||||
stealthMode.addStateListener { conversationId, state ->
|
stealthMode.addStateListener { conversationId, state ->
|
||||||
runCatching {
|
runCatching {
|
||||||
listeners[conversationId]?.invoke(state)
|
listeners[conversationId]?.invoke(stealthMode.getRuleState()?.let { if (it == RuleState.BLACKLIST) !state else state } ?: state)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
context.log.error("Failed to update stealth mode indicator", it)
|
context.log.error("Failed to update stealth mode indicator", it)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user