Browse Source

Merge pull request #508 from provokateurin/fix/quick-actions

Fix/quick actions
pull/519/head
Kate 1 year ago committed by GitHub
parent
commit
23290b7243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/neon/neon/lib/src/app.dart
  2. 8
      packages/neon/neon/lib/src/blocs/accounts.dart
  3. 14
      packages/neon/neon/lib/src/blocs/apps.dart
  4. 2
      packages/neon/neon/lib/src/pages/account_settings.dart

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

@ -227,7 +227,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
}
final matches = _appRegex.allMatches(shortcutType);
final activeAccount = _accountsBloc.activeAccount.valueOrNull;
final activeAccount = await _accountsBloc.activeAccount.first;
if (matches.isNotEmpty && activeAccount != null) {
await _openAppFromExternal(activeAccount, matches.first.group(1)!);
}

8
packages/neon/neon/lib/src/blocs/accounts.dart

@ -130,7 +130,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
BehaviorSubject<List<Account>> accounts = BehaviorSubject<List<Account>>.seeded([]);
@override
BehaviorSubject<Account?> activeAccount = BehaviorSubject<Account?>.seeded(null)
BehaviorSubject<Account?> activeAccount = BehaviorSubject<Account?>()
..distinct((final current, final next) => current?.id != next?.id);
@override
@ -191,10 +191,10 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
/// The currently active account.
///
/// Equivalent to activeAccount.value but throws a [StateError] when no user is logged in.
/// Equivalent to activeAccount.valueOrNull but throws a [StateError] when no user is logged in.
@visibleForTesting
Account get aa {
final aa = activeAccount.value;
final aa = activeAccount.valueOrNull;
if (aa == null) {
throw StateError('No user is logged in.');
@ -204,7 +204,7 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
}
/// Whether accounts are logged in.
bool get hasAccounts => activeAccount.value != null;
bool get hasAccounts => activeAccount.valueOrNull != null;
/// The options for the [activeAccount].
///

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

@ -19,7 +19,11 @@ import 'package:rxdart/rxdart.dart';
typedef NextcloudApp = CoreNavigationApps_Ocs_Data;
abstract class AppsBlocEvents {
void setActiveApp(final String appID);
/// Sets the active app using the [appID].
///
/// If the app is already the active app nothing will happen.
/// When using [skipAlreadySet] nothing will be done if there already is an active app.
void setActiveApp(final String appID, {final bool skipAlreadySet = false});
}
abstract class AppsBlocStates {
@ -57,8 +61,8 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
final options = _accountsBloc.getOptionsFor(_account);
final initialApp = options.initialApp.value ?? _getInitialAppFallback();
if (!activeApp.hasValue && initialApp != null) {
await setActiveApp(initialApp);
if (initialApp != null) {
await setActiveApp(initialApp, skipAlreadySet: true);
}
unawaited(_checkCompatibility());
@ -201,7 +205,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
}
@override
Future setActiveApp(final String appID) async {
Future setActiveApp(final String appID, {final bool skipAlreadySet = false}) async {
if (appID == AppIDs.notifications) {
openNotifications.add(null);
return;
@ -210,7 +214,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates
final apps = await appImplementations.firstWhere((final a) => a.hasData);
final app = apps.requireData.tryFind(appID);
if (app != null) {
if (activeApp.valueOrNull?.id != appID) {
if ((!activeApp.hasValue || !skipAlreadySet) && activeApp.valueOrNull?.id != appID) {
activeApp.add(app);
}
} else {

2
packages/neon/neon/lib/src/pages/account_settings.dart

@ -41,7 +41,7 @@ class AccountSettingsPage extends StatelessWidget {
context,
AppLocalizations.of(context).accountOptionsRemoveConfirm(account.client.humanReadableID),
)) {
final isActive = bloc.activeAccount.value == account;
final isActive = bloc.activeAccount.valueOrNull == account;
bloc.removeAccount(account);

Loading…
Cancel
Save