Skip to content

Commit

Permalink
Fix setting default activity tracking (#301)
Browse files Browse the repository at this point in the history
Fixes #299 

Tracking activity was changed to default to `true` in
stashapp/stash#4710, but this app would default
it to `false` if the server didn't provide a value.

The server won't provide a value by default until the user explicitly
changes the setting. This means, for example, a brand new install of
server version `0.26.1` would have server-side tracking enabled but
would not provide the value in the UI config query. So this app would
read it as a `null` value and translate that to `false`.

This PR fixes this behavior so that if the server is at least `0.26.0`
and no value is provided by the server, it will default to true.
  • Loading branch information
damontecres committed Jun 19, 2024
1 parent 11b4059 commit 4f66978
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ class ServerPreferences(private val context: Context) {
config: ConfigurationQuery.Configuration?,
serverInfo: ServerInfoQuery.Data?,
) {
val serverVersion =
Version.tryFromString(serverInfo?.version?.version)
if (config != null) {
val ui = config.ui as Map<String, *>
preferences.edit(true) {
ui.getCaseInsensitive(PREF_TRACK_ACTIVITY).also {
// If null, toString()=>"null".toBoolean()=>false
putBoolean(PREF_TRACK_ACTIVITY, it.toString().toBoolean())
if (it != null) {
// Use a non-null value from server
putBoolean(PREF_TRACK_ACTIVITY, it.toString().toBoolean())
} else if (serverVersion != null && serverVersion.isAtLeast(Version.V0_26_0)) {
// If server is >=0.26.0 and doesn't provide a value, default to true
// See https://github.com/stashapp/stash/pull/4710
putBoolean(PREF_TRACK_ACTIVITY, true)
} else {
// Server <0.26.0 default to false
putBoolean(PREF_TRACK_ACTIVITY, false)
}
}
ui.getCaseInsensitive(PREF_MINIMUM_PLAY_PERCENT)?.let {
try {
Expand Down

0 comments on commit 4f66978

Please sign in to comment.