diff --git a/.gitignore b/.gitignore
index 9e5fafc..34bba21 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@ android/key.properties
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
.vscode/
+*.code-workspace
# Flutter/Dart/Pub related
**/doc/api/
diff --git a/README.md b/README.md
index 9381d68..8866661 100644
--- a/README.md
+++ b/README.md
@@ -227,3 +227,6 @@ Here are some impressions from the app!
Made with [contrib.rocks](https://contrib.rocks).
+## Troubleshooting
+#### Suggestions are not selectable in any of the label form fields
+This is a known issue and it has to do with accessibility features of Android. Password managers such as Bitwarden often caused this issue to occur. Luckily, this can be resolved by turning off the accessibility features in these apps.
diff --git a/android/app/build.gradle b/android/app/build.gradle
index c7a26c2..20e446a 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -68,11 +68,11 @@ android {
storePassword keystoreProperties['storePassword']
}
}
- buildTypes {
- release {
- signingConfig signingConfigs.release
- }
- }
+ buildTypes {
+ release {
+ signingConfig signingConfigs.release
+ }
+ }
}
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index 842ea55..2c66854 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -35,7 +35,7 @@ PODS:
- DKPhotoGallery/Resource (0.0.17):
- SDWebImage
- SwiftyGif
- - edge_detection (1.0.9):
+ - edge_detection (1.1.1):
- Flutter
- WeScan
- file_picker (0.0.1):
@@ -44,6 +44,8 @@ PODS:
- Flutter (1.0.0)
- flutter_keyboard_visibility (0.0.1):
- Flutter
+ - flutter_local_notifications (0.0.1):
+ - Flutter
- flutter_native_splash (0.0.1):
- Flutter
- fluttertoast (0.0.2):
@@ -56,10 +58,13 @@ PODS:
- Flutter
- local_auth_ios (0.0.1):
- Flutter
+ - open_filex (0.0.2):
+ - Flutter
- package_info_plus (0.4.5):
- Flutter
- - path_provider_ios (0.0.1):
+ - path_provider_foundation (0.0.1):
- Flutter
+ - FlutterMacOS
- pdfx (1.0.0):
- Flutter
- permission_handler_apple (9.0.4):
@@ -72,8 +77,9 @@ PODS:
- SDWebImage/Core (5.13.5)
- share_plus (0.0.1):
- Flutter
- - shared_preferences_ios (0.0.1):
+ - shared_preferences_foundation (0.0.1):
- Flutter
+ - FlutterMacOS
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
@@ -90,17 +96,19 @@ DEPENDENCIES:
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
+ - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`)
+ - open_filex (from `.symlinks/plugins/open_filex/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
+ - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- pdfx (from `.symlinks/plugins/pdfx/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
+ - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
@@ -128,6 +136,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
+ flutter_local_notifications:
+ :path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
fluttertoast:
@@ -136,10 +146,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/integration_test/ios"
local_auth_ios:
:path: ".symlinks/plugins/local_auth_ios/ios"
+ open_filex:
+ :path: ".symlinks/plugins/open_filex/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
- path_provider_ios:
- :path: ".symlinks/plugins/path_provider_ios/ios"
+ path_provider_foundation:
+ :path: ".symlinks/plugins/path_provider_foundation/darwin"
pdfx:
:path: ".symlinks/plugins/pdfx/ios"
permission_handler_apple:
@@ -148,8 +160,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/receive_sharing_intent/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
- shared_preferences_ios:
- :path: ".symlinks/plugins/shared_preferences_ios/ios"
+ shared_preferences_foundation:
+ :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
url_launcher_ios:
@@ -160,28 +172,30 @@ SPEC CHECKSUMS:
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
- edge_detection: 9bc5ee35073b5a17c0b3b679908f01017ce3062a
- file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1
+ edge_detection: fa02aa120e00d87ada0ca2430b6c6087a501b1e9
+ file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
+ flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
- fluttertoast: 74526702fea2c060ea55dde75895b7e1bde1c86b
+ fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5
local_auth_ios: 0d333dde7780f669e66f19d2ff6005f3ea84008d
+ open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
- path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
+ path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
pdfx: 7b876b09de8b7a0bf444a4f82b439ffcff4ee1ec
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1
SDWebImage: 23d714cd599354ee7906dbae26dff89b421c4370
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
- shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
+ shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
- url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
+ url_launcher_ios: ae1517e5e344f5544fb090b079e11f399dfbe4d2
WeScan: fed582f6c38014d529afb5aa9ffd1bad38fc72b7
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 664648c..1653b15 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 51;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -321,10 +321,12 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
@@ -335,6 +337,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 6cb665f..a837d1a 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -65,5 +65,7 @@
CADisableMinimumFrameDurationOnPhone
-
+ UIApplicationSupportsIndirectInputEvents
+
+
diff --git a/lib/constants.dart b/lib/constants.dart
new file mode 100644
index 0000000..2a86892
--- /dev/null
+++ b/lib/constants.dart
@@ -0,0 +1,7 @@
+import 'package:device_info_plus/device_info_plus.dart';
+import 'package:package_info_plus/package_info_plus.dart';
+
+// Globally accessible variables which are definitely initialized after main().
+late final PackageInfo packageInfo;
+late final AndroidDeviceInfo? androidInfo;
+late final IosDeviceInfo? iosInfo;
diff --git a/lib/core/bloc/paperless_server_information_cubit.dart b/lib/core/bloc/paperless_server_information_cubit.dart
index 3c48eca..3067d8f 100644
--- a/lib/core/bloc/paperless_server_information_cubit.dart
+++ b/lib/core/bloc/paperless_server_information_cubit.dart
@@ -1,7 +1,6 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/bloc/paperless_server_information_state.dart';
-import 'package:paperless_mobile/core/security/session_manager.dart';
class PaperlessServerInformationCubit
extends Cubit {
diff --git a/lib/core/model/paperless_statistics_state.dart b/lib/core/model/paperless_statistics_state.dart
deleted file mode 100644
index 12fede2..0000000
--- a/lib/core/model/paperless_statistics_state.dart
+++ /dev/null
@@ -1,11 +0,0 @@
-import 'package:paperless_api/paperless_api.dart';
-
-class PaperlessStatisticsState {
- final bool isLoaded;
- final PaperlessServerStatisticsModel? statistics;
-
- PaperlessStatisticsState({
- required this.isLoaded,
- this.statistics,
- });
-}
diff --git a/lib/core/notifier/document_changed_notifier.dart b/lib/core/notifier/document_changed_notifier.dart
new file mode 100644
index 0000000..c53dedc
--- /dev/null
+++ b/lib/core/notifier/document_changed_notifier.dart
@@ -0,0 +1,54 @@
+import 'dart:async';
+import 'dart:developer';
+
+import 'package:flutter/foundation.dart';
+import 'package:paperless_api/paperless_api.dart';
+import 'package:rxdart/subjects.dart';
+
+typedef DocumentChangedCallback = void Function(DocumentModel document);
+
+class DocumentChangedNotifier {
+ final Subject _updated = PublishSubject();
+ final Subject _deleted = PublishSubject();
+
+ final Map> _subscribers = {};
+
+ void notifyUpdated(DocumentModel updated) {
+ debugPrint("Notifying updated document ${updated.id}");
+ _updated.add(updated);
+ }
+
+ void notifyDeleted(DocumentModel deleted) {
+ debugPrint("Notifying deleted document ${deleted.id}");
+ _deleted.add(deleted);
+ }
+
+ void subscribe(
+ dynamic subscriber, {
+ DocumentChangedCallback? onUpdated,
+ DocumentChangedCallback? onDeleted,
+ }) {
+ _subscribers.putIfAbsent(
+ subscriber,
+ () => [
+ _updated.listen((value) {
+ onUpdated?.call(value);
+ }),
+ _deleted.listen((value) {
+ onDeleted?.call(value);
+ }),
+ ],
+ );
+ }
+
+ void unsubscribe(dynamic subscriber) {
+ _subscribers[subscriber]?.forEach((element) {
+ element.cancel();
+ });
+ }
+
+ void close() {
+ _updated.close();
+ _deleted.close();
+ }
+}
diff --git a/lib/core/repository/base_repository.dart b/lib/core/repository/base_repository.dart
index f0c4589..1eb57c4 100644
--- a/lib/core/repository/base_repository.dart
+++ b/lib/core/repository/base_repository.dart
@@ -1,30 +1,30 @@
import 'package:hydrated_bloc/hydrated_bloc.dart';
-import 'package:paperless_mobile/core/repository/state/repository_state.dart';
+import 'package:paperless_mobile/core/repository/state/indexed_repository_state.dart';
import 'package:rxdart/subjects.dart';
///
/// Base repository class which all repositories should implement
///
-abstract class BaseRepository
- extends Cubit with HydratedMixin {
- final State _initialState;
+abstract class BaseRepository extends Cubit>
+ with HydratedMixin {
+ final IndexedRepositoryState _initialState;
BaseRepository(this._initialState) : super(_initialState) {
hydrate();
}
- Stream get values =>
+ Stream?> get values =>
BehaviorSubject.seeded(state)..addStream(super.stream);
- State? get current => state;
+ IndexedRepositoryState? get current => state;
bool get isInitialized => state.hasLoaded;
- Future create(Type object);
- Future find(int id);
- Future> findAll([Iterable? ids]);
- Future update(Type object);
- Future delete(Type object);
+ Future create(T object);
+ Future find(int id);
+ Future> findAll([Iterable? ids]);
+ Future update(T object);
+ Future delete(T object);
@override
Future clear() async {
diff --git a/lib/core/repository/impl/correspondent_repository_impl.dart b/lib/core/repository/impl/correspondent_repository_impl.dart
index 4b676ac..7227c58 100644
--- a/lib/core/repository/impl/correspondent_repository_impl.dart
+++ b/lib/core/repository/impl/correspondent_repository_impl.dart
@@ -3,10 +3,8 @@ import 'dart:async';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart';
-import 'package:paperless_mobile/core/repository/state/repository_state.dart';
-class CorrespondentRepositoryImpl
- extends LabelRepository {
+class CorrespondentRepositoryImpl extends LabelRepository {
final PaperlessLabelsApi _api;
CorrespondentRepositoryImpl(this._api)
@@ -15,7 +13,7 @@ class CorrespondentRepositoryImpl
@override
Future create(Correspondent correspondent) async {
final created = await _api.saveCorrespondent(correspondent);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..putIfAbsent(created.id!, () => created);
emit(CorrespondentRepositoryState(values: updatedState, hasLoaded: true));
return created;
@@ -24,7 +22,7 @@ class CorrespondentRepositoryImpl
@override
Future delete(Correspondent correspondent) async {
await _api.deleteCorrespondent(correspondent);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..removeWhere((k, v) => k == correspondent.id);
emit(CorrespondentRepositoryState(values: updatedState, hasLoaded: true));
return correspondent.id!;
@@ -34,7 +32,7 @@ class CorrespondentRepositoryImpl
Future find(int id) async {
final correspondent = await _api.getCorrespondent(id);
if (correspondent != null) {
- final updatedState = {...state.values}..[id] = correspondent;
+ final updatedState = {...state.values ?? {}}..[id] = correspondent;
emit(CorrespondentRepositoryState(values: updatedState, hasLoaded: true));
return correspondent;
}
@@ -44,7 +42,7 @@ class CorrespondentRepositoryImpl
@override
Future> findAll([Iterable? ids]) async {
final correspondents = await _api.getCorrespondents(ids);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..addEntries(correspondents.map((e) => MapEntry(e.id!, e)));
emit(CorrespondentRepositoryState(values: updatedState, hasLoaded: true));
return correspondents;
@@ -53,7 +51,8 @@ class CorrespondentRepositoryImpl
@override
Future update(Correspondent correspondent) async {
final updated = await _api.updateCorrespondent(correspondent);
- final updatedState = {...state.values}..update(updated.id!, (_) => updated);
+ final updatedState = {...state.values ?? {}}
+ ..update(updated.id!, (_) => updated);
emit(CorrespondentRepositoryState(values: updatedState, hasLoaded: true));
return updated;
}
@@ -64,7 +63,7 @@ class CorrespondentRepositoryImpl
}
@override
- Map toJson(CorrespondentRepositoryState state) {
+ Map toJson(covariant CorrespondentRepositoryState state) {
return state.toJson();
}
}
diff --git a/lib/core/repository/impl/document_type_repository_impl.dart b/lib/core/repository/impl/document_type_repository_impl.dart
index 1e1ae92..5fd7a87 100644
--- a/lib/core/repository/impl/document_type_repository_impl.dart
+++ b/lib/core/repository/impl/document_type_repository_impl.dart
@@ -1,10 +1,8 @@
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/core/repository/state/impl/document_type_repository_state.dart';
-import 'package:rxdart/rxdart.dart' show BehaviorSubject;
-class DocumentTypeRepositoryImpl
- extends LabelRepository {
+class DocumentTypeRepositoryImpl extends LabelRepository {
final PaperlessLabelsApi _api;
DocumentTypeRepositoryImpl(this._api)
@@ -13,7 +11,7 @@ class DocumentTypeRepositoryImpl
@override
Future create(DocumentType documentType) async {
final created = await _api.saveDocumentType(documentType);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..putIfAbsent(created.id!, () => created);
emit(DocumentTypeRepositoryState(values: updatedState, hasLoaded: true));
return created;
@@ -22,7 +20,7 @@ class DocumentTypeRepositoryImpl
@override
Future delete(DocumentType documentType) async {
await _api.deleteDocumentType(documentType);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..removeWhere((k, v) => k == documentType.id);
emit(DocumentTypeRepositoryState(values: updatedState, hasLoaded: true));
return documentType.id!;
@@ -32,7 +30,7 @@ class DocumentTypeRepositoryImpl
Future find(int id) async {
final documentType = await _api.getDocumentType(id);
if (documentType != null) {
- final updatedState = {...state.values}..[id] = documentType;
+ final updatedState = {...state.values ?? {}}..[id] = documentType;
emit(DocumentTypeRepositoryState(values: updatedState, hasLoaded: true));
return documentType;
}
@@ -42,7 +40,7 @@ class DocumentTypeRepositoryImpl
@override
Future> findAll([Iterable? ids]) async {
final documentTypes = await _api.getDocumentTypes(ids);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..addEntries(documentTypes.map((e) => MapEntry(e.id!, e)));
emit(DocumentTypeRepositoryState(values: updatedState, hasLoaded: true));
return documentTypes;
@@ -51,7 +49,8 @@ class DocumentTypeRepositoryImpl
@override
Future update(DocumentType documentType) async {
final updated = await _api.updateDocumentType(documentType);
- final updatedState = {...state.values}..update(updated.id!, (_) => updated);
+ final updatedState = {...state.values ?? {}}
+ ..update(updated.id!, (_) => updated);
emit(DocumentTypeRepositoryState(values: updatedState, hasLoaded: true));
return updated;
}
@@ -62,7 +61,7 @@ class DocumentTypeRepositoryImpl
}
@override
- Map toJson(DocumentTypeRepositoryState state) {
+ Map toJson(covariant DocumentTypeRepositoryState state) {
return state.toJson();
}
}
diff --git a/lib/core/repository/impl/saved_view_repository_impl.dart b/lib/core/repository/impl/saved_view_repository_impl.dart
index b5e03aa..18eceed 100644
--- a/lib/core/repository/impl/saved_view_repository_impl.dart
+++ b/lib/core/repository/impl/saved_view_repository_impl.dart
@@ -10,7 +10,7 @@ class SavedViewRepositoryImpl extends SavedViewRepository {
@override
Future create(SavedView object) async {
final created = await _api.save(object);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..putIfAbsent(created.id!, () => created);
emit(SavedViewRepositoryState(values: updatedState, hasLoaded: true));
return created;
@@ -19,7 +19,7 @@ class SavedViewRepositoryImpl extends SavedViewRepository {
@override
Future delete(SavedView view) async {
await _api.delete(view);
- final updatedState = {...state.values}..remove(view.id);
+ final updatedState = {...state.values ?? {}}..remove(view.id);
emit(SavedViewRepositoryState(values: updatedState, hasLoaded: true));
return view.id!;
}
@@ -27,7 +27,7 @@ class SavedViewRepositoryImpl extends SavedViewRepository {
@override
Future find(int id) async {
final found = await _api.find(id);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..update(id, (_) => found, ifAbsent: () => found);
emit(SavedViewRepositoryState(values: updatedState, hasLoaded: true));
return found;
@@ -37,7 +37,7 @@ class SavedViewRepositoryImpl extends SavedViewRepository {
Future> findAll([Iterable? ids]) async {
final found = await _api.findAll(ids);
final updatedState = {
- ...state.values,
+ ...state.values ?? {},
...{for (final view in found) view.id!: view},
};
emit(SavedViewRepositoryState(values: updatedState, hasLoaded: true));
@@ -56,7 +56,7 @@ class SavedViewRepositoryImpl extends SavedViewRepository {
}
@override
- Map toJson(SavedViewRepositoryState state) {
+ Map toJson(covariant SavedViewRepositoryState state) {
return state.toJson();
}
}
diff --git a/lib/core/repository/impl/storage_path_repository_impl.dart b/lib/core/repository/impl/storage_path_repository_impl.dart
index b738827..1fb54ea 100644
--- a/lib/core/repository/impl/storage_path_repository_impl.dart
+++ b/lib/core/repository/impl/storage_path_repository_impl.dart
@@ -3,8 +3,7 @@ import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/core/repository/state/impl/storage_path_repository_state.dart';
import 'package:rxdart/rxdart.dart' show BehaviorSubject;
-class StoragePathRepositoryImpl
- extends LabelRepository {
+class StoragePathRepositoryImpl extends LabelRepository {
final PaperlessLabelsApi _api;
StoragePathRepositoryImpl(this._api)
@@ -13,7 +12,7 @@ class StoragePathRepositoryImpl
@override
Future create(StoragePath storagePath) async {
final created = await _api.saveStoragePath(storagePath);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..putIfAbsent(created.id!, () => created);
emit(StoragePathRepositoryState(values: updatedState, hasLoaded: true));
return created;
@@ -22,7 +21,7 @@ class StoragePathRepositoryImpl
@override
Future delete(StoragePath storagePath) async {
await _api.deleteStoragePath(storagePath);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..removeWhere((k, v) => k == storagePath.id);
emit(StoragePathRepositoryState(values: updatedState, hasLoaded: true));
return storagePath.id!;
@@ -32,7 +31,7 @@ class StoragePathRepositoryImpl
Future find(int id) async {
final storagePath = await _api.getStoragePath(id);
if (storagePath != null) {
- final updatedState = {...state.values}..[id] = storagePath;
+ final updatedState = {...state.values ?? {}}..[id] = storagePath;
emit(StoragePathRepositoryState(values: updatedState, hasLoaded: true));
return storagePath;
}
@@ -42,7 +41,7 @@ class StoragePathRepositoryImpl
@override
Future> findAll([Iterable? ids]) async {
final storagePaths = await _api.getStoragePaths(ids);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..addEntries(storagePaths.map((e) => MapEntry(e.id!, e)));
emit(StoragePathRepositoryState(values: updatedState, hasLoaded: true));
return storagePaths;
@@ -51,7 +50,8 @@ class StoragePathRepositoryImpl
@override
Future update(StoragePath storagePath) async {
final updated = await _api.updateStoragePath(storagePath);
- final updatedState = {...state.values}..update(updated.id!, (_) => updated);
+ final updatedState = {...state.values ?? {}}
+ ..update(updated.id!, (_) => updated);
emit(StoragePathRepositoryState(values: updatedState, hasLoaded: true));
return updated;
}
@@ -62,7 +62,7 @@ class StoragePathRepositoryImpl
}
@override
- Map toJson(StoragePathRepositoryState state) {
+ Map toJson(covariant StoragePathRepositoryState state) {
return state.toJson();
}
}
diff --git a/lib/core/repository/impl/tag_repository_impl.dart b/lib/core/repository/impl/tag_repository_impl.dart
index 09f6061..a39a77b 100644
--- a/lib/core/repository/impl/tag_repository_impl.dart
+++ b/lib/core/repository/impl/tag_repository_impl.dart
@@ -1,10 +1,8 @@
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
-import 'package:paperless_mobile/core/repository/state/impl/correspondent_repository_state.dart';
import 'package:paperless_mobile/core/repository/state/impl/tag_repository_state.dart';
-import 'package:paperless_mobile/core/repository/state/repository_state.dart';
-class TagRepositoryImpl extends LabelRepository {
+class TagRepositoryImpl extends LabelRepository {
final PaperlessLabelsApi _api;
TagRepositoryImpl(this._api) : super(const TagRepositoryState());
@@ -12,7 +10,7 @@ class TagRepositoryImpl extends LabelRepository {
@override
Future create(Tag object) async {
final created = await _api.saveTag(object);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..putIfAbsent(created.id!, () => created);
emit(TagRepositoryState(values: updatedState, hasLoaded: true));
return created;
@@ -21,7 +19,8 @@ class TagRepositoryImpl extends LabelRepository {
@override
Future delete(Tag tag) async {
await _api.deleteTag(tag);
- final updatedState = {...state.values}..removeWhere((k, v) => k == tag.id);
+ final updatedState = {...state.values ?? {}}
+ ..removeWhere((k, v) => k == tag.id);
emit(TagRepositoryState(values: updatedState, hasLoaded: true));
return tag.id!;
}
@@ -30,7 +29,7 @@ class TagRepositoryImpl extends LabelRepository {
Future find(int id) async {
final tag = await _api.getTag(id);
if (tag != null) {
- final updatedState = {...state.values}..[id] = tag;
+ final updatedState = {...state.values ?? {}}..[id] = tag;
emit(TagRepositoryState(values: updatedState, hasLoaded: true));
return tag;
}
@@ -40,7 +39,7 @@ class TagRepositoryImpl extends LabelRepository {
@override
Future> findAll([Iterable? ids]) async {
final tags = await _api.getTags(ids);
- final updatedState = {...state.values}
+ final updatedState = {...state.values ?? {}}
..addEntries(tags.map((e) => MapEntry(e.id!, e)));
emit(TagRepositoryState(values: updatedState, hasLoaded: true));
return tags;
@@ -49,7 +48,8 @@ class TagRepositoryImpl extends LabelRepository {
@override
Future update(Tag tag) async {
final updated = await _api.updateTag(tag);
- final updatedState = {...state.values}..update(updated.id!, (_) => updated);
+ final updatedState = {...state.values ?? {}}
+ ..update(updated.id!, (_) => updated);
emit(TagRepositoryState(values: updatedState, hasLoaded: true));
return updated;
}
@@ -60,7 +60,7 @@ class TagRepositoryImpl extends LabelRepository {
}
@override
- Map? toJson(TagRepositoryState state) {
+ Map? toJson(covariant TagRepositoryState state) {
return state.toJson();
}
}
diff --git a/lib/core/repository/label_repository.dart b/lib/core/repository/label_repository.dart
index c2aa3bc..8fe3458 100644
--- a/lib/core/repository/label_repository.dart
+++ b/lib/core/repository/label_repository.dart
@@ -1,8 +1,7 @@
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/base_repository.dart';
-import 'package:paperless_mobile/core/repository/state/repository_state.dart';
+import 'package:paperless_mobile/core/repository/state/indexed_repository_state.dart';
-abstract class LabelRepository
- extends BaseRepository {
- LabelRepository(State initial) : super(initial);
+abstract class LabelRepository extends BaseRepository {
+ LabelRepository(IndexedRepositoryState initial) : super(initial);
}
diff --git a/lib/core/repository/provider/label_repositories_provider.dart b/lib/core/repository/provider/label_repositories_provider.dart
index d45c792..e9634be 100644
--- a/lib/core/repository/provider/label_repositories_provider.dart
+++ b/lib/core/repository/provider/label_repositories_provider.dart
@@ -17,20 +17,16 @@ class LabelRepositoriesProvider extends StatelessWidget {
return MultiRepositoryProvider(
providers: [
RepositoryProvider(
- create: (context) => context.read<
- LabelRepository>(),
+ create: (context) => context.read>(),
),
RepositoryProvider(
- create: (context) => context.read<
- LabelRepository>(),
+ create: (context) => context.read>(),
),
RepositoryProvider(
- create: (context) => context
- .read>(),
+ create: (context) => context.read>(),
),
RepositoryProvider(
- create: (context) =>
- context.read>(),
+ create: (context) => context.read>(),
),
],
child: child,
diff --git a/lib/core/repository/saved_view_repository.dart b/lib/core/repository/saved_view_repository.dart
index 644f367..bb1c4e3 100644
--- a/lib/core/repository/saved_view_repository.dart
+++ b/lib/core/repository/saved_view_repository.dart
@@ -1,8 +1,8 @@
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/base_repository.dart';
import 'package:paperless_mobile/core/repository/state/impl/saved_view_repository_state.dart';
+import 'package:paperless_mobile/core/repository/state/indexed_repository_state.dart';
-abstract class SavedViewRepository
- extends BaseRepository {
+abstract class SavedViewRepository extends BaseRepository {
SavedViewRepository(super.initialState);
}
diff --git a/lib/core/repository/state/impl/correspondent_repository_state.dart b/lib/core/repository/state/impl/correspondent_repository_state.dart
index 5fb88ee..fce9efb 100644
--- a/lib/core/repository/state/impl/correspondent_repository_state.dart
+++ b/lib/core/repository/state/impl/correspondent_repository_state.dart
@@ -1,13 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:paperless_api/paperless_api.dart';
-import 'package:paperless_mobile/core/repository/state/repository_state.dart';
+import 'package:paperless_mobile/core/repository/state/indexed_repository_state.dart';
part 'correspondent_repository_state.g.dart';
@JsonSerializable()
class CorrespondentRepositoryState
- extends RepositoryState