From ec5ca6689b58fe9783b810690f781e5e14983842 Mon Sep 17 00:00:00 2001 From: hank Date: Fri, 27 Sep 2024 14:52:52 +0800 Subject: [PATCH] use toReversed --- source/extension.svelte | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/source/extension.svelte b/source/extension.svelte index 41e370e..53aa7f3 100644 --- a/source/extension.svelte +++ b/source/extension.svelte @@ -57,20 +57,15 @@ size *= window.devicePixelRatio; if (icons) { - const sortedIcons = icons.sort(sortIconBySize); // Get a large icon closest to the desired size - for (const icon of sortedIcons) { + for (const icon of icons.toReversed()) { if (icon.size >= size) { return icon.url; } } + // Fallback icon + return 'icons/puzzle.svg'; } - // Fallback icon - return 'icons/puzzle.svg'; - } - - function sortIconBySize(a, b) { - return b.size - a.size; }