fix: Update codegen of hive adapters

This commit is contained in:
Anton Stubenbord
2023-10-06 12:09:03 +02:00
parent 0616ca2ffc
commit 29b7c8bdc0
4 changed files with 64 additions and 76 deletions

View File

@@ -192,25 +192,15 @@ class AuthenticationCubit extends Cubit<AuthenticationState> {
final sessionManager = SessionManager([
LanguageHeaderInterceptor(locale),
]);
try {
await _addUser(
localUserId,
serverUrl,
credentials,
clientCertificate,
sessionManager,
// onPerformLogin: () async {
// emit(AuthenticatingState(AuthenticatingStage.authenticating));
// await Future.delayed(const Duration(milliseconds: 500));
// },
);
await _addUser(
localUserId,
serverUrl,
credentials,
clientCertificate,
sessionManager,
);
return localUserId;
} catch (error, stackTrace) {
print(error);
debugPrintStack(stackTrace: stackTrace);
rethrow;
}
return localUserId;
}
Future<void> removeAccount(String userId) async {

View File

@@ -232,53 +232,51 @@ class _GoRouterShellState extends State<GoRouterShell> {
initialLocation: "/login",
routes: [
ShellRoute(
pageBuilder: (context, state, child) {
return MaterialPage(
child: BlocListener<AuthenticationCubit, AuthenticationState>(
listener: (context, state) {
switch (state) {
case UnauthenticatedState(
redirectToAccountSelection: var shouldRedirect
):
if (shouldRedirect) {
const LoginToExistingAccountRoute().go(context);
} else {
const LoginRoute().go(context);
}
break;
case RestoringSessionState():
const RestoringSessionRoute().go(context);
break;
case VerifyIdentityState(userId: var userId):
VerifyIdentityRoute(userId: userId).go(context);
break;
case SwitchingAccountsState():
const SwitchingAccountsRoute().push(context);
break;
case AuthenticatedState():
const LandingRoute().go(context);
break;
case AuthenticatingState state:
AuthenticatingRoute(state.currentStage.name).push(context);
break;
case LoggingOutState():
const LoggingOutRoute().go(context);
break;
case AuthenticationErrorState():
if (context.canPop()) {
context.pop();
}
// LoginRoute(
// $extra: errorState.clientCertificate,
// password: errorState.password,
// serverUrl: errorState.serverUrl,
// username: errorState.username,
// ).go(context);
break;
}
},
child: child,
),
builder: (context, state, child) {
return BlocListener<AuthenticationCubit, AuthenticationState>(
listener: (context, state) {
switch (state) {
case UnauthenticatedState(
redirectToAccountSelection: var shouldRedirect
):
if (shouldRedirect) {
const LoginToExistingAccountRoute().go(context);
} else {
const LoginRoute().go(context);
}
break;
case RestoringSessionState():
const RestoringSessionRoute().go(context);
break;
case VerifyIdentityState(userId: var userId):
VerifyIdentityRoute(userId: userId).go(context);
break;
case SwitchingAccountsState():
const SwitchingAccountsRoute().push(context);
break;
case AuthenticatedState():
const LandingRoute().go(context);
break;
case AuthenticatingState state:
AuthenticatingRoute(state.currentStage.name).push(context);
break;
case LoggingOutState():
const LoggingOutRoute().go(context);
break;
case AuthenticationErrorState():
if (context.canPop()) {
context.pop();
}
// LoginRoute(
// $extra: errorState.clientCertificate,
// password: errorState.password,
// serverUrl: errorState.serverUrl,
// username: errorState.username,
// ).go(context);
break;
}
},
child: child,
);
},
navigatorKey: rootNavigatorKey,

View File

@@ -1,6 +1,5 @@
import 'package:hive/hive.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_api/src/models/query_parameters/date_range_queries/date_range_unit.dart';
class PaperlessApiHiveTypeIds {
PaperlessApiHiveTypeIds._();
@@ -37,9 +36,9 @@ class PaperlessApiHiveTypeIds {
void registerPaperlessApiHiveTypeAdapters() {
Hive.registerAdapter(DocumentFilterAdapter());
// TagsQuery
Hive.registerAdapter(AnyAssignedTagsQueryAdapter());
Hive.registerAdapter(NotAssignedTagsQueryAdapter());
Hive.registerAdapter(IdsTagsQueryAdapter());
Hive.registerAdapter(AnyAssignedTagsQueryImplAdapter());
Hive.registerAdapter(NotAssignedTagsQueryImplAdapter());
Hive.registerAdapter(IdsTagsQueryImplAdapter());
Hive.registerAdapter(SortFieldAdapter());
Hive.registerAdapter(SortOrderAdapter());
@@ -50,13 +49,13 @@ void registerPaperlessApiHiveTypeAdapters() {
Hive.registerAdapter(TextQueryAdapter());
Hive.registerAdapter(QueryTypeAdapter());
// IdQueryParameter
Hive.registerAdapter(SetIdQueryParameterAdapter());
Hive.registerAdapter(UnsetIdQueryParameterAdapter());
Hive.registerAdapter(AnyAssignedIdQueryParameterAdapter());
Hive.registerAdapter(NotAssignedIdQueryParameterAdapter());
Hive.registerAdapter(SetIdQueryParameterImplAdapter());
Hive.registerAdapter(UnsetIdQueryParameterImplAdapter());
Hive.registerAdapter(AnyAssignedIdQueryParameterImplAdapter());
Hive.registerAdapter(NotAssignedIdQueryParameterImplAdapter());
// Users and permissions
Hive.registerAdapter(UserModelV3Adapter());
Hive.registerAdapter(UserModelV2Adapter());
Hive.registerAdapter(UserModelV3ImplAdapter());
Hive.registerAdapter(UserModelV2ImplAdapter());
Hive.registerAdapter(GroupModelAdapter());
Hive.registerAdapter(PermissionsAdapter());
}

View File

@@ -36,7 +36,8 @@ class UserModel with _$UserModel {
@HiveField(2) String? displayName,
}) = UserModelV2;
factory UserModel.fromJson(Map<String, dynamic> json) => _$UserModelFromJson(json);
factory UserModel.fromJson(Map<String, dynamic> json) =>
_$UserModelFromJson(json);
String? get fullName => map(
v2: (value) => value.displayName,