Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

gifs: Introduce `abstract_gif_network.ts`.

apoorvapendse6f758c9d7294
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index 043f9618479..4ba6a421a10 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -45,6 +45,7 @@ def make_set(files: list[str]) -> set[str]:
EXEMPT_FILES = make_set(
[
"web/src/about_zulip.ts",
+ "web/src/abstract_gif_network.ts",
"web/src/add_group_members_pill.ts",
"web/src/add_stream_options_popover.ts",
"web/src/add_subscribers_pill.ts",
diff --git a/web/src/abstract_gif_network.ts b/web/src/abstract_gif_network.ts
new file mode 100644
index 00000000000..8b8eca11541
--- /dev/null
+++ b/web/src/abstract_gif_network.ts
@@ -0,0 +1,6 @@
+export type GifInfoUrl = {
+ preview_url: string;
+ insert_url: string;
+};
+
+export type RenderGifsCallback = (urls: GifInfoUrl[], next_page: boolean) => void;
diff --git a/web/src/tenor.ts b/web/src/tenor.ts
index 743bc71173f..dd4a6eddf83 100644
--- a/web/src/tenor.ts
+++ b/web/src/tenor.ts
@@ -6,6 +6,7 @@ import * as z from "zod/mini";
import render_tenor_gif from "../templates/tenor_gif.hbs";
+import type {GifInfoUrl, RenderGifsCallback} from "./abstract_gif_network.ts";
import * as channel from "./channel.ts";
import {ComposeIconSession} from "./compose_icon_session.ts";
import * as gif_picker_popover_content from "./gif_picker_popover_content.ts";
@@ -67,13 +68,6 @@ type TenorPayload = {
q?: string;
};
-type TenorURL = {
- preview_url: string;
- insert_url: string;
-};
-
-type RenderGifsCallback = (urls: TenorURL[], next_page: boolean) => void;
-
class TenorNetwork {
is_loading_more = false;
next_pos_identifier: string | number | undefined;
@@ -123,7 +117,7 @@ class TenorNetwork {
data,
success: (raw_tenor_result) => {
const parsed_data = tenor_result_schema.parse(raw_tenor_result);
- const urls: TenorURL[] = parsed_data.results.map((result) => ({
+ const urls: GifInfoUrl[] = parsed_data.results.map((result) => ({
preview_url: result.media_formats.tinygif.url,
insert_url: result.media_formats.mediumgif.url,
}));
@@ -234,7 +228,7 @@ export function hide_tenor_popover(): boolean {
return false;
}
-function render_gifs_to_grid(urls: TenorURL[], next_page: boolean): void {
+function render_gifs_to_grid(urls: GifInfoUrl[], next_page: boolean): void {
// Tenor popover may have been hidden by the
// time this function is called.
if (tenor_popover_instance === undefined) {