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 {
_accountsBloc.getAppsBloc(account).setActiveApp(id);
await _accountsBloc.getAppsBloc(account).setActiveApp(id);
_navigatorKey.currentState!.popUntil((final route) => route.settings.name == 'home');
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);
if (matchingAppImplementations.isNotEmpty) {
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 {
await showDialog(
context: context,

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

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

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

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

Loading…
Cancel
Save