WIP - Redesigned login flow

This commit is contained in:
Anton Stubenbord
2023-01-05 01:38:00 +01:00
parent 2445c97d44
commit 738ef99bc5
60 changed files with 1159 additions and 755 deletions

View File

@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/type/types.dart';
@@ -9,12 +11,22 @@ class DioHttpErrorInterceptor extends Interceptor {
// try to parse contained error message, otherwise return response
final dynamic data = err.response?.data;
if (data is Map<String, dynamic>) {
return _handlePaperlessValidationError(data, handler, err);
_handlePaperlessValidationError(data, handler, err);
} else if (data is String) {
return _handlePlainError(data, handler, err);
_handlePlainError(data, handler, err);
}
} else if (err.error is SocketException) {
// Offline
handler.reject(
DioError(
error: const PaperlessServerException(ErrorCode.deviceOffline),
requestOptions: err.requestOptions,
type: DioErrorType.connectTimeout,
),
);
} else {
handler.reject(err);
}
handler.reject(err);
}
void _handlePaperlessValidationError(
@@ -54,7 +66,8 @@ class DioHttpErrorInterceptor extends Interceptor {
DioError(
requestOptions: err.requestOptions,
type: DioErrorType.response,
error: ErrorCode.missingClientCertificate,
error: const PaperlessServerException(
ErrorCode.missingClientCertificate),
),
);
}

View File

@@ -1,5 +1,4 @@
import 'package:dio/dio.dart';
import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
class LanguageHeaderInterceptor extends Interceptor {
String preferredLocaleSubtag;

View File

@@ -15,6 +15,7 @@ class RetryOnConnectionChangeInterceptor extends Interceptor {
try {
handler.resolve(await DioHttpRequestRetrier(dio: dio)
.requestRetry(err.requestOptions)
// ignore: body_might_complete_normally_catch_error
.catchError((e) {
handler.next(err);
}));