Skip to content

Commit 0ea43e5

Browse files
committed
fix: default speedInterval to 1000ms so fresh installs show speeds
DataStore.speedInterval used stringToInt's implicit { 0 } default. On a fresh install that never opens the Settings screen, the key is absent, so it resolved to 0. TrafficLooper.loop() returns early when delayMs == 0, which disables the traffic-stats loop entirely and leaves the dashboard up/down (UP/DOWN) speeds permanently blank. Align the code default with global_preferences.xml (defaultValue=1000) so the stats loop runs out of the box. '0' (Off) remains a valid explicit user choice via the settings menu.
1 parent bfac4af commit 0ea43e5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • app/src/main/java/io/nekohasekai/sagernet/database

app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ object DataStore : OnPreferenceDataStoreChangeListener {
116116
var concurrentDial by configurationStore.boolean(Key.CONCURRENT_DIAL)
117117

118118
var allowAccess by configurationStore.boolean(Key.ALLOW_ACCESS)
119-
var speedInterval by configurationStore.stringToInt(Key.SPEED_INTERVAL)
119+
// Default must match global_preferences.xml (1000ms). Without a non-zero code
120+
// default, a fresh install that never opens Settings reads 0, which disables the
121+
// TrafficLooper stats loop entirely (TrafficLooper.loop() returns on delayMs == 0),
122+
// so the dashboard up/down speeds stay blank. "0" remains a valid user choice (Off).
123+
var speedInterval by configurationStore.stringToInt(Key.SPEED_INTERVAL) { 1000 }
120124
var showGroupInNotification by configurationStore.boolean("showGroupInNotification")
121125

122126
var globalCustomConfig by configurationStore.string(Key.GLOBAL_CUSTOM_CONFIG) { "" }

0 commit comments

Comments
 (0)