Rework everything to use meilisearch
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:flutter/gestures.dart';
|
||||
import 'dart:math';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:ps_list/ps_list.dart';
|
||||
import 'package:journaler/meilisearch.dart';
|
||||
|
||||
// TODO: Sound does not play when ran from a different workdir? Weird
|
||||
// TODO: Fix saving the same scratch over and over again
|
||||
@@ -481,7 +482,7 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final prev = await getPreviousNote(_currentlyDisplayedNote!.date);
|
||||
final prev = await getPreviousTo(_currentlyDisplayedNote!.date);
|
||||
final bool isLatest = _currentlyDisplayedNote!.date == previousNote?.date;
|
||||
|
||||
setState(() {
|
||||
@@ -496,10 +497,10 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
// Save the current note content before navigating away
|
||||
if (_currentlyDisplayedNote != null) {
|
||||
_currentlyDisplayedNote!.content = _previousEntryController.text;
|
||||
await updateNote(_currentlyDisplayedNote!);
|
||||
await updateNote(_currentlyDisplayedNote!.date, _currentlyDisplayedNote!.content);
|
||||
}
|
||||
|
||||
final prevNote = await getPreviousNote(_currentlyDisplayedNote!.date);
|
||||
final prevNote = await getPreviousTo(_currentlyDisplayedNote!.date);
|
||||
if (prevNote != null) {
|
||||
setState(() {
|
||||
_currentlyDisplayedNote = prevNote;
|
||||
@@ -515,10 +516,10 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
// Save the current note content before navigating away
|
||||
if (_currentlyDisplayedNote != null) {
|
||||
_currentlyDisplayedNote!.content = _previousEntryController.text;
|
||||
await updateNote(_currentlyDisplayedNote!);
|
||||
await updateNote(_currentlyDisplayedNote!.date, _currentlyDisplayedNote!.content);
|
||||
}
|
||||
|
||||
final nextNote = await getNextNote(_currentlyDisplayedNote!.date);
|
||||
final nextNote = await getNextTo(_currentlyDisplayedNote!.date);
|
||||
if (nextNote != null) {
|
||||
setState(() {
|
||||
_currentlyDisplayedNote = nextNote;
|
||||
@@ -543,7 +544,7 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
|
||||
_startPopupTimer();
|
||||
|
||||
final note = await getLatestNote();
|
||||
final note = await getLatest();
|
||||
previousNote = note;
|
||||
_currentlyDisplayedNote = note;
|
||||
_previousEntryController.text = _currentlyDisplayedNote?.content ?? "";
|
||||
@@ -594,12 +595,12 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
// Handle previous/currently displayed note
|
||||
if (_currentlyDisplayedNote != null) {
|
||||
_currentlyDisplayedNote!.content = previousEntry;
|
||||
await updateNote(_currentlyDisplayedNote!);
|
||||
await updateNote(_currentlyDisplayedNote!.date, _currentlyDisplayedNote!.content);
|
||||
|
||||
// If the note was deleted (due to being empty), update the UI state
|
||||
if (previousEntry.isEmpty) {
|
||||
// Check if we need to navigate to another note
|
||||
Note? nextNote = await getLatestNote();
|
||||
Note? nextNote = await getLatest();
|
||||
setState(() {
|
||||
_currentlyDisplayedNote = nextNote;
|
||||
if (nextNote != null) {
|
||||
@@ -838,7 +839,8 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
_currentlyDisplayedNote!.content =
|
||||
_previousEntryController.text;
|
||||
await updateNote(
|
||||
_currentlyDisplayedNote!,
|
||||
_currentlyDisplayedNote!.date,
|
||||
_currentlyDisplayedNote!.content,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -913,8 +915,8 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
// Show cleanup dialog
|
||||
void _showCleanupDialog() async {
|
||||
double sensitivity = 0.7; // Default 70%
|
||||
final problematicEntries = await findProblematicEntries(
|
||||
maxCharPercentage: sensitivity,
|
||||
final problematicEntries = await getProblematic(
|
||||
threshold: sensitivity,
|
||||
);
|
||||
|
||||
if (!mounted) return;
|
||||
@@ -948,8 +950,8 @@ class MainPageState extends State<MainPage> with WindowListener {
|
||||
100; // Round to 2 decimal places
|
||||
});
|
||||
// Refresh results with new sensitivity
|
||||
final newResults = await findProblematicEntries(
|
||||
maxCharPercentage: sensitivity,
|
||||
final newResults = await getProblematic(
|
||||
threshold: sensitivity,
|
||||
);
|
||||
dialogSetState(() {
|
||||
problematicEntries.clear();
|
||||
|
Reference in New Issue
Block a user