TenorGifSearch: fix search results being blank on Linux
This commit is contained in:
parent
72cc4d1110
commit
9e75fe9ef4
1 changed files with 19 additions and 8 deletions
|
|
@ -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<Record<string, TenorMedia>>;
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue