Skip to content

Commit

Permalink
Remove connectivity warning bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed Sep 18, 2024
1 parent c26d787 commit 799a6ac
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.signal.donations.StripeApi;
import org.thoughtcrime.securesms.components.DeviceSpecificNotificationBottomSheet;
import org.thoughtcrime.securesms.components.PromptBatterySaverDialogFragment;
import org.thoughtcrime.securesms.components.ConnectivityWarningBottomSheet;
import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity;
import org.thoughtcrime.securesms.components.voice.VoiceNoteMediaController;
import org.thoughtcrime.securesms.components.voice.VoiceNoteMediaControllerOwner;
Expand Down Expand Up @@ -122,9 +121,6 @@ private void presentVitalsState(VitalsViewModel.State state) {
case PROMPT_GENERAL_BATTERY_SAVER_DIALOG:
PromptBatterySaverDialogFragment.show(getSupportFragmentManager());
break;
case PROMPT_CONNECTIVITY_WARNING:
ConnectivityWarningBottomSheet.show(getSupportFragmentManager());
break;
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto
private const val LEAST_ACTIVE_LINKED_DEVICE = "misc.linked_device.least_active"
private const val NEXT_DATABASE_ANALYSIS_TIME = "misc.next_database_analysis_time"
private const val LAST_NETWORK_RESET_TIME = "misc.last_network_reset_time"
private const val LAST_WEBSOCKET_CONNECT_TIME = "misc.last_websocket_connect_time"
private const val LAST_CONNECTIVITY_WARNING_TIME = "misc.last_connectivity_warning_time"
}

public override fun onFirstEverAppLaunch() {
Expand Down Expand Up @@ -248,14 +246,4 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto
var nextDatabaseAnalysisTime: Long by longValue(NEXT_DATABASE_ANALYSIS_TIME, 0)

var lastNetworkResetDueToStreamResets: Long by longValue(LAST_NETWORK_RESET_TIME, 0L)

/**
* The last time you successfully connected to the websocket.
*/
var lastWebSocketConnectTime: Long by longValue(LAST_WEBSOCKET_CONNECT_TIME, System.currentTimeMillis())

/**
* The last time we prompted the user regarding a [org.thoughtcrime.securesms.util.ConnectivityWarning].
*/
var lastConnectivityWarningTime: Long by longValue(LAST_CONNECTIVITY_WARNING_TIME, 0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,6 @@ class IncomingMessageObserver(private val context: Application) {
if (state != WebSocketConnectionState.CONNECTED) {
decryptionDrained = false
}

if (state == WebSocketConnectionState.CONNECTED) {
SignalStore.misc.lastWebSocketConnectTime = System.currentTimeMillis()
}
}

signalWebSocket.connect(shouldKeepAliveUnidentified())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.schedulers.Schedulers
import io.reactivex.rxjava3.subjects.BehaviorSubject
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.notifications.DeviceSpecificNotificationConfig.ShowCondition
import org.thoughtcrime.securesms.util.ConnectivityWarning
import org.thoughtcrime.securesms.util.NetworkUtil
import java.util.concurrent.TimeUnit
import kotlin.time.Duration.Companion.days

/**
* View model for checking for various app vitals, like slow notifications and crashes.
Expand All @@ -32,7 +28,7 @@ class VitalsViewModel(private val context: Application) : AndroidViewModel(conte
vitalsState = checkSubject
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.throttleFirst(1, TimeUnit.MINUTES)
.throttleLast(15, TimeUnit.MINUTES)
.switchMapSingle {
checkHeuristics()
}
Expand Down Expand Up @@ -64,13 +60,6 @@ class VitalsViewModel(private val context: Application) : AndroidViewModel(conte
return@fromCallable State.PROMPT_GENERAL_BATTERY_SAVER_DIALOG
}

val timeSinceLastConnection = System.currentTimeMillis() - SignalStore.misc.lastWebSocketConnectTime
val timeSinceLastConnectionWarning = System.currentTimeMillis() - SignalStore.misc.lastConnectivityWarningTime

if (ConnectivityWarning.isEnabled && timeSinceLastConnection > ConnectivityWarning.threshold && timeSinceLastConnectionWarning > 14.days.inWholeMilliseconds && NetworkUtil.isConnected(context)) {
return@fromCallable State.PROMPT_CONNECTIVITY_WARNING
}

return@fromCallable State.NONE
}.subscribeOn(Schedulers.io())
}
Expand All @@ -79,6 +68,5 @@ class VitalsViewModel(private val context: Application) : AndroidViewModel(conte
NONE,
PROMPT_SPECIFIC_BATTERY_SAVER_DIALOG,
PROMPT_GENERAL_BATTERY_SAVER_DIALOG,
PROMPT_CONNECTIVITY_WARNING,
}
}

0 comments on commit 799a6ac

Please sign in to comment.