This commit is contained in:
Bnyro 2022-07-03 11:39:25 +02:00
parent bcc475102a
commit cf6a0e2937
3 changed files with 5 additions and 4 deletions

View File

@ -61,6 +61,7 @@ class MainActivity : AppCompatActivity() {
RetrofitInstance.url =
PreferenceHelper.getString(this, "selectInstance", "https://pipedapi.kavin.rocks/")!!
// set auth instance
RetrofitInstance.authUrl =
if (PreferenceHelper.getBoolean(this, "auth_instance_toggle", false)) {
PreferenceHelper.getString(

View File

@ -69,7 +69,6 @@ class LoginDialog : DialogFragment() {
private fun login(login: Login) {
fun run() {
lifecycleScope.launchWhenCreated {
Log.e(TAG, RetrofitInstance.authUrl)
val response = try {
RetrofitInstance.authApi.login(login)
} catch (e: IOException) {

View File

@ -34,7 +34,6 @@ import java.io.IOException
import java.io.InputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import kotlin.math.log
class InstanceSettings : PreferenceFragmentCompat() {
val TAG = "InstanceSettings"
@ -138,6 +137,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
}
authInstance.setOnPreferenceChangeListener { _, newValue ->
requireMainActivityRestart = true
// save new auth url
RetrofitInstance.authUrl = newValue.toString()
RetrofitInstance.lazyMgr.reset()
logout()
@ -149,6 +149,7 @@ class InstanceSettings : PreferenceFragmentCompat() {
requireMainActivityRestart = true
authInstance.isVisible = newValue == true
logout()
// either use new auth url or the normal api url if auth instance disabled
RetrofitInstance.authUrl = if (newValue == false) RetrofitInstance.url
else authInstance.value
true