fix delete accounts

This commit is contained in:
Bnyro 2022-06-25 21:26:37 +02:00
parent 8062873ca2
commit 0d30ad1227
3 changed files with 8 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package com.github.libretube.dialogs
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
import android.widget.Button
import android.widget.EditText
@ -62,7 +63,8 @@ class DeleteAccountDialog : DialogFragment() {
val response = try {
RetrofitInstance.api.deleteAccount(token, DeleteUserRequest(password))
} catch (e: Exception) {
e.printStackTrace()
Log.e(TAG, e.toString())
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launchWhenCreated
}
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()

View File

@ -114,9 +114,6 @@ class InstanceSettings : PreferenceFragmentCompat() {
val topBarTextView = activity?.findViewById<TextView>(R.id.topBar_textView)
topBarTextView?.text = getString(R.string.instance)
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
val token = sharedPref?.getString("token", "")
val instance = findPreference<ListPreference>("selectInstance")
// fetchInstance()
initCustomInstances()
@ -155,8 +152,9 @@ class InstanceSettings : PreferenceFragmentCompat() {
}
val deleteAccount = findPreference<Preference>("delete_account")
deleteAccount?.parent?.removePreference(deleteAccount)
deleteAccount?.setOnPreferenceClickListener {
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
val token = sharedPref?.getString("token", "")
if (token != "") {
val newFragment = DeleteAccountDialog()
newFragment.show(childFragmentManager, "DeleteAccountDialog")
@ -168,6 +166,8 @@ class InstanceSettings : PreferenceFragmentCompat() {
val importFromYt = findPreference<Preference>("import_from_yt")
importFromYt?.setOnPreferenceClickListener {
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
val token = sharedPref?.getString("token", "")
// check StorageAccess
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Log.d("myz", "" + Build.VERSION.SDK_INT)

View File

@ -91,7 +91,7 @@ interface PipedApi {
suspend fun deleteAccount(
@Header("Authorization") token: String,
@Body password: DeleteUserRequest
): Message
)
@GET("feed")
suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem>