diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 7ec92e8..0bba900 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -36,6 +36,7 @@ class _HomePageState extends State { bool prevIsLoading = true; late AppLinks _appLinks; StreamSubscription? _linkSubscription; + bool isLinkActivity = false; List pages = [ NavigationPageItem(tr('appsString'), Icons.apps, @@ -69,6 +70,7 @@ class _HomePageState extends State { } interpretLink(Uri uri) async { + isLinkActivity = true; var action = uri.host; var data = uri.path.length > 1 ? uri.path.substring(1) : ""; try { @@ -124,12 +126,6 @@ class _HomePageState extends State { } else if (selectedIndexHistory.isEmpty || (selectedIndexHistory.isNotEmpty && selectedIndexHistory.last != index)) { - // while (index == 1 && - // (pages[0].widget.key as GlobalKey).currentState != - // null) { - // // Avoid duplicate GlobalKey error - // await Future.delayed(const Duration(microseconds: 1)); - // } setState(() { int existingInd = selectedIndexHistory.indexOf(index); if (existingInd >= 0) { @@ -145,13 +141,14 @@ class _HomePageState extends State { AppsProvider appsProvider = context.watch(); SettingsProvider settingsProvider = context.watch(); - // if (!prevIsLoading && - // prevAppCount >= 0 && - // appsProvider.apps.length > prevAppCount && - // selectedIndexHistory.isNotEmpty && - // selectedIndexHistory.last == 1) { - // switchToPage(0); - // } + if (!prevIsLoading && + prevAppCount >= 0 && + appsProvider.apps.length > prevAppCount && + selectedIndexHistory.isNotEmpty && + selectedIndexHistory.last == 1 && + !isLinkActivity) { + switchToPage(0); + } prevAppCount = appsProvider.apps.length; prevIsLoading = appsProvider.loadingApps; @@ -197,6 +194,11 @@ class _HomePageState extends State { ), ), onWillPop: () async { + if (isLinkActivity && + selectedIndexHistory.length == 1 && + selectedIndexHistory.last == 1) { + return true; + } setIsReversing(selectedIndexHistory.length >= 2 ? selectedIndexHistory.reversed.toList()[1] : 0);