From 26c1563ea95011c5a2f3bdd70817e5220a3b633d Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sun, 15 Feb 2026 16:46:31 -0500 Subject: [PATCH] feat: add GIF search and trending functionality with Tauri commands - Implemented `search_gifs` and `get_trending_gifs` commands in Tauri for GIF retrieval. - Created a new protocol for GIF requests and responses. - Added `EmojiPicker` component for emoji selection with recent emoji storage. - Developed `GifPicker` component for searching and selecting GIFs. - Introduced emoji data management with recent emoji tracking. - Added markdown conversion utilities for rendering formatted text. - Updated Vite configuration to optimize dependencies for Prosemirror. --- src-tauri/src/commands/gif.rs | 6 ++++-- src-tauri/src/node/behaviour.rs | 8 ++++---- src-tauri/src/node/swarm.rs | 4 +++- src/components/chat/GifPicker.tsx | 3 ++- src/lib/tauri.ts | 4 +--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/commands/gif.rs b/src-tauri/src/commands/gif.rs index b8fae88..85bcd17 100644 --- a/src-tauri/src/commands/gif.rs +++ b/src-tauri/src/commands/gif.rs @@ -31,7 +31,8 @@ pub async fn search_gifs( // drop the lock before awaiting the response drop(handle_ref); - rx.await.map_err(|_| "gif search response channel closed".to_string())? + rx.await + .map_err(|_| "gif search response channel closed".to_string())? } #[tauri::command] @@ -59,5 +60,6 @@ pub async fn get_trending_gifs( drop(handle_ref); - rx.await.map_err(|_| "trending gifs response channel closed".to_string())? + rx.await + .map_err(|_| "trending gifs response channel closed".to_string())? } diff --git a/src-tauri/src/node/behaviour.rs b/src-tauri/src/node/behaviour.rs index 5a348c9..3107faf 100644 --- a/src-tauri/src/node/behaviour.rs +++ b/src-tauri/src/node/behaviour.rs @@ -1,8 +1,8 @@ -use libp2p::{ - gossipsub, identify, kad, mdns, ping, relay, - rendezvous, request_response::cbor, swarm::NetworkBehaviour, -}; use crate::protocol::gif::{GifRequest, GifResponse}; +use libp2p::{ + gossipsub, identify, kad, mdns, ping, relay, rendezvous, request_response::cbor, + swarm::NetworkBehaviour, +}; #[derive(NetworkBehaviour)] pub struct DuskBehaviour { diff --git a/src-tauri/src/node/swarm.rs b/src-tauri/src/node/swarm.rs index 1e5dc60..072134b 100644 --- a/src-tauri/src/node/swarm.rs +++ b/src-tauri/src/node/swarm.rs @@ -76,7 +76,9 @@ pub fn build_swarm( mdns, identify, // ping every 30s to keep the relay connection alive - ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(30))), + ping: ping::Behaviour::new( + ping::Config::new().with_interval(Duration::from_secs(30)), + ), // gif search via request-response to the relay (outbound only) gif_service: cbor::Behaviour::::new( [(GIF_PROTOCOL, ProtocolSupport::Outbound)], diff --git a/src/components/chat/GifPicker.tsx b/src/components/chat/GifPicker.tsx index 12a814f..344d57c 100644 --- a/src/components/chat/GifPicker.tsx +++ b/src/components/chat/GifPicker.tsx @@ -5,7 +5,8 @@ import type { GifResult } from "../../lib/types"; import * as tauri from "../../lib/tauri"; // detect if running inside tauri (vs standalone vite dev) -const isTauri = typeof window !== "undefined" && "__TAURI_INTERNALS__" in window; +const isTauri = + typeof window !== "undefined" && "__TAURI_INTERNALS__" in window; interface GifPickerProps { onSelect: (gifUrl: string) => void; diff --git a/src/lib/tauri.ts b/src/lib/tauri.ts index 528a67b..1f53525 100644 --- a/src/lib/tauri.ts +++ b/src/lib/tauri.ts @@ -351,8 +351,6 @@ export async function searchGifs( return invoke("search_gifs", { query, limit }); } -export async function getTrendingGifs( - limit?: number, -): Promise { +export async function getTrendingGifs(limit?: number): Promise { return invoke("get_trending_gifs", { limit }); }