Track original scratch content to only write scratch when modified

This commit is contained in:
2025-05-25 10:11:35 +02:00
parent 27f21a23fe
commit 188619478e

View File

@@ -313,6 +313,7 @@ class MainPageState extends State<MainPage> with WindowListener {
Note? _currentlyDisplayedNote;
Duration _currentPopupInterval = _defaultPopupInterval;
String _currentNotificationSound = _defaultNotificationSound;
String? _originalScratchContent; // Track original scratch content
bool _canGoPrevious = false;
bool _canGoNext = false;
@@ -562,6 +563,7 @@ class MainPageState extends State<MainPage> with WindowListener {
final scratch = await getLatestScratch();
_scratchController.text = scratch?.content ?? "";
_originalScratchContent = scratch?.content; // Store original content
await _checkNavigation();
@@ -596,9 +598,10 @@ class MainPageState extends State<MainPage> with WindowListener {
_currentEntryController.clear(); // Clear the input field after saving
}
if (scratchContent != _scratchController.text) {
// Was modified
// Only create new scratch if content has changed
if (scratchContent != _originalScratchContent) {
await createScratch(scratchContent);
_originalScratchContent = scratchContent; // Update original content
}
// Handle previous/currently displayed note