Browse Source

Merge pull request #183 from provokateurin/fix/open-app-from-shortcut

neon: Fix opening app from shortcut
pull/184/head
Kate 2 years ago committed by GitHub
parent
commit
4c2b3b6191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/neon/lib/src/app.dart
  2. 2
      packages/neon/lib/src/apps/notifications/pages/main.dart
  3. 9
      packages/neon/lib/src/blocs/apps.dart
  4. 11
      packages/neon/lib/src/pages/home.dart

2
packages/neon/lib/src/app.dart

@ -255,7 +255,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
} }
Future _openAppFromExternal(final Account account, final String id) async { Future _openAppFromExternal(final Account account, final String id) async {
_accountsBloc.getAppsBloc(account).setActiveApp(id); await _accountsBloc.getAppsBloc(account).setActiveApp(id);
_navigatorKey.currentState!.popUntil((final route) => route.settings.name == 'home'); _navigatorKey.currentState!.popUntil((final route) => route.settings.name == 'home');
await _showAndRestoreWindow(); await _showAndRestoreWindow();
} }

2
packages/neon/lib/src/apps/notifications/pages/main.dart

@ -94,7 +94,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
final matchingAppImplementations = allAppImplementations.where((final a) => a.id == notification.app); final matchingAppImplementations = allAppImplementations.where((final a) => a.id == notification.app);
if (matchingAppImplementations.isNotEmpty) { if (matchingAppImplementations.isNotEmpty) {
final accountsBloc = Provider.of<AccountsBloc>(context, listen: false); final accountsBloc = Provider.of<AccountsBloc>(context, listen: false);
accountsBloc.getAppsBloc(accountsBloc.activeAccount.value!).setActiveApp(notification.app); await accountsBloc.getAppsBloc(accountsBloc.activeAccount.value!).setActiveApp(notification.app);
} else { } else {
await showDialog( await showDialog(
context: context, context: context,

9
packages/neon/lib/src/blocs/apps.dart

@ -44,7 +44,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
} }
} }
if (!activeAppID.hasValue) { if (!activeAppID.hasValue) {
setActiveApp(initialApp); await setActiveApp(initialApp);
} }
}), }),
); );
@ -119,8 +119,11 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
} }
@override @override
void setActiveApp(final String? appID) { Future setActiveApp(final String? appID) async {
if (appImplementations.value.data!.where((final app) => app.id == appID).isNotEmpty) { if ((await appImplementations.firstWhere((final a) => a.data != null))
.data!
.where((final app) => app.id == appID)
.isNotEmpty) {
if (activeAppID.valueOrNull != appID) { if (activeAppID.valueOrNull != appID) {
activeAppID.add(appID); activeAppID.add(appID);
} }

11
packages/neon/lib/src/pages/home.dart

@ -321,8 +321,8 @@ class _HomePageState extends State<HomePage> {
return Tooltip( return Tooltip(
message: appImplementation.name(context), message: appImplementation.name(context),
child: IconButton( child: IconButton(
onPressed: () { onPressed: () async {
_appsBloc.setActiveApp(appImplementation.id); await _appsBloc.setActiveApp(appImplementation.id);
}, },
icon: AppImplementationIcon( icon: AppImplementationIcon(
appImplementation: appImplementation, appImplementation: appImplementation,
@ -352,10 +352,13 @@ class _HomePageState extends State<HomePage> {
), ),
leading: appImplementation.buildIcon(context), leading: appImplementation.buildIcon(context),
minLeadingWidth: 0, minLeadingWidth: 0,
onTap: () { onTap: () async {
_appsBloc.setActiveApp(appImplementation.id); await _appsBloc.setActiveApp(appImplementation.id);
if (navigationMode == NavigationMode.drawer) { if (navigationMode == NavigationMode.drawer) {
// Don't pop when the drawer is always shown // Don't pop when the drawer is always shown
if (!mounted) {
return;
}
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
}, },

Loading…
Cancel
Save