3 Commits

View File

@@ -550,11 +550,10 @@ class MainPageState extends State<MainPage> with WindowListener {
final scratch = await getLatestScratch(); final scratch = await getLatestScratch();
_scratchController.text = scratch?.content ?? ""; _scratchController.text = scratch?.content ?? "";
_currentEntryController.text = "";
await _checkNavigation(); await _checkNavigation();
debugPrint("Data loaded."); debugPrint("Data loaded");
} }
// Load volume setting from database // Load volume setting from database
@@ -586,6 +585,7 @@ class MainPageState extends State<MainPage> with WindowListener {
// Handle current entry // Handle current entry
if (currentEntry.isNotEmpty) { if (currentEntry.isNotEmpty) {
await createNote(currentEntry); await createNote(currentEntry);
_currentEntryController.clear(); // Clear the input field after saving
} }
// Handle scratch pad // Handle scratch pad
@@ -755,6 +755,9 @@ class MainPageState extends State<MainPage> with WindowListener {
.where((note) => note.content.isNotEmpty) .where((note) => note.content.isNotEmpty)
.toList(); .toList();
// Sort by date, newest first
filteredResults.sort((a, b) => b.date.compareTo(a.date));
// Important: update the dialog state after search completes // Important: update the dialog state after search completes
dialogSetState(() { dialogSetState(() {
_searchResults = filteredResults; _searchResults = filteredResults;