From de3eeaf3f682ec795703220913d74bd5d1eb1501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Chiotti?= <44336112+maelchiotti@users.noreply.github.com> Date: Sat, 4 Oct 2025 22:15:13 +0200 Subject: [PATCH 1/6] [455] fix: auto delete corrupted notes and avoid importing them --- lib/models/note/note.dart | 1 + lib/models/note/types/rich_text_note.dart | 14 ++++++++++-- lib/services/backup/backup_service.dart | 27 +++++++++++++++++------ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lib/models/note/note.dart b/lib/models/note/note.dart index 90e5c33a..8b655eaf 100644 --- a/lib/models/note/note.dart +++ b/lib/models/note/note.dart @@ -11,6 +11,7 @@ import '../../../common/constants/constants.dart'; import '../../common/files/encryption_utils.dart'; import '../../common/preferences/enums/sort_method.dart'; import '../../common/preferences/preference_key.dart'; +import '../../services/notes/notes_service.dart'; import '../label/label.dart'; import 'note_status.dart'; import 'types/note_type.dart'; diff --git a/lib/models/note/types/rich_text_note.dart b/lib/models/note/types/rich_text_note.dart index 1a803e9c..1447ee6e 100644 --- a/lib/models/note/types/rich_text_note.dart +++ b/lib/models/note/types/rich_text_note.dart @@ -72,7 +72,7 @@ class RichTextNote extends Note { encryptionPassword != null ? EncryptionUtils().decrypt(encryptionPassword, contentAsJson) : contentAsJson, ); ParchmentDocument.fromJson(content); - } on Exception { + } catch (_) { return false; } @@ -81,7 +81,17 @@ class RichTextNote extends Note { /// Document containing the fleather content representation. @ignore - ParchmentDocument get document => ParchmentDocument.fromJson(jsonDecode(content) as List); + ParchmentDocument get document { + try { + return ParchmentDocument.fromJson(jsonDecode(content) as List); + } catch (exception, stackTrace) { + logger.e('Failed to decode the content of a rich text note, deleting it.', exception, stackTrace); + + NotesService().delete(this); + + return ParchmentDocument(); + } + } @ignore @override diff --git a/lib/services/backup/backup_service.dart b/lib/services/backup/backup_service.dart index dd77171e..4e3415f7 100644 --- a/lib/services/backup/backup_service.dart +++ b/lib/services/backup/backup_service.dart @@ -157,12 +157,11 @@ class ManualBackupService { // If the note type is null, it's an export from before v2.0.0 when only rich text notes were available if (noteType == null) { - if (RichTextNote.isFleatherData(noteAsJson['content'] as String)) { - notes.add(RichTextNote.fromJson(noteAsJson)); - } else { - logger.w('Imported a note without a type as a plain text note because its content is not fleather data'); - notes.add(PlainTextNote.fromJson(noteAsJson)); - } + _addRichTextNote( + noteAsJson, + notes, + 'Imported a note without a type as a plain text note because its content is not fleather data', + ); } else { switch (noteType) { case NoteType.plainText: @@ -170,7 +169,11 @@ class ManualBackupService { case NoteType.markdown: notes.add(MarkdownNote.fromJson(noteAsJson)); case NoteType.richText: - notes.add(RichTextNote.fromJson(noteAsJson)); + _addRichTextNote( + noteAsJson, + notes, + 'Imported a rich text note as a plain text note because its content is not fleather data', + ); case NoteType.checklist: notes.add(ChecklistNote.fromJson(noteAsJson)); } @@ -199,6 +202,16 @@ class ManualBackupService { return true; } + void _addRichTextNote(dynamic noteAsJson, List notes, String warningMessage) { + if (RichTextNote.isFleatherData(noteAsJson['content'] as String)) { + notes.add(RichTextNote.fromJson(noteAsJson)); + } else { + logger.w(warningMessage); + + notes.add(PlainTextNote.fromJson(noteAsJson)); + } + } + Future _importPreferences(dynamic importedJson) async { final preferencesAndValues = importedJson['preferences'] as Map; From 36f472df4c49bf4f68d898332282cfd64e847bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Chiotti?= <44336112+maelchiotti@users.noreply.github.com> Date: Sat, 4 Oct 2025 22:17:44 +0200 Subject: [PATCH 2/6] [455] fix: auto delete corrupted notes and avoid importing them --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 328e233f..b29e8a50 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: localmaterialnotes description: Simple, local, material design notes repository: https://github.com/maelchiotti/LocalMaterialNotes -version: 2.1.1+30 +version: 2.1.1+31 publish_to: none # TODO(maelchiotti): move back to the stable branch when native assets are released From 9fb5745ce0ab9fd491f5b97452ca1279b0784d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Chiotti?= <44336112+maelchiotti@users.noreply.github.com> Date: Sat, 4 Oct 2025 22:42:09 +0200 Subject: [PATCH 3/6] [455] chore: use fvm --- .fvmrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .fvmrc diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 00000000..3cb9a9b8 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "beta" +} \ No newline at end of file From 3e4534ece95de395514b442a2591477531c04a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Chiotti?= <44336112+maelchiotti@users.noreply.github.com> Date: Sun, 5 Oct 2025 17:23:29 +0200 Subject: [PATCH 4/6] [455] chore: use fvm --- pubspec.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 86e3d898..bdec9a77 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -921,10 +921,10 @@ packages: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.16.0" mime: dependency: transitive description: @@ -1511,26 +1511,26 @@ packages: dependency: transitive description: name: test - sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb" url: "https://pub.dev" source: hosted - version: "1.26.3" + version: "1.26.2" test_api: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.6" test_core: dependency: transitive description: name: test_core - sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" + sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a" url: "https://pub.dev" source: hosted - version: "0.6.12" + version: "0.6.11" time: dependency: transitive description: From 99271ed3ad801453a3dcfe0b24f624fb54188464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Chiotti?= <44336112+maelchiotti@users.noreply.github.com> Date: Mon, 20 Oct 2025 18:47:34 +0200 Subject: [PATCH 5/6] [455] chore: replace receive_sharing_intent with listen_sharing_intent --- lib/common/system_utils.dart | 2 +- pubspec.lock | 33 ++++++++++++++++----------------- pubspec.yaml | 5 +---- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/common/system_utils.dart b/lib/common/system_utils.dart index 908a28e0..81af8d5a 100644 --- a/lib/common/system_utils.dart +++ b/lib/common/system_utils.dart @@ -5,10 +5,10 @@ import 'package:device_info_plus/device_info_plus.dart'; import 'package:flag_secure/flag_secure.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:listen_sharing_intent/listen_sharing_intent.dart'; import 'package:local_auth/local_auth.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:quick_actions/quick_actions.dart'; -import 'package:receive_sharing_intent/receive_sharing_intent.dart'; import '../l10n/app_localizations/app_localizations.g.dart'; import '../models/note/types/note_type.dart'; diff --git a/pubspec.lock b/pubspec.lock index bdec9a77..2aac5a1a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -821,6 +821,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.0" + listen_sharing_intent: + dependency: "direct main" + description: + name: listen_sharing_intent + sha256: df12e6c78666018985c39df494fc12412ece6510c38c79fe1230f2abef0965fa + url: "https://pub.dev" + source: hosted + version: "1.9.2" local_auth: dependency: "direct main" description: @@ -921,10 +929,10 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" mime: dependency: transitive description: @@ -1173,15 +1181,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.2" - receive_sharing_intent: - dependency: "direct main" - description: - path: "." - ref: "2cea396843cd3ab1b5ec4334be4233864637874e" - resolved-ref: "2cea396843cd3ab1b5ec4334be4233864637874e" - url: "https://github.com/KasemJaffer/receive_sharing_intent" - source: git - version: "1.8.1" remove_markdown: dependency: "direct main" description: @@ -1511,26 +1510,26 @@ packages: dependency: transitive description: name: test - sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb" + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" url: "https://pub.dev" source: hosted - version: "1.26.2" + version: "1.26.3" test_api: dependency: transitive description: name: test_api - sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 url: "https://pub.dev" source: hosted - version: "0.7.6" + version: "0.7.7" test_core: dependency: transitive description: name: test_core - sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a" + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" url: "https://pub.dev" source: hosted - version: "0.6.11" + version: "0.6.12" time: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b29e8a50..6db499f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,6 +45,7 @@ dependencies: isar_community: ^3.3.0-dev.3 isar_community_flutter_libs: ^3.3.0-dev.3 json_annotation: ^4.9.0 + listen_sharing_intent: ^1.9.2 local_auth: ^3.0.0 locale_names: ^1.1.1 logger: ^2.6.2 @@ -57,10 +58,6 @@ dependencies: path: ^1.9.1 path_provider: ^2.1.5 quick_actions: ^1.1.0 - receive_sharing_intent: # TODO: change when the fix is released - git: - url: https://github.com/KasemJaffer/receive_sharing_intent - ref: 2cea396843cd3ab1b5ec4334be4233864637874e remove_markdown: ^0.0.2 restart_app: ^1.3.2 riverpod_annotation: ^3.0.3 From ca5fbb91c0db3f2d98060a6ade0dd7b41f247ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Chiotti?= <44336112+maelchiotti@users.noreply.github.com> Date: Mon, 20 Oct 2025 18:57:59 +0200 Subject: [PATCH 6/6] [455] chore: replace receive_sharing_intent with listen_sharing_intent --- .run/Generate localizations.run.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.run/Generate localizations.run.xml b/.run/Generate localizations.run.xml index c7929fab..45f6d16d 100644 --- a/.run/Generate localizations.run.xml +++ b/.run/Generate localizations.run.xml @@ -1,6 +1,6 @@ -