refactor: Implement unified search abstraction, MemoryState refactoring, error handling, and unit test expansion
This commit is contained in:
1 parent
a34554b7ff
commit
462f65f66d
21 files changed
+425
-535
No files matched your search
@@ -2,8 +2,7 @@ use crate::state::MemoryState;
|
||||
use crate::models::StickyNote;
|
||||
use std::sync::Arc;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use clipboard_win::{formats, get_clipboard, Clipboard};
|
||||
|
||||
use arboard::Clipboard;
|
||||
pub fn spawn_watcher(state: Arc<MemoryState>) {
|
||||
tokio::spawn(async move {
|
||||
let mut last_text = String::new();
|
||||
@@ -19,9 +18,9 @@ pub fn spawn_watcher(state: Arc<MemoryState>) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Ok(_clip) = tokio::task::spawn_blocking(|| Clipboard::new_attempts(3)).await.unwrap()
|
||||
&& let Ok(text) = get_clipboard::<String, _>(formats::Unicode)
|
||||
&& text != last_text && !text.trim().is_empty() {
|
||||
if let Ok(mut clipboard) = Clipboard::new() {
|
||||
if let Ok(text) = clipboard.get_text() {
|
||||
if text != last_text && !text.trim().is_empty() {
|
||||
last_text = text.clone();
|
||||
|
||||
let note = StickyNote {
|
||||
@@ -40,6 +39,8 @@ pub fn spawn_watcher(state: Arc<MemoryState>) {
|
||||
// We use rebuild_index to index the new sticky note
|
||||
state.rebuild_index().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user