Fix login dialog

This commit is contained in:
Kelvin 2025-08-15 21:20:23 +02:00
commit 1edc8aabf8
2 changed files with 15 additions and 5 deletions

View file

@ -1141,10 +1141,14 @@ class VideoDetailView : ConstraintLayout {
//Lifecycle //Lifecycle
var isLoginStop = false; //TODO: This is a bit jank, but easiest solution for now without reworking flow. (Alternatively, fix MainActivity getting stopped/disposing video)
fun onResume() { fun onResume() {
Logger.v(TAG, "onResume"); Logger.v(TAG, "onResume");
_onPauseCalled = false; _onPauseCalled = false;
val wasLoginCall = isLoginStop;
isLoginStop = false;
Logger.i(TAG, "_video: ${video?.name ?: "no video"}"); Logger.i(TAG, "_video: ${video?.name ?: "no video"}");
Logger.i(TAG, "_didStop: $_didStop"); Logger.i(TAG, "_didStop: $_didStop");
@ -1153,7 +1157,7 @@ class VideoDetailView : ConstraintLayout {
val t = (lastPositionMilliseconds / 1000.0f).roundToLong(); val t = (lastPositionMilliseconds / 1000.0f).roundToLong();
if(_searchVideo != null) if(_searchVideo != null)
setVideoOverview(_searchVideo!!, true, t); setVideoOverview(_searchVideo!!, true, t);
else if(_url != null) else if(_url != null && !wasLoginCall)
setVideo(_url!!, t, _playWhenReady); setVideo(_url!!, t, _playWhenReady);
} }
else if(_didStop) { else if(_didStop) {
@ -3276,8 +3280,13 @@ class VideoDetailView : ConstraintLayout {
val id = e.config.let { if(it is SourcePluginConfig) it.id else null }; val id = e.config.let { if(it is SourcePluginConfig) it.id else null };
val didLogin = if(id == null) val didLogin = if(id == null)
false false
else StatePlugins.instance.loginPlugin(context, id) { else {
fetchVideo(); isLoginStop = true;
StatePlugins.instance.loginPlugin(context, id) {
fragment.lifecycleScope.launch(Dispatchers.Main) {
fetchVideo();
}
}
} }
if(!didLogin) if(!didLogin)
UIDialogs.showDialogOk(context, R.drawable.ic_error_pred, "Failed to login"); UIDialogs.showDialogOk(context, R.drawable.ic_error_pred, "Failed to login");

View file

@ -179,8 +179,9 @@ class StatePlugins {
} }
StateApp.instance.scope.launch(Dispatchers.IO) { StateApp.instance.scope.launch(Dispatchers.IO) {
StatePlatform.instance.reloadClient(context, id); StatePlatform.instance.reloadClient(context, id) {
afterLogin.invoke(); afterLogin.invoke();
}
} }
}; };
return true; return true;