inline updateList

This commit is contained in:
Simon Knott 2024-07-26 15:45:17 +02:00
parent b95b435e01
commit c7b8a7b766
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -224,25 +224,6 @@ export const UIModeView: React.FC<{}> = ({
}; };
}, [testServerConnection]); }, [testServerConnection]);
const updateList = React.useCallback(async () => {
if (!testServerConnection || !teleSuiteUpdater)
return;
commandQueue.current = commandQueue.current.then(async () => {
setIsLoading(true);
try {
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert });
teleSuiteUpdater.processListReport(result.report);
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
} finally {
setIsLoading(false);
}
});
await commandQueue.current;
}, [testServerConnection, teleSuiteUpdater]);
// Update project filter default values. // Update project filter default values.
React.useEffect(() => { React.useEffect(() => {
if (!testModel) if (!testModel)
@ -345,7 +326,19 @@ export const UIModeView: React.FC<{}> = ({
if (!testServerConnection || !teleSuiteUpdater) if (!testServerConnection || !teleSuiteUpdater)
return; return;
const disposable = testServerConnection.onTestFilesChanged(async params => { const disposable = testServerConnection.onTestFilesChanged(async params => {
await updateList(); commandQueue.current = commandQueue.current.then(async () => {
setIsLoading(true);
try {
const result = await testServerConnection.listTests({ projects: queryParams.projects, locations: queryParams.args, grep: queryParams.grep, grepInvert: queryParams.grepInvert });
teleSuiteUpdater.processListReport(result.report);
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
} finally {
setIsLoading(false);
}
});
await commandQueue.current;
const testModel = teleSuiteUpdater.asModel(); const testModel = teleSuiteUpdater.asModel();
const testTree = new TestTree('', testModel.rootSuite, testModel.loadErrors, projectFilters, pathSeparator); const testTree = new TestTree('', testModel.rootSuite, testModel.loadErrors, projectFilters, pathSeparator);
@ -372,7 +365,7 @@ export const UIModeView: React.FC<{}> = ({
runTests('queue-if-busy', new Set(testIds)); runTests('queue-if-busy', new Set(testIds));
}); });
return () => disposable.dispose(); return () => disposable.dispose();
}, [runTests, updateList, testServerConnection, watchAll, watchedTreeIds, teleSuiteUpdater, projectFilters]); }, [runTests, testServerConnection, watchAll, watchedTreeIds, teleSuiteUpdater, projectFilters]);
// Shortcuts. // Shortcuts.
React.useEffect(() => { React.useEffect(() => {