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.
This commit is contained in:
parent
e468f5ae44
commit
26c1563ea9
|
|
@ -31,7 +31,8 @@ pub async fn search_gifs(
|
||||||
// drop the lock before awaiting the response
|
// drop the lock before awaiting the response
|
||||||
drop(handle_ref);
|
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]
|
#[tauri::command]
|
||||||
|
|
@ -59,5 +60,6 @@ pub async fn get_trending_gifs(
|
||||||
|
|
||||||
drop(handle_ref);
|
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())?
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 crate::protocol::gif::{GifRequest, GifResponse};
|
||||||
|
use libp2p::{
|
||||||
|
gossipsub, identify, kad, mdns, ping, relay, rendezvous, request_response::cbor,
|
||||||
|
swarm::NetworkBehaviour,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(NetworkBehaviour)]
|
#[derive(NetworkBehaviour)]
|
||||||
pub struct DuskBehaviour {
|
pub struct DuskBehaviour {
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,9 @@ pub fn build_swarm(
|
||||||
mdns,
|
mdns,
|
||||||
identify,
|
identify,
|
||||||
// ping every 30s to keep the relay connection alive
|
// 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 search via request-response to the relay (outbound only)
|
||||||
gif_service: cbor::Behaviour::<GifRequest, GifResponse>::new(
|
gif_service: cbor::Behaviour::<GifRequest, GifResponse>::new(
|
||||||
[(GIF_PROTOCOL, ProtocolSupport::Outbound)],
|
[(GIF_PROTOCOL, ProtocolSupport::Outbound)],
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ import type { GifResult } from "../../lib/types";
|
||||||
import * as tauri from "../../lib/tauri";
|
import * as tauri from "../../lib/tauri";
|
||||||
|
|
||||||
// detect if running inside tauri (vs standalone vite dev)
|
// 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 {
|
interface GifPickerProps {
|
||||||
onSelect: (gifUrl: string) => void;
|
onSelect: (gifUrl: string) => void;
|
||||||
|
|
|
||||||
|
|
@ -351,8 +351,6 @@ export async function searchGifs(
|
||||||
return invoke("search_gifs", { query, limit });
|
return invoke("search_gifs", { query, limit });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getTrendingGifs(
|
export async function getTrendingGifs(limit?: number): Promise<GifResponse> {
|
||||||
limit?: number,
|
|
||||||
): Promise<GifResponse> {
|
|
||||||
return invoke("get_trending_gifs", { limit });
|
return invoke("get_trending_gifs", { limit });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue