Skip to content

Commit

Permalink
Fix pop may call multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc authored Jun 2, 2024
1 parent ca8fb15 commit 727d3ec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/dialog/new_download_task_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class _NewDownloadTaskPage extends State<NewDownloadTaskPage> {
WidgetsBinding.instance!.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/task_manager");
});
_ok = false;
}
if (!_fetched) fetchDefaultCfg();
final i18n = AppLocalizations.of(context)!;
Expand Down
1 change: 1 addition & 0 deletions lib/dialog/new_export_zip_task_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class _NewExportZipTaskPage extends State<NewExportZipTaskPage> {
WidgetsBinding.instance!.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/task_manager");
});
_ok = false;
}
if (!_fetched) fetchDefaultCfg();
final i18n = AppLocalizations.of(context)!;
Expand Down
1 change: 1 addition & 0 deletions lib/dialog/new_user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class _NewUserPage extends State<NewUserPage> {
SchedulerBinding.instance.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/users");
});
_newUserId = null;
return Container();
}
final i18n = AppLocalizations.of(context)!;
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _LoginPageState extends State<LoginPage>
bool _isValid = false;
bool _isLogin = false;
bool _checkAuth = false;
bool _tryPoped = false;

void _onStateChanged(dynamic _) {
setState(() {});
Expand Down Expand Up @@ -120,10 +121,12 @@ class _LoginPageState extends State<LoginPage>
Widget build(BuildContext context) {
tryInitApi(context);
_checkStatus(context);
if (isTop(context) && auth.user != null) {
if (isTop(context) && auth.user != null && !_tryPoped) {
SchedulerBinding.instance.addPostFrameCallback((_) {
context.canPop() ? context.pop() : context.go("/");
});
_tryPoped = true;
return Container();
}
return Scaffold(
appBar: AppBar(
Expand Down

0 comments on commit 727d3ec

Please sign in to comment.