From 9e75fe9ef4bdbe755bd832f54fd63bbbfa9fae50 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 11 Aug 2026 23:12:39 +0200 Subject: [PATCH] TenorGifSearch: fix search results being blank on Linux --- src/plugins/tenorGifSearch/index.tsx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/plugins/tenorGifSearch/index.tsx b/src/plugins/tenorGifSearch/index.tsx index ab9befbde..d5499b0f7 100644 --- a/src/plugins/tenorGifSearch/index.tsx +++ b/src/plugins/tenorGifSearch/index.tsx @@ -7,11 +7,14 @@ import { Devs } from "@utils/constants"; import { isNonNullish } from "@utils/guards"; import definePlugin from "@utils/types"; +import { findStoreLazy } from "@webpack"; import { FluxDispatcher, LocaleStore } from "@webpack/common"; // API key is taken from the GBoard app on iOS const TENOR_KEY = "3Z0688EVWYKH"; +const GIFPickerViewStore = findStoreLazy("GIFPickerViewStore"); + let cachedCategories: TrendingCategories | null = null; interface TenorMedia { @@ -21,6 +24,8 @@ interface TenorMedia { } interface TenorResult { id: string; + title: string; + h1_title: string; media: Array>; itemurl: string; } @@ -46,17 +51,23 @@ interface TrendingCategories { } function toDiscordGif(item: TenorResult): DiscordGif | null { - const { gif, webm } = item.media[0]; + // Discord uses tinywebp on Linux, webm on rest (including web Linux). Tenor only has "webp", not "tinywebp" + const format = GIFPickerViewStore.getSelectedFormat() === "tinywebp" + ? "webp" + : "tinywebm"; + + const { title, h1_title, id, itemurl } = item; + const { gif, [format]: mediaItem } = item.media[0]; return { - id: item.id, - title: "", // discord always returns a blank string - url: item.itemurl, + id: id, + title: title || h1_title, + url: itemurl, gif_src: gif.url, - src: webm.url, - width: webm.dims[0], - height: webm.dims[1], - preview: webm.preview + src: mediaItem.url, + width: mediaItem.dims[0], + height: mediaItem.dims[1], + preview: mediaItem.preview }; }