perf: Debounce various Database Endpoints for less Database Queries and better Backend performance (#20982)
* Update KnowledgeSelector.svelte * Update KnowledgeSelector.svelte * Update Users.svelte * Update MemberSelector.svelte * Update MemberSelector.svelte * Update Knowledge.svelte * Update Knowledge.svelte * Update Notes.svelte * Update Knowledge.svelte * Update Prompts.svelte * Update Tools.svelte * Update Tools.svelte * Update Prompts.svelte * Update Prompts.svelte * Update Prompts.svelte * Update Functions.svelte * Update UserList.svelte * Update Functions.svelte * Update Prompts.svelte * Update UserList.svelte
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
@@ -30,6 +30,7 @@
|
||||
let total = null;
|
||||
|
||||
let query = '';
|
||||
let searchDebounceTimer: ReturnType<typeof setTimeout>;
|
||||
let orderBy = 'created_at'; // default sort key
|
||||
let direction = 'desc'; // default sort order
|
||||
|
||||
@@ -79,13 +80,21 @@
|
||||
getUserList();
|
||||
};
|
||||
|
||||
$: if (page !== null && query !== null && orderBy !== null && direction !== null) {
|
||||
$: if (page !== null && orderBy !== null && direction !== null) {
|
||||
getUserList();
|
||||
}
|
||||
|
||||
$: if (query) {
|
||||
page = 1;
|
||||
$: if (query !== undefined) {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
getUserList();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class=" max-h-full h-full w-full flex flex-col overflow-y-hidden">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
||||
import { WEBUI_NAME, config, user, showSidebar } from '$lib/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { onMount, getContext } from 'svelte';
|
||||
import { onMount, getContext, onDestroy } from 'svelte';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
@@ -43,6 +43,7 @@
|
||||
let total = null;
|
||||
|
||||
let query = '';
|
||||
let searchDebounceTimer: ReturnType<typeof setTimeout>;
|
||||
let orderBy = 'created_at'; // default sort key
|
||||
let direction = 'asc'; // default sort order
|
||||
|
||||
@@ -97,13 +98,21 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: if (query) {
|
||||
page = 1;
|
||||
$: if (query !== undefined) {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
searchDebounceTimer = setTimeout(() => {
|
||||
page = 1;
|
||||
getUserList();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
$: if (query !== null && page !== null && orderBy !== null && direction !== null) {
|
||||
$: if (page !== null && orderBy !== null && direction !== null) {
|
||||
getUserList();
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
clearTimeout(searchDebounceTimer);
|
||||
});
|
||||
</script>
|
||||
|
||||
<ConfirmDialog
|
||||
|
||||
Reference in New Issue
Block a user