mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-09-13 17:36:34 +00:00
style: formatting
This commit is contained in:
parent
41c880f9d5
commit
00eb6d6e18
6 changed files with 253 additions and 236 deletions
|
@ -56,7 +56,8 @@ enum IncomingMessage {
|
|||
pub struct WsState {
|
||||
pub connection: Arc<Mutex<Option<tokio::sync::mpsc::Sender<String>>>>,
|
||||
pub is_connected: Arc<Mutex<bool>>,
|
||||
pub pending_requests: Arc<Mutex<HashMap<u64, oneshot::Sender<Result<serde_json::Value, String>>>>>,
|
||||
pub pending_requests:
|
||||
Arc<Mutex<HashMap<u64, oneshot::Sender<Result<serde_json::Value, String>>>>>,
|
||||
pub request_id_counter: Arc<Mutex<u64>>,
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,11 @@ async fn handle_connection(stream: TcpStream, app_handle: AppHandle) {
|
|||
|
||||
let sender_task = tokio::spawn(async move {
|
||||
while let Some(msg_to_send) = rx.recv().await {
|
||||
if ws_sender.send(Message::Binary(msg_to_send.into())).await.is_err() {
|
||||
if ws_sender
|
||||
.send(Message::Binary(msg_to_send.into()))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -113,14 +118,24 @@ async fn handle_connection(stream: TcpStream, app_handle: AppHandle) {
|
|||
"result": null,
|
||||
"id": id
|
||||
});
|
||||
let tx = app_clone_for_receiver.state::<WsState>().connection.lock().unwrap().clone();
|
||||
let tx = app_clone_for_receiver
|
||||
.state::<WsState>()
|
||||
.connection
|
||||
.lock()
|
||||
.unwrap()
|
||||
.clone();
|
||||
if let Some(tx) = tx {
|
||||
let _ = tx.send(response.to_string()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(IncomingMessage::Response { id, result, error }) => {
|
||||
let sender = app_clone_for_receiver.state::<WsState>().pending_requests.lock().unwrap().remove(&id);
|
||||
let sender = app_clone_for_receiver
|
||||
.state::<WsState>()
|
||||
.pending_requests
|
||||
.lock()
|
||||
.unwrap()
|
||||
.remove(&id);
|
||||
if let Some(sender) = sender {
|
||||
if !error.is_null() {
|
||||
let _ = sender.send(Err(error.to_string()));
|
||||
|
@ -161,7 +176,9 @@ pub async fn run_server(app_handle: AppHandle) {
|
|||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn browser_extension_check_connection(state: tauri::State<'_, WsState>) -> Result<bool, String> {
|
||||
pub async fn browser_extension_check_connection(
|
||||
state: tauri::State<'_, WsState>,
|
||||
) -> Result<bool, String> {
|
||||
Ok(*state.is_connected.lock().unwrap())
|
||||
}
|
||||
|
||||
|
@ -212,4 +229,3 @@ pub async fn browser_extension_request(
|
|||
Err("Browser extension not connected".into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ pub async fn clipboard_read_text(app: tauri::AppHandle) -> Result<ReadResult, St
|
|||
Ok(ReadResult {
|
||||
text,
|
||||
html: None,
|
||||
file: None
|
||||
file: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ pub async fn clipboard_read(app: tauri::AppHandle) -> Result<ReadResult, String>
|
|||
pub async fn clipboard_copy(
|
||||
app: tauri::AppHandle,
|
||||
content: ClipboardContent,
|
||||
_options: Option<CopyOptions>
|
||||
_options: Option<CopyOptions>,
|
||||
) -> Result<(), String> {
|
||||
let clipboard = app.clipboard();
|
||||
|
||||
|
@ -73,7 +73,9 @@ pub async fn clipboard_copy(
|
|||
.write_html(html.clone(), content.text)
|
||||
.map_err(|e| e.to_string())?;
|
||||
} else if let Some(text) = &content.text {
|
||||
clipboard.write_text(text.clone()).map_err(|e| e.to_string())?;
|
||||
clipboard
|
||||
.write_text(text.clone())
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -82,7 +84,7 @@ pub async fn clipboard_copy(
|
|||
#[tauri::command]
|
||||
pub async fn clipboard_paste(
|
||||
app: tauri::AppHandle,
|
||||
content: ClipboardContent
|
||||
content: ClipboardContent,
|
||||
) -> Result<(), String> {
|
||||
let clipboard = app.clipboard();
|
||||
let original_text = clipboard.read_text().ok();
|
||||
|
|
|
@ -14,7 +14,7 @@ use selection::get_text;
|
|||
use std::process::Command;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use tauri::{Manager, Emitter};
|
||||
use tauri::{Emitter, Manager};
|
||||
use tauri_plugin_deep_link::DeepLinkExt;
|
||||
|
||||
#[tauri::command]
|
||||
|
@ -66,7 +66,7 @@ fn setup_background_refresh() {
|
|||
|
||||
fn setup_global_shortcut(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
use tauri_plugin_global_shortcut::{
|
||||
Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState
|
||||
Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState,
|
||||
};
|
||||
|
||||
let spotlight_shortcut = Shortcut::new(Some(Modifiers::ALT), Code::Space);
|
||||
|
@ -89,7 +89,7 @@ fn setup_global_shortcut(app: &mut tauri::App) -> Result<(), Box<dyn std::error:
|
|||
}
|
||||
}
|
||||
})
|
||||
.build()
|
||||
.build(),
|
||||
)?;
|
||||
|
||||
app.global_shortcut().register(spotlight_shortcut)?;
|
||||
|
|
|
@ -56,8 +56,7 @@ pub fn oauth_set_tokens(
|
|||
let path = get_storage_path(&app)?;
|
||||
let mut store = read_store(&path)?;
|
||||
|
||||
let token_set: StoredTokenSet =
|
||||
serde_json::from_value(tokens).map_err(|e| e.to_string())?;
|
||||
let token_set: StoredTokenSet = serde_json::from_value(tokens).map_err(|e| e.to_string())?;
|
||||
|
||||
store.insert(provider_id, token_set);
|
||||
write_store(&path, &store)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue