diff --git a/common/src/lib.rs b/common/src/lib.rs index 7378b2a..b6fb008 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -17,7 +17,6 @@ pub enum ActionMessage { pub enum ClipboardContent { Text(String), Image(Vec), - None, } impl Debug for ClipboardContent { @@ -25,7 +24,6 @@ impl Debug for ClipboardContent { match self { ClipboardContent::Text(text) => write!(f, "Text({:?})", text), ClipboardContent::Image(content) => write!(f, "Image(len={})", content.len()), - ClipboardContent::None => write!(f, "None"), } } } diff --git a/daemon/src/clipboard/clipboard.rs b/daemon/src/clipboard/clipboard.rs index a60debd..7f42964 100644 --- a/daemon/src/clipboard/clipboard.rs +++ b/daemon/src/clipboard/clipboard.rs @@ -68,7 +68,8 @@ fn get_clipboard_content(output_format: &ImageOutputFormat) -> Result> ClipboardHandler for &mut Watcher { @@ -95,7 +96,6 @@ impl> ClipboardHandler for &mut Watcher { pub fn set_clipboard(content: &ClipboardContent) -> anyhow::Result<()> { match &content { - ClipboardContent::None => Ok(()), ClipboardContent::Text(text) => { let mut clipboard = Clipboard::new()?; diff --git a/server/src/connection.rs b/server/src/connection.rs index 05fb8e1..c92d2e9 100644 --- a/server/src/connection.rs +++ b/server/src/connection.rs @@ -33,7 +33,7 @@ impl Manager { config: config, connections: Arc::new(RwLock::new(HashMap::new())), counter: AtomicUsize::new(0), - last_clipboard_content: RwLock::new(ClipboardContent::None), + last_clipboard_content: RwLock::new(ClipboardContent::Text("".to_string())), last_message: RwLock::new(None), } } diff --git a/server/src/web_server.rs b/server/src/web_server.rs index 7b68a57..1b177f9 100644 --- a/server/src/web_server.rs +++ b/server/src/web_server.rs @@ -75,7 +75,7 @@ fn handle_read_clipboard_route(manager: Arc>) -> impl Reply { match last_clipboard_content.clone() { ClipboardContent::Text(text) => warp::reply::with_header( - text, + warp::reply::html(text), "Content-Type", "text/plain" .parse::() @@ -101,7 +101,6 @@ fn handle_read_clipboard_route(manager: Arc>) -> impl Reply { ) .into_response() } - _ => warp::reply::html("No clipboard content".to_string()).into_response(), } } diff --git a/server/src/websocket.rs b/server/src/websocket.rs index ea75cf0..5783d0b 100644 --- a/server/src/websocket.rs +++ b/server/src/websocket.rs @@ -1,6 +1,6 @@ use crate::connection::Manager; use anyhow::Result; -use common::{ActionMessage, ClipboardContent}; +use common::ActionMessage; use futures_util::{SinkExt, StreamExt}; use log::{error, info}; use std::sync::{Arc, RwLock}; @@ -66,15 +66,9 @@ pub(crate) async fn handle_connection( // Send the last clipboard content to the user let manager = manager_clone.write().unwrap(); let last_clipboard_content = manager.last_clipboard_content.read().unwrap(); - let content = last_clipboard_content.clone(); - match content { - ClipboardContent::None => (), - _ => { - let message = ActionMessage::Clipboard(last_clipboard_content.clone()); - let _ = ws_writer_clone.send(message); - } - } + let message = ActionMessage::Clipboard(last_clipboard_content.clone()); + let _ = ws_writer_clone.send(message); }); log::info!(