Skip to content

best way to save what you love

web/SupportedServices: speed up the secondary expand by ~200μs

wukko4cdbb02de2d6
diff --git a/web/src/components/save/SupportedServices.svelte b/web/src/components/save/SupportedServices.svelte
index d3077a2a..6dcb9244 100644
--- a/web/src/components/save/SupportedServices.svelte
+++ b/web/src/components/save/SupportedServices.svelte
@@ -23,20 +23,26 @@
}
};
+ const popoverAction = async () => {
+ expanded = !expanded;
+ if (expanded && services.length === 0) {
+ await loadInfo();
+ }
+ if (expanded) {
+ popover.focus();
+ }
+ }
+
const showPopover = async () => {
- const timeout = renderPopover ? 0 : 10;
+ const timeout = !renderPopover;
renderPopover = true;
// 10ms delay to let the popover render for the first time
- setTimeout(async () => {
- expanded = !expanded;
- if (expanded && services.length === 0) {
- await loadInfo();
- }
- if (expanded) {
- popover.focus();
- }
- }, timeout);
+ if (timeout) {
+ setTimeout(popoverAction, 10);
+ } else {
+ await popoverAction();
+ }
};
</script>