Skip to content

Commit

Permalink
Merge pull request #320 from astubenbord/fix/paperless-2.x.x
Browse files Browse the repository at this point in the history
fix: Add custom fields, translations, add app logs to login routes
  • Loading branch information
astubenbord authored Dec 10, 2023
2 parents 5e5e5d2 + 9f6b95f commit f26d561
Show file tree
Hide file tree
Showing 102 changed files with 2,399 additions and 1,088 deletions.
5 changes: 4 additions & 1 deletion android/fastlane/metadata/android/de-DE/changelogs/58.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
* Neue Einstellung um Animationen zu deaktivieren
* Verbesserte Validierung von Server-Adressen
* Verbesserte Validierung von Server-Adressen
* Beheben von Fehlern, durch welche es zu Problemen mit Paperless-ngx 2.x.x kam
* Weitere, kleinere Fehlerbehebungen
* Neue Übersetzungen
5 changes: 4 additions & 1 deletion android/fastlane/metadata/android/en-US/changelogs/58.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
* Add setting to disable animations
* Improved server-address validation
* Improved server-address validation
* Fixed a bug which caused issues with newer versions of Paperless-ngx (2.x.x)
* Minor bugfixes
* Updated translations
2 changes: 1 addition & 1 deletion fastlane/metadata
Original file line number Diff line number Diff line change
@@ -1 +1 @@
../android/fastlane/metadata
../../android/fastlane/metadata
1 change: 0 additions & 1 deletion flutter
Submodule flutter deleted from d211f4
6 changes: 6 additions & 0 deletions lib/core/bloc/loading_status.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum LoadingStatus {
initial,
loading,
loaded,
error;
}
41 changes: 41 additions & 0 deletions lib/core/bloc/my_bloc_observer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_mobile/core/bloc/transient_error.dart';
import 'package:paperless_mobile/core/translation/error_code_localization_mapper.dart';
import 'package:paperless_mobile/features/logging/data/logger.dart';
import 'package:paperless_mobile/helpers/message_helpers.dart';
import 'package:paperless_mobile/routing/navigation_keys.dart';

class MyBlocObserver extends BlocObserver {
@override
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
if (error is TransientError) {
_handleTransientError(bloc, error, stackTrace);
}
super.onError(bloc, error, stackTrace);
}

void _handleTransientError(
BlocBase bloc,
TransientError error,
StackTrace stackTrace,
) {
assert(rootNavigatorKey.currentContext != null);
final message = switch (error) {
TransientPaperlessApiError(code: var code) => translateError(
rootNavigatorKey.currentContext!,
code,
),
TransientMessageError(message: var message) => message,
};
final details = switch (error) {
TransientPaperlessApiError(details: var details) => details,
_ => null,
};

showSnackBar(
rootNavigatorKey.currentContext!,
message,
details: details,
);
}
}
16 changes: 16 additions & 0 deletions lib/core/bloc/transient_error.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:paperless_api/paperless_api.dart';

sealed class TransientError extends Error {}

class TransientPaperlessApiError extends TransientError {
final ErrorCode code;
final String? details;

TransientPaperlessApiError({required this.code, this.details});
}

class TransientMessageError extends TransientError {
final String message;

TransientMessageError({required this.message});
}
35 changes: 25 additions & 10 deletions lib/core/interceptor/dio_http_error_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,31 @@ class DioHttpErrorInterceptor extends Interceptor {
type: DioExceptionType.badResponse,
),
);
} else if (data is String &&
data.contains("No required SSL certificate was sent")) {
handler.reject(
DioException(
requestOptions: err.requestOptions,
type: DioExceptionType.badResponse,
error:
const PaperlessApiException(ErrorCode.missingClientCertificate),
),
);
} else if (data is String) {
if (data.contains("No required SSL certificate was sent")) {
handler.reject(
DioException(
requestOptions: err.requestOptions,
type: DioExceptionType.badResponse,
error: const PaperlessApiException(
ErrorCode.missingClientCertificate),
),
);
} else {
handler.reject(
DioException(
requestOptions: err.requestOptions,
message: data,
error: PaperlessApiException(
ErrorCode.documentLoadFailed,
details: data,
),
response: err.response,
stackTrace: err.stackTrace,
type: DioExceptionType.badResponse,
),
);
}
} else {
handler.reject(err);
}
Expand Down
Loading

0 comments on commit f26d561

Please sign in to comment.