diff --git a/src/plugins/favEmojiFirst/README.md b/src/plugins/favEmojiFirst/README.md
new file mode 100644
index 00000000..dc844802
--- /dev/null
+++ b/src/plugins/favEmojiFirst/README.md
@@ -0,0 +1,6 @@
+# FavoriteEmojiFirst
+
+Puts your favorite emoji first in the emoji autocomplete.
+
+![FavEmojis](https://i.imgur.com/mEFCoZG.png)
+![Example](https://i.imgur.com/wY3Tc43.png)
diff --git a/src/plugins/favEmojiFirst.ts b/src/plugins/favEmojiFirst/index.ts
similarity index 100%
rename from src/plugins/favEmojiFirst.ts
rename to src/plugins/favEmojiFirst/index.ts
diff --git a/src/plugins/favGifSearch/README.md b/src/plugins/favGifSearch/README.md
new file mode 100644
index 00000000..c0768859
--- /dev/null
+++ b/src/plugins/favGifSearch/README.md
@@ -0,0 +1,5 @@
+# FavoriteGifSearch
+
+Adds a search bar to favorite gifs.
+
+![Screenshot](https://i.imgur.com/Bcgb7PD.png)
diff --git a/src/plugins/favGifSearch.tsx b/src/plugins/favGifSearch/index.tsx
similarity index 99%
rename from src/plugins/favGifSearch.tsx
rename to src/plugins/favGifSearch/index.tsx
index db575a03..d10c5153 100644
--- a/src/plugins/favGifSearch.tsx
+++ b/src/plugins/favGifSearch/index.tsx
@@ -87,7 +87,7 @@ export const settings = definePluginSettings({
export default definePlugin({
name: "FavoriteGifSearch",
authors: [Devs.Aria],
- description: "Adds a search bar for favorite gifs",
+ description: "Adds a search bar to favorite gifs.",
patches: [
{
diff --git a/src/plugins/imageZoom/README.md b/src/plugins/imageZoom/README.md
new file mode 100644
index 00000000..8e3b7efd
--- /dev/null
+++ b/src/plugins/imageZoom/README.md
@@ -0,0 +1,6 @@
+# ImageZoom
+
+Lets you zoom in to images and gifs. Use scroll wheel to zoom in and shift + scroll wheel to increase lens radius / size
+
+![Example](https://i.imgur.com/VJdo4aq.png)
+![ContextMenu](https://i.imgur.com/0oaRM2s.png)
diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx
index 71540f2b..cca0db02 100644
--- a/src/plugins/imageZoom/index.tsx
+++ b/src/plugins/imageZoom/index.tsx
@@ -99,6 +99,15 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
ContextMenu.close();
}}
/>
+
{
+ settings.store.nearestNeighbour = !settings.store.nearestNeighbour;
+ ContextMenu.close();
+ }}
+ />
.
*/
-import { sendBotMessage } from "@api/Commands";
+import { generateId, sendBotMessage } from "@api/Commands";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
+import { findByPropsLazy } from "@webpack";
import { Button, ButtonLooks, ButtonWrapperClasses, DraftStore, DraftType, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common";
+import { MessageAttachment } from "discord-types/general";
interface Props {
type: {
analyticsName: string;
+ isEmpty: boolean;
+ attachments: boolean;
};
}
+const UploadStore = findByPropsLazy("getUploads");
+
const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage);
+
+const getImageBox = (url: string): Promise<{ width: number, height: number; } | null> =>
+ new Promise(res => {
+ const img = new Image();
+ img.onload = () =>
+ res({ width: img.width, height: img.height });
+
+ img.onerror = () =>
+ res(null);
+
+ img.src = url;
+ });
+
+
+const getAttachments = async (channelId: string) =>
+ await Promise.all(
+ UploadStore.getUploads(channelId, DraftType.ChannelMessage)
+ .map(async (upload: any) => {
+ const { isImage, filename, spoiler, item: { file } } = upload;
+ const url = URL.createObjectURL(file);
+ const attachment: MessageAttachment = {
+ id: generateId(),
+ filename: spoiler ? "SPOILER_" + filename : filename,
+ // weird eh? if i give it the normal content type the preview doenst work
+ content_type: undefined,
+ size: await upload.getSize(),
+ spoiler,
+ // discord adds query params to the url, so we need to add a hash to prevent that
+ url: url + "#",
+ proxy_url: url + "#",
+ };
+
+ if (isImage) {
+ const box = await getImageBox(url);
+ if (!box) return attachment;
+
+ attachment.width = box.width;
+ attachment.height = box.height;
+ }
+
+ return attachment;
+ })
+ );
+
+
export function PreviewButton(chatBoxProps: Props) {
+ const { isEmpty, attachments } = chatBoxProps.type;
+
const channelId = SelectedChannelStore.getChannelId();
const draft = useStateFromStores([DraftStore], () => getDraft(channelId));
+
if (chatBoxProps.type.analyticsName !== "normal") return null;
- if (!draft) return null;
+
+ const hasAttachments = attachments && UploadStore.getUploads(channelId, DraftType.ChannelMessage).length > 0;
+ const hasContent = !isEmpty && draft?.length > 0;
+
+ if (!hasContent && !hasAttachments) return null;
return (
{tooltipProps => (