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