diff --git a/src-tauri/src/api/streams.rs b/src-tauri/src/api/streams.rs index 940fb578..cf4cee5b 100644 --- a/src-tauri/src/api/streams.rs +++ b/src-tauri/src/api/streams.rs @@ -1,6 +1,7 @@ use futures::TryStreamExt; use tauri::State; use tauri::async_runtime::Mutex; +use twitch_api::helix::clips::{Clip, get_clips}; use twitch_api::helix::streams::{CreatedStreamMarker, Stream}; use super::get_access_token; @@ -50,3 +51,17 @@ pub async fn create_marker( Ok(marker) } + +#[tauri::command] +pub async fn get_clip( + state: State<'_, Mutex>, + id: String, +) -> Result, Error> { + let state = state.lock().await; + let token = get_access_token(&state)?; + + let request = get_clips::GetClipsRequest::clip_ids(vec![id]); + let mut response = state.helix.req_get(request, token).await?; + + Ok(response.data.pop()) +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c0d4d432..bcb1aa6e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -180,6 +180,7 @@ fn get_handler() -> impl Fn(Invoke) -> bool { api::streams::get_stream, api::streams::get_streams, api::streams::create_marker, + api::streams::get_clip, api::users::get_user_from_id, api::users::get_user_from_login, api::users::get_user_emotes, diff --git a/src/lib/components/Chat.svelte b/src/lib/components/Chat.svelte index af855a8c..7d964729 100644 --- a/src/lib/components/Chat.svelte +++ b/src/lib/components/Chat.svelte @@ -113,7 +113,12 @@ {:else if message.autoMod} {:else} - + { + if (!scrollingPaused) scrollToEnd(); + }} + /> {/if} {@const next = app.joined?.messages.at(i + 1)} diff --git a/src/lib/components/message/Embed.svelte b/src/lib/components/message/Embed.svelte new file mode 100644 index 00000000..906b940f --- /dev/null +++ b/src/lib/components/message/Embed.svelte @@ -0,0 +1,138 @@ + + +
+ {#if tld.domain === "7tv.app"} + {#await fetchEmote() then emote} +
+ {#if emote} +
+ {emote.name} + + {#if !emote.listed && blurred} + + {/if} +
+ +
+
+ + {emote.name} + + + {#if !emote.listed} + (unlisted) + {/if} +
+ + + by {emote.owner.display_name} + +
+ {/if} +
+ {/await} + {:else if tld.hostname === "open.spotify.com"} +
+ +
+ {:else if tld.domain === "twitch.tv"} + {#await fetchClip() then clip} + {#if clip} +
+ {clip.title} + +
+ + openUrl(clip.url)} + > + {clip.title} + + + + {dayjs(clip.created_at).format("MMMM D, YYYY")} + + +
+ by {clip.creator_name} + + + +
+ + {clip.view_count} views +
+
+
+
+ {/if} + {/await} + {/if} +
diff --git a/src/lib/components/message/Message.svelte b/src/lib/components/message/Message.svelte index 691f0677..3d5c18c8 100644 --- a/src/lib/components/message/Message.svelte +++ b/src/lib/components/message/Message.svelte @@ -1,16 +1,25 @@ + + @@ -120,14 +138,17 @@ render properly without an extra space in between. --> {node.value} {/if} - - {#if i < message.nodes.length - 1} - - {" "} - {/if} {/each}

+{#if linkNodes.some(canEmbed)} +
+ {#each linkNodes as node} + + {/each} +
+{/if} +