Merge branch 'development' into feature/notes

This commit is contained in:
Anton Stubenbord
2023-12-16 16:34:36 +01:00
13 changed files with 125 additions and 29 deletions

View File

@@ -42,8 +42,7 @@
</div>
## Important Notes
* ⚠️ This project is under **very active** development.
* ⚠️ Breaking changes **are still expected** between updates! Please perform a clean install after updating the app before filing an issue or leaving a 1-Star review in the App-Stores!**
* ⚠️ Breaking changes **are still expected** between updates! Please perform a **clean instal** after updating the app before filing an issue or leaving a 1-star review in the App-Store!
<!-- ABOUT THE PROJECT -->
## About The Project

View File

@@ -103,7 +103,9 @@ android.applicationVariants.all { variant ->
def abiName = output.getFilter(OutputFile.ABI)
def abiVersionCode = project.ext.abiCodes.get(abiName)
if (abiVersionCode != null) {
output.versionCodeOverride = variant.versionCode * 10 + abiVersionCode
output.versionCodeOverride = abiVersionCode * 1000 + variant.versionCode
println(abiName + ": " + output.versionCodeOverride)
// output.versionCodeOverride = variant.versionCode * 10 + abiVersionCode
}
}
}

View File

@@ -0,0 +1,2 @@
* Beheben eines Fehlers, durch welchen Tags nach Bearbeitung eines Dokumentes nicht mehr gefunden wurden
* Aktualisieren der F-Droid Konfiguration

View File

@@ -0,0 +1,2 @@
* Fixed a bug where tags cannot be found after editing a document
* Update F-Droid configuration

View File

@@ -1 +0,0 @@
../../android/fastlane/metadata

1
fastlane/metadata Symbolic link
View File

