Fixed visual bugs, added notifications on document upload success, enabled editing in inbox, added hints

This commit is contained in:
Anton Stubenbord
2023-01-11 18:28:42 +01:00
parent a4c4726c16
commit 4d7af3fffb
34 changed files with 1046 additions and 627 deletions

View File

@@ -11,22 +11,23 @@ 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>) {
_handlePaperlessValidationError(data, handler, err);
return _handlePaperlessValidationError(data, handler, err);
} else if (data is String) {
_handlePlainError(data, handler, err);
return _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);
final ex = err.error as SocketException;
if (ex.osError?.errorCode == _OsErrorCodes.serverUnreachable.code) {
return handler.reject(
DioError(
error: const PaperlessServerException(ErrorCode.deviceOffline),
requestOptions: err.requestOptions,
type: DioErrorType.connectTimeout,
),
);
}
}
return handler.reject(err);
}
void _handlePaperlessValidationError(
@@ -73,3 +74,11 @@ class DioHttpErrorInterceptor extends Interceptor {
}
}
}
enum _OsErrorCodes {
serverUnreachable(101),
hostNotFound(7);
const _OsErrorCodes(this.code);
final int code;
}

View File

@@ -0,0 +1,60 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:paperless_mobile/core/global/os_error_codes.dart';
import 'package:paperless_mobile/features/login/model/reachability_status.dart';
class ServerReachabilityErrorInterceptor extends Interceptor {
static const _missingClientCertText = "No required SSL certificate was sent";
@override
void onError(DioError err, ErrorInterceptorHandler handler) {
if (err.response?.statusCode == 400) {
final message = err.response?.data;
if (message is String && message.contains(_missingClientCertText)) {
return _rejectWithStatus(
ReachabilityStatus.missingClientCertificate,
err,
handler,
);
}
}
if (err.type == DioErrorType.connectTimeout) {
return _rejectWithStatus(
ReachabilityStatus.connectionTimeout,
err,
handler,
);
}
final error = err.error;
if (error is SocketException) {
final code = error.osError?.errorCode;
if (code == OsErrorCodes.serverUnreachable.code ||
code == OsErrorCodes.hostNotFound.code) {
return _rejectWithStatus(
ReachabilityStatus.unknownHost,
err,
handler,
);
}
}
return _rejectWithStatus(
ReachabilityStatus.notReachable,
err,
handler,
);
}
}
void _rejectWithStatus(
ReachabilityStatus reachabilityStatus,
DioError err,
ErrorInterceptorHandler handler,
) {
handler.reject(DioError(
error: reachabilityStatus,
requestOptions: err.requestOptions,
response: err.response,
type: DioErrorType.other,
));
}