Compare commits
2 Commits
v4.1.0
...
d6f9fa5032
Author | SHA1 | Date | |
---|---|---|---|
d6f9fa5032 | |||
64884cbb42 |
@@ -507,9 +507,11 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
|
|
||||||
// Save the current note content before navigating away
|
// Save the current note content before navigating away
|
||||||
if (_currentlyDisplayedNote != null) {
|
if (_currentlyDisplayedNote != null) {
|
||||||
|
if (_currentlyDisplayedNote!.content != _previousEntryController.text) {
|
||||||
_currentlyDisplayedNote!.content = _previousEntryController.text;
|
_currentlyDisplayedNote!.content = _previousEntryController.text;
|
||||||
await updateNote(_currentlyDisplayedNote!);
|
await updateNote(_currentlyDisplayedNote!);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final prevNote = await getPreviousTo(_currentlyDisplayedNote!.epochTime);
|
final prevNote = await getPreviousTo(_currentlyDisplayedNote!.epochTime);
|
||||||
if (prevNote != null) {
|
if (prevNote != null) {
|
||||||
@@ -526,9 +528,11 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
|
|
||||||
// Save the current note content before navigating away
|
// Save the current note content before navigating away
|
||||||
if (_currentlyDisplayedNote != null) {
|
if (_currentlyDisplayedNote != null) {
|
||||||
|
if (_currentlyDisplayedNote!.content != _previousEntryController.text) {
|
||||||
_currentlyDisplayedNote!.content = _previousEntryController.text;
|
_currentlyDisplayedNote!.content = _previousEntryController.text;
|
||||||
await updateNote(_currentlyDisplayedNote!);
|
await updateNote(_currentlyDisplayedNote!);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final nextNote = await getNextTo(_currentlyDisplayedNote!.epochTime);
|
final nextNote = await getNextTo(_currentlyDisplayedNote!.epochTime);
|
||||||
if (nextNote != null) {
|
if (nextNote != null) {
|
||||||
@@ -593,13 +597,17 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
_currentEntryController.clear(); // Clear the input field after saving
|
_currentEntryController.clear(); // Clear the input field after saving
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle scratch pad
|
if (scratchContent != _scratchController.text) {
|
||||||
|
// Was modified
|
||||||
await createScratch(scratchContent);
|
await createScratch(scratchContent);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle previous/currently displayed note
|
// Handle previous/currently displayed note
|
||||||
if (_currentlyDisplayedNote != null) {
|
if (_currentlyDisplayedNote != null) {
|
||||||
|
if (_currentlyDisplayedNote!.content != previousEntry) {
|
||||||
_currentlyDisplayedNote!.content = previousEntry;
|
_currentlyDisplayedNote!.content = previousEntry;
|
||||||
await updateNote(_currentlyDisplayedNote!);
|
await updateNote(_currentlyDisplayedNote!);
|
||||||
|
}
|
||||||
|
|
||||||
// If the note was deleted (due to being empty), update the UI state
|
// If the note was deleted (due to being empty), update the UI state
|
||||||
if (previousEntry.isEmpty) {
|
if (previousEntry.isEmpty) {
|
||||||
@@ -662,9 +670,7 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
spans.add(
|
spans.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: highlightedText.substring(lastIndex, match.start),
|
text: highlightedText.substring(lastIndex, match.start),
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 13),
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -825,12 +831,19 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
// Save current note if needed
|
// Save current note if needed
|
||||||
if (_currentlyDisplayedNote !=
|
if (_currentlyDisplayedNote !=
|
||||||
null) {
|
null) {
|
||||||
_currentlyDisplayedNote!.content =
|
if (_currentlyDisplayedNote!
|
||||||
_previousEntryController.text;
|
.content !=
|
||||||
|
_previousEntryController
|
||||||
|
.text) {
|
||||||
|
_currentlyDisplayedNote!
|
||||||
|
.content =
|
||||||
|
_previousEntryController
|
||||||
|
.text;
|
||||||
await updateNote(
|
await updateNote(
|
||||||
_currentlyDisplayedNote!,
|
_currentlyDisplayedNote!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Navigate to the selected note
|
// Navigate to the selected note
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
@@ -1107,17 +1120,21 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
String? errorMessage;
|
String? errorMessage;
|
||||||
|
|
||||||
// Load current values
|
// Load current values
|
||||||
getMeilisearchEndpoint().then((value) {
|
getMeilisearchEndpoint()
|
||||||
|
.then((value) {
|
||||||
endpointController.text = value;
|
endpointController.text = value;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
}).catchError((e) {
|
})
|
||||||
|
.catchError((e) {
|
||||||
errorMessage = 'Failed to load endpoint: $e';
|
errorMessage = 'Failed to load endpoint: $e';
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
getMeilisearchApiKey().then((value) {
|
getMeilisearchApiKey()
|
||||||
|
.then((value) {
|
||||||
apiKeyController.text = value;
|
apiKeyController.text = value;
|
||||||
}).catchError((e) {
|
})
|
||||||
|
.catchError((e) {
|
||||||
errorMessage = 'Failed to load API key: $e';
|
errorMessage = 'Failed to load API key: $e';
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1168,14 +1185,19 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
child: const Text('Cancel'),
|
child: const Text('Cancel'),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: isLoading ? null : () async {
|
onPressed:
|
||||||
|
isLoading
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
try {
|
try {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
await setMeilisearchEndpoint(endpointController.text);
|
await setMeilisearchEndpoint(
|
||||||
|
endpointController.text,
|
||||||
|
);
|
||||||
await setMeilisearchApiKey(apiKeyController.text);
|
await setMeilisearchApiKey(apiKeyController.text);
|
||||||
|
|
||||||
// Try to reinitialize Meilisearch with new settings
|
// Try to reinitialize Meilisearch with new settings
|
||||||
|
@@ -350,6 +350,7 @@ Future<Note> createNote(String content) async {
|
|||||||
final document = {
|
final document = {
|
||||||
'id': generateRandomString(32),
|
'id': generateRandomString(32),
|
||||||
'date': DateTime.now().toUtc().millisecondsSinceEpoch,
|
'date': DateTime.now().toUtc().millisecondsSinceEpoch,
|
||||||
|
'dateISO': DateTime.now().toUtc().toIso8601String(),
|
||||||
'content': content,
|
'content': content,
|
||||||
'topLetter': mostFrequentLetter,
|
'topLetter': mostFrequentLetter,
|
||||||
'topLetterFrequency': mostFrequentLetterCount,
|
'topLetterFrequency': mostFrequentLetterCount,
|
||||||
@@ -433,6 +434,10 @@ Future<void> updateNote(Note note) async {
|
|||||||
'id': note.id,
|
'id': note.id,
|
||||||
'content': trimmedContent,
|
'content': trimmedContent,
|
||||||
'date': note.epochTime,
|
'date': note.epochTime,
|
||||||
|
'dateISO':
|
||||||
|
DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
note.epochTime,
|
||||||
|
).toUtc().toIso8601String(),
|
||||||
'topLetter': mostFrequentLetter,
|
'topLetter': mostFrequentLetter,
|
||||||
'topLetterFrequency': mostFrequentLetterRatio,
|
'topLetterFrequency': mostFrequentLetterRatio,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user