@@ -0,0 +1 @@
../android/fastlane/metadata

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/features/logging/data/logger.dart';
class LabelRepository extends ChangeNotifier {
final PaperlessLabelsApi _api;
@@ -57,8 +58,29 @@ class LabelRepository extends ChangeNotifier {
}
Future<Iterable<Tag>> findAllTags([Iterable<int>? ids]) async {
logger.fd(
"Loading ${ids?.isEmpty ?? true ? "all" : "a subset of"} tags"
"${ids?.isEmpty ?? true ? "" : " (${ids!.join(",")})"}...",
className: runtimeType.toString(),
methodName: "findAllTags",
);
final data = await _api.getTags(ids);
tags = {for (var tag in data) tag.id!: tag};
if (ids?.isNotEmpty ?? false) {
logger.fd(
"Successfully updated subset of tags: ${ids!.join(",")}",
className: runtimeType.toString(),
methodName: "findAllTags",
);
// Only update the tags that were requested, keep existing ones.
tags = {...tags, for (var tag in data) tag.id!: tag};
} else {
logger.fd(
"Successfully updated all tags.",
className: runtimeType.toString(),
methodName: "findAllTags",
);
tags = {for (var tag in data) tag.id!: tag};
}
notifyListeners();
return data;
}

View File

@@ -63,6 +63,7 @@ class ChangelogDialog extends StatelessWidget {
}
const _versionNumbers = {
"59": "3.1.5",
"58": "3.1.4",
"57": "3.1.3",
"56": "3.1.2",

View File

@@ -5,6 +5,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/notifier/document_changed_notifier.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/features/logging/data/logger.dart';
part 'document_edit_state.dart';
part 'document_edit_cubit.freezed.dart';
@@ -25,37 +26,91 @@ class DocumentEditCubit extends Cubit<DocumentEditState> {
_notifier.addListener(
this,
onUpdated: (doc) {
emit(state.copyWith(document: doc));
emit(state.copyWith(
document: doc,
suggestions: null,
));
loadFieldSuggestions();
},
ids: [document.id],
);
}
Future<void> updateDocument(DocumentModel document) async {
logger.fi(
"Updating document ${document.id}...",
className: runtimeType.toString(),
methodName: "updateDocument",
);
final updated = await _docsApi.update(document);
logger.fi(
"Document ${document.id} successfully updated.",
className: runtimeType.toString(),
methodName: "updateDocument",
);
_notifier.notifyUpdated(updated);
// Reload changed labels (documentCount property changes with removal/add)
if (document.documentType != _initialDocument.documentType) {
logger.fd(
"Document type assigned to document ${document.id} has changed "
"(${_initialDocument.documentType} -> ${document.documentType}). "
"Reloading document type ${document.documentType}...",
className: runtimeType.toString(),
methodName: "updateDocument",
);
_labelRepository.findDocumentType(
(document.documentType ?? _initialDocument.documentType)!);
(document.documentType ?? _initialDocument.documentType)!,
);
}
if (document.correspondent != _initialDocument.correspondent) {
logger.fd(
"Correspondent assigned to document ${document.id} has changed "
"(${_initialDocument.correspondent} -> ${document.correspondent}). "
"Reloading correspondent ${document.correspondent}...",
className: runtimeType.toString(),
methodName: "updateDocument",
);
_labelRepository.findCorrespondent(
(document.correspondent ?? _initialDocument.correspondent)!);
}
if (document.storagePath != _initialDocument.storagePath) {
logger.fd(
"Storage path assigned to document ${document.id} has changed "
"(${_initialDocument.storagePath} -> ${document.storagePath}). "
"Reloading storage path ${document.storagePath}...",
className: runtimeType.toString(),
methodName: "updateDocument",
);
_labelRepository.findStoragePath(
(document.storagePath ?? _initialDocument.storagePath)!);
}
if (!const DeepCollectionEquality.unordered()
.equals(document.tags, _initialDocument.tags)) {
_labelRepository.findAllTags(document.tags);
.equals(document.tags.toList(), _initialDocument.tags.toList())) {
final tagsToReload = {...document.tags, ..._initialDocument.tags};
logger.fd(
"Tags assigned to document ${document.id} have changed "
"(${_initialDocument.tags.join(",")} -> ${document.tags.join(",")}). "
"Reloading tags ${tagsToReload.join(",")}...",
className: runtimeType.toString(),
methodName: "updateDocument",
);
_labelRepository.findAllTags(tagsToReload);
}
}
Future<void> loadFieldSuggestions() async {
logger.fi(
"Loading suggestions for document ${state.document.id}...",
className: runtimeType.toString(),
methodName: "loadFieldSuggestions",
);
final suggestions = await _docsApi.findSuggestions(state.document);
logger.fi(
"Found ${suggestions.suggestionsCount} suggestions for document ${state.document.id}.",
className: runtimeType.toString(),
methodName: "loadFieldSuggestions",
);
emit(state.copyWith(suggestions: suggestions));
}

View File

@@ -183,8 +183,12 @@ class _DocumentEditPageState extends State<DocumentEditPage>
);
}
Padding _buildEditForm(BuildContext context, DocumentEditState state,
FieldSuggestions? filteredSuggestions, UserModel currentUser) {
Padding _buildEditForm(
BuildContext context,
DocumentEditState state,
FieldSuggestions? filteredSuggestions,
UserModel currentUser,
) {
final labelRepository = context.watch<LabelRepository>();
return Padding(

View File

@@ -105,14 +105,18 @@ class _DocumentViewState extends State<DocumentView> {
body: PdfView(
controller: _controller,
onDocumentLoaded: (document) {
setState(() {
_totalPages = document.pagesCount;
});
if (mounted) {
setState(() {
_totalPages = document.pagesCount;
});
}
},
onPageChanged: (page) {
setState(() {
_currentPage = page;
});
if (mounted) {
setState(() {
_currentPage = page;
});
}
},
),
);

View File

@@ -10,16 +10,16 @@ class LabelCubit extends Cubit<LabelState> {
final LabelRepository labelRepository;
LabelCubit(this.labelRepository) : super(const LabelState()) {
labelRepository.addListener(
() {
emit(state.copyWith(
correspondents: labelRepository.correspondents,
documentTypes: labelRepository.documentTypes,
storagePaths: labelRepository.storagePaths,
tags: labelRepository.tags,
));
},
);
labelRepository.addListener(_updateStateListener);
}
void _updateStateListener() {
emit(state.copyWith(
correspondents: labelRepository.correspondents,
documentTypes: labelRepository.documentTypes,
storagePaths: labelRepository.storagePaths,
tags: labelRepository.tags,
));
}
Future<void> reload({
@@ -130,6 +130,7 @@ class LabelCubit extends Cubit<LabelState> {
@override
Future<void> close() {
labelRepository.removeListener(_updateStateListener);
return super.close();
}
}

View File

@@ -117,8 +117,12 @@ class TagsFormField extends StatelessWidget {
scrollDirection: Axis.horizontal,
itemCount: displayedSuggestions.length,
itemBuilder: (context, index) {
print(options);
final suggestion =
options[displayedSuggestions.elementAt(index)]!;
options[displayedSuggestions.elementAt(index)];
if (suggestion == null) {
return SizedBox.shrink();
}
return ColoredChipWrapper(
child: ActionChip(
label: Text(suggestion.name),

View File

@@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.1.4+58
version: 3.1.5+59
environment:
sdk: ">=3.1.0 <4.0.0"