From e34da54271ed8027d337a484f0ec00749c71a53b Mon Sep 17 00:00:00 2001
From: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
Date: Wed, 12 Apr 2023 23:22:38 -0300
Subject: Option to transform emotes/stickers in compound messages (#876)

+ ContextMenu refactor to not call callbacks for same children multiple times

Co-authored-by: V <vendicated@riseup.net>
---
 src/plugins/imageZoom/index.tsx | 98 ++++++++++++++++++++---------------------
 1 file changed, 48 insertions(+), 50 deletions(-)

(limited to 'src/plugins/imageZoom/index.tsx')

diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx
index 6014756..d65df08 100644
--- a/src/plugins/imageZoom/index.tsx
+++ b/src/plugins/imageZoom/index.tsx
@@ -76,56 +76,54 @@ export const settings = definePluginSettings({
 
 
 const imageContextMenuPatch: NavContextMenuPatchCallback = (children, _) => {
-    if (!children.some(child => child?.props?.id === "image-zoom")) {
-        children.push(
-            <Menu.MenuGroup id="image-zoom">
-                {/* thanks SpotifyControls */}
-                <Menu.MenuControlItem
-                    id="zoom"
-                    label="Zoom"
-                    control={(props, ref) => (
-                        <Menu.MenuSliderControl
-                            ref={ref}
-                            {...props}
-                            minValue={1}
-                            maxValue={50}
-                            value={settings.store.zoom}
-                            onChange={debounce((value: number) => settings.store.zoom = value, 100)}
-                        />
-                    )}
-                />
-                <Menu.MenuControlItem
-                    id="size"
-                    label="Lens Size"
-                    control={(props, ref) => (
-                        <Menu.MenuSliderControl
-                            ref={ref}
-                            {...props}
-                            minValue={50}
-                            maxValue={1000}
-                            value={settings.store.size}
-                            onChange={debounce((value: number) => settings.store.size = value, 100)}
-                        />
-                    )}
-                />
-                <Menu.MenuControlItem
-                    id="zoom-speed"
-                    label="Zoom Speed"
-                    control={(props, ref) => (
-                        <Menu.MenuSliderControl
-                            ref={ref}
-                            {...props}
-                            minValue={0.1}
-                            maxValue={5}
-                            value={settings.store.zoomSpeed}
-                            onChange={debounce((value: number) => settings.store.zoomSpeed = value, 100)}
-                            renderValue={(value: number) => `${value.toFixed(3)}x`}
-                        />
-                    )}
-                />
-            </Menu.MenuGroup>
-        );
-    }
+    children.push(
+        <Menu.MenuGroup id="image-zoom">
+            {/* thanks SpotifyControls */}
+            <Menu.MenuControlItem
+                id="zoom"
+                label="Zoom"
+                control={(props, ref) => (
+                    <Menu.MenuSliderControl
+                        ref={ref}
+                        {...props}
+                        minValue={1}
+                        maxValue={50}
+                        value={settings.store.zoom}
+                        onChange={debounce((value: number) => settings.store.zoom = value, 100)}
+                    />
+                )}
+            />
+            <Menu.MenuControlItem
+                id="size"
+                label="Lens Size"
+                control={(props, ref) => (
+                    <Menu.MenuSliderControl
+                        ref={ref}
+                        {...props}
+                        minValue={50}
+                        maxValue={1000}
+                        value={settings.store.size}
+                        onChange={debounce((value: number) => settings.store.size = value, 100)}
+                    />
+                )}
+            />
+            <Menu.MenuControlItem
+                id="zoom-speed"
+                label="Zoom Speed"
+                control={(props, ref) => (
+                    <Menu.MenuSliderControl
+                        ref={ref}
+                        {...props}
+                        minValue={0.1}
+                        maxValue={5}
+                        value={settings.store.zoomSpeed}
+                        onChange={debounce((value: number) => settings.store.zoomSpeed = value, 100)}
+                        renderValue={(value: number) => `${value.toFixed(3)}x`}
+                    />
+                )}
+            />
+        </Menu.MenuGroup>
+    );
 };
 
 export default definePlugin({
-- 
cgit 

