withNewAccess method

Future<AccessDetermined> withNewAccess(
  1. AccessBloc accessBloc,
  2. AccessModel access
)

Implementation

Future<AccessDetermined> withNewAccess(
    AccessBloc accessBloc, AccessModel access) async {
  var appId = access.appId;
  var newCurrentApp = await appRepository()!.get(appId);
  if (newCurrentApp == null) {
    throw Exception("Can't find app with id $appId");
  }
  var newAccesses = {...accesses};
  newAccesses.removeWhere((key, value) => key == appId);

  var newApps = [...apps];
  newApps.removeWhere((element) => element.app.documentID == appId);

  return addApp2(accessBloc, newAccesses, newApps, newCurrentApp);
}