diff --git a/frontend/app/src/components/home/MessageActions.svelte b/frontend/app/src/components/home/MessageActions.svelte index f196534874..185d754542 100644 --- a/frontend/app/src/components/home/MessageActions.svelte +++ b/frontend/app/src/components/home/MessageActions.svelte @@ -82,44 +82,43 @@ drawOpen = false; } + function cssValues(index: number): string { + return `--top: ${top(index)}px; --transition-delay: ${delay(index)}ms`; + } + function buildListOfActions( permissions: Map, messageAction: MessageAction, includeAll: boolean, - ): Map { - const actions = new Map(); + ): Map { + let index = -1; + const actions = new Map(); if (includeAll) { if (permissions.get("text") || messageAction === "file") { - actions.set("emoji", actions.size); + actions.set("emoji", cssValues(++index)); } if (permissions.get("file") || permissions.get("image") || permissions.get("video")) { - actions.set("attach", actions.size); + actions.set("attach", cssValues(++index)); } } if (permissions.get("crypto")) { - actions.set("crypto", actions.size); + actions.set("crypto", cssValues(++index)); } if (permissions.get("giphy")) { - actions.set("giphy", actions.size); + actions.set("giphy", cssValues(++index)); } if (permissions.get("memeFighter")) { - actions.set("meme", actions.size); + actions.set("meme", cssValues(++index)); } if (permissions.get("poll")) { - actions.set("poll", actions.size); + actions.set("poll", cssValues(++index)); } if (permissions.get("prize")) { - actions.set("prize", actions.size); + actions.set("prize", cssValues(++index)); } return actions; } - function cssVars(key: string): string { - return `--top: ${top(supportedActions.get(key))}px; --transition-delay: ${delay( - supportedActions.get(key), - )}ms`; - } - function top(i: number | undefined): number { if (i === undefined) return 0; return -55 - i * 45; @@ -128,7 +127,7 @@ function delay(i: number | undefined): number { if (i === undefined) return 0; const increment = 50; - const total = supportedActions.size * increment; + const total = i * increment; return total - (i + 1) * increment; } @@ -172,7 +171,10 @@
{#if supportedActions.has("emoji")} -
+
@@ -180,13 +182,13 @@ {/if} {#if !editing} {#if supportedActions.has("attach")} -
+
{/if} {#if supportedActions.has("crypto")}
@@ -195,21 +197,30 @@
{/if} {#if supportedActions.has("giphy")} -
+
{/if} {#if supportedActions.has("meme")} -
+
{/if} {#if supportedActions.has("poll")} -
+
@@ -217,7 +228,7 @@ {/if} {#if supportedActions.has("prize")}