Browse Source

refactor(neon): Cleanup creating blocs for account

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/495/head
jld3103 1 year ago
parent
commit
155e9f1504
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 62
      packages/neon/neon/lib/src/blocs/accounts.dart

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

@ -225,18 +225,12 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
/// The appsBloc for the specified [account]. /// The appsBloc for the specified [account].
/// ///
/// Use [activeAppsBloc] to get them for the [activeAccount]. /// Use [activeAppsBloc] to get them for the [activeAccount].
AppsBloc getAppsBlocFor(final Account account) { AppsBloc getAppsBlocFor(final Account account) => _appsBlocs[account.id] ??= AppsBloc(
if (_appsBlocs[account.id] != null) { getCapabilitiesBlocFor(account),
return _appsBlocs[account.id]!; this,
} account,
_allAppImplementations,
return _appsBlocs[account.id] = AppsBloc( );
getCapabilitiesBlocFor(account),
this,
account,
_allAppImplementations,
);
}
/// The capabilitiesBloc for the [activeAccount]. /// The capabilitiesBloc for the [activeAccount].
/// ///
@ -246,13 +240,8 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
/// The capabilitiesBloc for the specified [account]. /// The capabilitiesBloc for the specified [account].
/// ///
/// Use [activeCapabilitiesBloc] to get them for the [activeAccount]. /// Use [activeCapabilitiesBloc] to get them for the [activeAccount].
CapabilitiesBloc getCapabilitiesBlocFor(final Account account) { CapabilitiesBloc getCapabilitiesBlocFor(final Account account) =>
if (_capabilitiesBlocs[account.id] != null) { _capabilitiesBlocs[account.id] ??= CapabilitiesBloc(account);
return _capabilitiesBlocs[account.id]!;
}
return _capabilitiesBlocs[account.id] = CapabilitiesBloc(account);
}
/// The userDetailsBloc for the [activeAccount]. /// The userDetailsBloc for the [activeAccount].
/// ///
@ -262,13 +251,8 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
/// The userDetailsBloc for the specified [account]. /// The userDetailsBloc for the specified [account].
/// ///
/// Use [activeUerDetailsBloc] to get them for the [activeAccount]. /// Use [activeUerDetailsBloc] to get them for the [activeAccount].
UserDetailsBloc getUserDetailsBlocFor(final Account account) { UserDetailsBloc getUserDetailsBlocFor(final Account account) =>
if (_userDetailsBlocs[account.id] != null) { _userDetailsBlocs[account.id] ??= UserDetailsBloc(account);
return _userDetailsBlocs[account.id]!;
}
return _userDetailsBlocs[account.id] = UserDetailsBloc(account);
}
/// The userStatusBloc for the [activeAccount]. /// The userStatusBloc for the [activeAccount].
/// ///
@ -278,15 +262,8 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
/// The userStatusBloc for the specified [account]. /// The userStatusBloc for the specified [account].
/// ///
/// Use [activeUserStatusesBloc] to get them for the [activeAccount]. /// Use [activeUserStatusesBloc] to get them for the [activeAccount].
UserStatusesBloc getUserStatusesBlocFor(final Account account) { UserStatusesBloc getUserStatusesBlocFor(final Account account) =>
if (_userStatusesBlocs[account.id] != null) { _userStatusesBlocs[account.id] ??= UserStatusesBloc(account);
return _userStatusesBlocs[account.id]!;
}
return _userStatusesBlocs[account.id] = UserStatusesBloc(
account,
);
}
/// The UnifiedSearchBloc for the [activeAccount]. /// The UnifiedSearchBloc for the [activeAccount].
/// ///
@ -296,16 +273,11 @@ class AccountsBloc extends Bloc implements AccountsBlocEvents, AccountsBlocState
/// The UnifiedSearchBloc for the specified [account]. /// The UnifiedSearchBloc for the specified [account].
/// ///
/// Use [activeUnifiedSearchBloc] to get them for the [activeAccount]. /// Use [activeUnifiedSearchBloc] to get them for the [activeAccount].
UnifiedSearchBloc getUnifiedSearchBlocFor(final Account account) { UnifiedSearchBloc getUnifiedSearchBlocFor(final Account account) =>
if (_unifiedSearchBlocs[account.id] != null) { _unifiedSearchBlocs[account.id] ??= UnifiedSearchBloc(
return _unifiedSearchBlocs[account.id]!; getAppsBlocFor(account),
} account,
);
return _unifiedSearchBlocs[account.id] = UnifiedSearchBloc(
getAppsBlocFor(account),
account,
);
}
} }
/// Get a list of logged in accounts from [storage]. /// Get a list of logged in accounts from [storage].

Loading…
Cancel
Save