mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 12:07:54 -06:00
feat: Externalize settings into LocalUserAppState, fix bugs
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/user_settings.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/local_user_settings.dart';
|
||||
|
||||
part 'user_account.g.dart';
|
||||
part 'local_user_account.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.userAccount)
|
||||
class UserAccount extends HiveObject {
|
||||
@HiveType(typeId: HiveTypeIds.localUserAccount)
|
||||
class LocalUserAccount extends HiveObject {
|
||||
@HiveField(0)
|
||||
final String serverUrl;
|
||||
|
||||
@@ -19,9 +19,9 @@ class UserAccount extends HiveObject {
|
||||
final String id;
|
||||
|
||||
@HiveField(4)
|
||||
UserSettings settings;
|
||||
LocalUserSettings settings;
|
||||
|
||||
UserAccount({
|
||||
LocalUserAccount({
|
||||
required this.id,
|
||||
required this.serverUrl,
|
||||
required this.username,
|
||||
40
lib/core/database/tables/local_user_app_state.dart
Normal file
40
lib/core/database/tables/local_user_app_state.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
import 'package:paperless_mobile/features/settings/model/view_type.dart';
|
||||
|
||||
part 'local_user_app_state.g.dart';
|
||||
|
||||
///
|
||||
/// Object used for the persistence of app state, e.g. set filters,
|
||||
/// search history and implicit settings.
|
||||
///
|
||||
@HiveType(typeId: HiveTypeIds.localUserAppState)
|
||||
class LocalUserAppState extends HiveObject {
|
||||
@HiveField(0)
|
||||
final String userId;
|
||||
|
||||
@HiveField(1)
|
||||
DocumentFilter currentDocumentFilter;
|
||||
|
||||
@HiveField(2)
|
||||
List<String> documentSearchHistory;
|
||||
|
||||
@HiveField(3)
|
||||
ViewType documentsPageViewType;
|
||||
|
||||
@HiveField(4)
|
||||
ViewType savedViewsViewType;
|
||||
|
||||
@HiveField(5)
|
||||
ViewType documentSearchViewType;
|
||||
|
||||
LocalUserAppState({
|
||||
required this.userId,
|
||||
this.currentDocumentFilter = const DocumentFilter(),
|
||||
this.documentSearchHistory = const [],
|
||||
this.documentsPageViewType = ViewType.list,
|
||||
this.documentSearchViewType = ViewType.list,
|
||||
this.savedViewsViewType = ViewType.list,
|
||||
});
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
|
||||
part 'user_settings.g.dart';
|
||||
part 'local_user_settings.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.userSettings)
|
||||
class UserSettings with HiveObjectMixin {
|
||||
@HiveType(typeId: HiveTypeIds.localUserSettings)
|
||||
class LocalUserSettings with HiveObjectMixin {
|
||||
@HiveField(0)
|
||||
bool isBiometricAuthenticationEnabled;
|
||||
|
||||
UserSettings({
|
||||
LocalUserSettings({
|
||||
this.isBiometricAuthenticationEnabled = false,
|
||||
});
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
part 'user_app_state.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.userAppState)
|
||||
class UserAppState extends HiveObject {
|
||||
@HiveField(0)
|
||||
final String userId;
|
||||
|
||||
@HiveField(1)
|
||||
DocumentFilter currentDocumentFilter;
|
||||
|
||||
@HiveField(2)
|
||||
List<String> documentSearchHistory;
|
||||
|
||||
UserAppState({
|
||||
required this.userId,
|
||||
this.currentDocumentFilter = const DocumentFilter(),
|
||||
this.documentSearchHistory = const [],
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import 'package:paperless_mobile/features/login/model/client_certificate.dart';
|
||||
|
||||
part 'user_credentials.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.userCredentials)
|
||||
@HiveType(typeId: HiveTypeIds.localUserCredentials)
|
||||
class UserCredentials extends HiveObject {
|
||||
@HiveField(0)
|
||||
final String token;
|
||||
|
||||
Reference in New Issue
Block a user