Skip to content

Commit

Permalink
account: Logout now nulls values
Browse files Browse the repository at this point in the history
  • Loading branch information
mikooomich authored and reocat committed Jan 6, 2025
1 parent 4cc9327 commit b772d69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/com/dd3boh/outertune/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class App : Application(), ImageLoaderFactory {
// we now allow user input now, here be the demons. This serves as a last ditch effort to avoid a crash loop
Timber.e("Could not parse cookie. Clearing existing cookie. %s", e.message)
dataStore.edit { settings ->
settings[InnerTubeCookieKey] = ""
settings.remove(InnerTubeCookieKey)
settings.remove(VisitorDataKey)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.sp
import androidx.datastore.preferences.core.edit
import androidx.navigation.NavController
import com.dd3boh.outertune.LocalPlayerAwareWindowInsets
import com.dd3boh.outertune.R
Expand All @@ -48,6 +50,7 @@ import com.dd3boh.outertune.constants.ProxyEnabledKey
import com.dd3boh.outertune.constants.ProxyTypeKey
import com.dd3boh.outertune.constants.ProxyUrlKey
import com.dd3boh.outertune.constants.SYSTEM_DEFAULT
import com.dd3boh.outertune.constants.VisitorDataKey
import com.dd3boh.outertune.constants.YtmSyncKey
import com.dd3boh.outertune.ui.component.EditTextPreference
import com.dd3boh.outertune.ui.component.IconButton
Expand All @@ -58,9 +61,11 @@ import com.dd3boh.outertune.ui.component.PreferenceGroupTitle
import com.dd3boh.outertune.ui.component.SwitchPreference
import com.dd3boh.outertune.ui.component.TextFieldDialog
import com.dd3boh.outertune.ui.utils.backToMain
import com.dd3boh.outertune.utils.dataStore
import com.dd3boh.outertune.utils.rememberEnumPreference
import com.dd3boh.outertune.utils.rememberPreference
import com.zionhuang.innertube.utils.parseCookieString
import kotlinx.coroutines.runBlocking
import java.net.Proxy

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -69,6 +74,8 @@ fun ContentSettings(
navController: NavController,
scrollBehavior: TopAppBarScrollBehavior,
) {
val context = LocalContext.current

val accountName by rememberPreference(AccountNameKey, "")
val accountEmail by rememberPreference(AccountEmailKey, "")
val accountChannelHandle by rememberPreference(AccountChannelHandleKey, "")
Expand Down Expand Up @@ -120,6 +127,12 @@ fun ContentSettings(
icon = { Icon(Icons.AutoMirrored.Rounded.Logout, null) },
onClick = {
onInnerTubeCookieChange("")
runBlocking {
context.dataStore.edit { settings ->
settings.remove(InnerTubeCookieKey)
settings.remove(VisitorDataKey)
}
}
}
)
}
Expand Down

0 comments on commit b772d69

Please sign in to comment.