Browse Source

feat: do not initiate requests when the SearchModal is not open to speed up page loading

Shirasawa 2 weeks ago
parent
commit
01fcd057b7
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/lib/components/layout/SearchModal.svelte

+ 2 - 4
src/lib/components/layout/SearchModal.svelte

@@ -149,9 +149,9 @@
 		chatListLoading = false;
 	};
 
-	const init = () => {
+	$: if (show) {
 		searchHandler();
-	};
+	}
 
 	const onKeyDown = (e) => {
 		const searchOptions = document.getElementById('search-options-container');
@@ -205,8 +205,6 @@
 	};
 
 	onMount(() => {
-		init();
-
 		document.addEventListener('keydown', onKeyDown);
 	});