fix(ui): stop the chat input attach menus from fetching twice on open (#27461)
This commit is contained in:
@@ -25,11 +25,13 @@
|
||||
let itemsLoading = false;
|
||||
let allItemsLoaded = false;
|
||||
let initialized = false;
|
||||
let searchedQuery = '';
|
||||
let searchDebounceTimer: ReturnType<typeof setTimeout>;
|
||||
let requestId = 0;
|
||||
|
||||
$: if (initialized) {
|
||||
query;
|
||||
// Only re-run the search when the query actually changes. Flipping `initialized`
|
||||
// after the initial load would otherwise trigger a second, identical request.
|
||||
$: if (initialized && query !== searchedQuery) {
|
||||
scheduleSearch();
|
||||
}
|
||||
|
||||
@@ -40,6 +42,7 @@
|
||||
|
||||
const init = async () => {
|
||||
requestId += 1;
|
||||
searchedQuery = query;
|
||||
page = 1;
|
||||
items = [];
|
||||
selectedIdx = 0;
|
||||
|
||||
@@ -23,11 +23,13 @@
|
||||
let itemsLoading = false;
|
||||
let allItemsLoaded = false;
|
||||
let initialized = false;
|
||||
let searchedQuery = '';
|
||||
let searchDebounceTimer: ReturnType<typeof setTimeout>;
|
||||
let requestId = 0;
|
||||
|
||||
$: if (initialized) {
|
||||
query;
|
||||
// Only re-run the search when the query actually changes. Flipping `initialized`
|
||||
// after the initial load would otherwise trigger a second, identical request.
|
||||
$: if (initialized && query !== searchedQuery) {
|
||||
scheduleSearch();
|
||||
}
|
||||
|
||||
@@ -38,6 +40,7 @@
|
||||
|
||||
const init = async () => {
|
||||
requestId += 1;
|
||||
searchedQuery = query;
|
||||
page = 0;
|
||||
items = [];
|
||||
selectedIdx = 0;
|
||||
|
||||
@@ -100,11 +100,13 @@
|
||||
let itemsLoading = false;
|
||||
let allItemsLoaded = false;
|
||||
let initialized = false;
|
||||
let searchedQuery = '';
|
||||
let searchDebounceTimer: ReturnType<typeof setTimeout>;
|
||||
let requestId = 0;
|
||||
|
||||
$: if (initialized) {
|
||||
query;
|
||||
// Only re-run the search when the query actually changes. Flipping `initialized`
|
||||
// after the initial load would otherwise trigger a second, identical request.
|
||||
$: if (initialized && query !== searchedQuery) {
|
||||
scheduleSearch();
|
||||
}
|
||||
|
||||
@@ -115,6 +117,7 @@
|
||||
|
||||
const init = async () => {
|
||||
requestId += 1;
|
||||
searchedQuery = query;
|
||||
reset();
|
||||
selectedItem = null;
|
||||
await tick();
|
||||
@@ -151,12 +154,6 @@
|
||||
total = res.total;
|
||||
const pageItems = res.items;
|
||||
|
||||
if ((pageItems ?? []).length === 0) {
|
||||
allItemsLoaded = true;
|
||||
} else {
|
||||
allItemsLoaded = false;
|
||||
}
|
||||
|
||||
if (items) {
|
||||
const existingIds = new Set(items.map((item) => item.id));
|
||||
const newItems = pageItems.filter((item) => !existingIds.has(item.id));
|
||||
@@ -164,6 +161,11 @@
|
||||
} else {
|
||||
items = pageItems;
|
||||
}
|
||||
|
||||
// The response reports the full count, so the end of the list is known without
|
||||
// probing for an empty page - otherwise a list shorter than one page would
|
||||
// immediately request the next one.
|
||||
allItemsLoaded = (pageItems ?? []).length === 0 || items.length >= (total ?? 0);
|
||||
}
|
||||
|
||||
itemsLoading = false;
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
let itemsLoading = false;
|
||||
let allItemsLoaded = false;
|
||||
let initialized = false;
|
||||
let searchedQuery = '';
|
||||
let searchDebounceTimer: ReturnType<typeof setTimeout>;
|
||||
let requestId = 0;
|
||||
|
||||
$: if (initialized) {
|
||||
query;
|
||||
// Only re-run the search when the query actually changes. Flipping `initialized`
|
||||
// after the initial load would otherwise trigger a second, identical request.
|
||||
$: if (initialized && query !== searchedQuery) {
|
||||
scheduleSearch();
|
||||
}
|
||||
|
||||
@@ -40,6 +42,7 @@
|
||||
|
||||
const init = async () => {
|
||||
requestId += 1;
|
||||
searchedQuery = query;
|
||||
page = 1;
|
||||
items = [];
|
||||
selectedIdx = 0;
|
||||
|
||||
Reference in New Issue
Block a user