mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-30 18:13:23 +08:00
Merge pull request #22223 from mvdbeek/fix-history-list-race
[26.0] Fix race condition in history list when rapidly changing search filters
This commit is contained in:
@@ -92,6 +92,7 @@ const limit = ref(24);
|
||||
const offset = ref(0);
|
||||
const loading = ref(true);
|
||||
const overlay = ref(false);
|
||||
let loadGeneration = 0;
|
||||
const filterText = ref("");
|
||||
const totalHistories = ref(0);
|
||||
const showAdvanced = ref(false);
|
||||
@@ -219,6 +220,8 @@ function onToggleDeleted() {
|
||||
* @param {boolean} silent - Whether to skip loading indicators
|
||||
*/
|
||||
async function load(overlayLoading: boolean = false, silent: boolean = false) {
|
||||
const thisGeneration = ++loadGeneration;
|
||||
|
||||
if (!silent) {
|
||||
if (overlayLoading) {
|
||||
overlay.value = true;
|
||||
@@ -242,32 +245,37 @@ async function load(overlayLoading: boolean = false, silent: boolean = false) {
|
||||
};
|
||||
|
||||
try {
|
||||
let data;
|
||||
let total;
|
||||
|
||||
if (myView.value) {
|
||||
const { data, total } = await getMyHistories(options);
|
||||
|
||||
historiesLoaded.value = data;
|
||||
totalHistories.value = total;
|
||||
({ data, total } = await getMyHistories(options));
|
||||
} else if (sharedView.value) {
|
||||
const { data, total } = await getSharedHistories(options);
|
||||
|
||||
historiesLoaded.value = data;
|
||||
totalHistories.value = total;
|
||||
({ data, total } = await getSharedHistories(options));
|
||||
} else if (publishedView.value) {
|
||||
const { data, total } = await getPublishedHistories(options);
|
||||
|
||||
historiesLoaded.value = data;
|
||||
totalHistories.value = total;
|
||||
({ data, total } = await getPublishedHistories(options));
|
||||
} else if (archivedView.value) {
|
||||
const { data, total } = await getArchivedHistories(options);
|
||||
({ data, total } = await getArchivedHistories(options));
|
||||
}
|
||||
|
||||
if (thisGeneration !== loadGeneration) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data !== undefined) {
|
||||
historiesLoaded.value = data;
|
||||
totalHistories.value = total;
|
||||
totalHistories.value = total!;
|
||||
}
|
||||
} catch (error) {
|
||||
if (thisGeneration !== loadGeneration) {
|
||||
return;
|
||||
}
|
||||
Toast.error(`Failed to load histories: ${errorMessageAsString(error)}`);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
overlay.value = false;
|
||||
if (thisGeneration === loadGeneration) {
|
||||
loading.value = false;
|
||||
overlay.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user