More work on inbox, refactorings (bloc separation of concerns), fixed saved views wrong sort order

This commit is contained in:
Anton Stubenbord
2022-11-29 01:09:36 +01:00
parent 5edbdabf26
commit 50190f035e
43 changed files with 605 additions and 463 deletions

View File

@@ -1,62 +0,0 @@
import 'dart:math';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:paperless_mobile/core/model/paperless_statistics.dart';
import 'package:paperless_mobile/core/model/paperless_statistics_state.dart';
import 'package:paperless_mobile/core/service/paperless_statistics_service.dart';
@singleton
class PaperlessStatisticsCubit extends Cubit<PaperlessStatisticsState> {
final PaperlessStatisticsService statisticsService;
PaperlessStatisticsCubit(this.statisticsService)
: super(PaperlessStatisticsState(isLoaded: false));
Future<void> updateStatistics() async {
final stats = await statisticsService.getStatistics();
emit(PaperlessStatisticsState(isLoaded: true, statistics: stats));
}
void decrementInboxCount() {
if (state.isLoaded) {
emit(
PaperlessStatisticsState(
isLoaded: true,
statistics: PaperlessStatistics(
documentsInInbox: max(0, state.statistics!.documentsInInbox - 1),
documentsTotal: state.statistics!.documentsTotal,
),
),
);
}
}
void incrementInboxCount() {
if (state.isLoaded) {
emit(
PaperlessStatisticsState(
isLoaded: true,
statistics: PaperlessStatistics(
documentsInInbox: state.statistics!.documentsInInbox + 1,
documentsTotal: state.statistics!.documentsTotal,
),
),
);
}
}
void resetInboxCount() {
if (state.isLoaded) {
emit(
PaperlessStatisticsState(
isLoaded: true,
statistics: PaperlessStatistics(
documentsInInbox: 0,
documentsTotal: state.statistics!.documentsTotal,
),
),
);
}
}
}

View File

@@ -4,16 +4,16 @@ enum AssetImages {
headacheDocuments("images/documents_headache.png"),
organizeDocuments("images/organize_documents.png"),
secureDocuments("images/secure_documents.png"),
success("images/success.png");
success("images/success.png"),
emptyInbox("images/empty_inbox.png");
final String relativePath;
const AssetImages(String relativePath)
: relativePath = "assets/$relativePath";
Image get image => Image.asset(
relativePath,
key: ObjectKey("assetimage_$relativePath"),
);
AssetImage get image => AssetImage(relativePath);
void load(context) => precacheImage(image.image, context);
void load(context) => precacheImage(image, context);
}
late Image emptyInboxImage;

View File

@@ -15,7 +15,7 @@ class AuthenticationInterceptor implements InterceptorContract {
Future<BaseRequest> interceptRequest({required BaseRequest request}) async {
final authState = authenticationCubit.state;
if (kDebugMode) {
log("Intercepted request to ${request.url.toString()}");
log("Intercepted ${request.method} request to ${request.url.toString()}");
}
if (authState.authentication == null) {
throw const ErrorMessage(ErrorCode.notAuthenticated);