mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-02 08:40:53 +03:00
fix(frontend): send empty sync is not allowed (#2716)
…d files The syncFiles function in multiple files has been updated to only sync connections that have selected files. This change improves the efficiency of the syncing process and ensures that only relevant connections are synced. # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
76918202fa
commit
18d594493a
@ -89,7 +89,11 @@ export const BrainRecapStep = (): JSX.Element => {
|
||||
<div className={styles.cards_wrapper}>
|
||||
<BrainRecapCard
|
||||
label="Connection"
|
||||
number={openedConnections.length}
|
||||
number={
|
||||
openedConnections.filter(
|
||||
(connection) => connection.selectedFiles.files.length
|
||||
).length
|
||||
}
|
||||
/>
|
||||
<BrainRecapCard
|
||||
label="URL"
|
||||
|
@ -46,9 +46,11 @@ export const useBrainCreationApi = () => {
|
||||
|
||||
await Promise.all([...uploadPromises, ...crawlPromises]);
|
||||
await Promise.all(
|
||||
openedConnections.map(async (openedConnection) => {
|
||||
await syncFiles(openedConnection, brainId);
|
||||
})
|
||||
openedConnections
|
||||
.filter((connection) => connection.selectedFiles.files.length)
|
||||
.map(async (openedConnection) => {
|
||||
await syncFiles(openedConnection, brainId);
|
||||
})
|
||||
);
|
||||
setKnowledgeToFeed([]);
|
||||
};
|
||||
|
@ -45,21 +45,23 @@ export const useFeedBrainHandler = () => {
|
||||
const existingConnections = await getActiveSyncsForBrain(brainId);
|
||||
|
||||
await Promise.all(
|
||||
openedConnections.map(async (openedConnection) => {
|
||||
const existingConnectionIds = existingConnections.map(
|
||||
(connection) => connection.id
|
||||
);
|
||||
if (
|
||||
!openedConnection.id ||
|
||||
!existingConnectionIds.includes(openedConnection.id)
|
||||
) {
|
||||
await syncFiles(openedConnection, brainId);
|
||||
} else if (!openedConnection.selectedFiles.files.length) {
|
||||
await deleteActiveSync(openedConnection.id);
|
||||
} else {
|
||||
await updateActiveSync(openedConnection);
|
||||
}
|
||||
})
|
||||
openedConnections
|
||||
.filter((connection) => connection.selectedFiles.files.length)
|
||||
.map(async (openedConnection) => {
|
||||
const existingConnectionIds = existingConnections.map(
|
||||
(connection) => connection.id
|
||||
);
|
||||
if (
|
||||
!openedConnection.id ||
|
||||
!existingConnectionIds.includes(openedConnection.id)
|
||||
) {
|
||||
await syncFiles(openedConnection, brainId);
|
||||
} else if (!openedConnection.selectedFiles.files.length) {
|
||||
await deleteActiveSync(openedConnection.id);
|
||||
} else {
|
||||
await updateActiveSync(openedConnection);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
|
Loading…
Reference in New Issue
Block a user