Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(queryPreviewList): repeated query loading issue #1566

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ describe('testing QueryPreviewList', () => {
expect(queryPreviews.wrappers).toHaveLength(1);
expect(queryPreviews.at(0).text()).toEqual('shoes - Crazy shoes');
});

it('load next batch when it contains duplicates', async () => {
const { getQueryPreviewItemWrappers, reRender, wrapper } = renderQueryPreviewList({
queriesPreviewInfo: [{ query: 'shirt' }, { query: 'jeans' }],
results: {
shirt: [createResultStub('Cool shirt')],
jeans: [createResultStub('Sick jeans')],
dress: [createResultStub('cool dress ')]
}
});
await reRender();
let queryPreviews = getQueryPreviewItemWrappers();
expect(queryPreviews.wrappers).toHaveLength(2);
wrapper.setProps({
queriesPreviewInfo: [{ query: 'shirt' }, { query: 'jeans' }, { query: 'dress' }]
});
await reRender();
queryPreviews = getQueryPreviewItemWrappers();
expect(queryPreviews.wrappers).toHaveLength(3);
});
});

interface RenderQueryPreviewListOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@
queries,
(newQueries: string[], oldQueries: string[] | undefined) => {
if (newQueries.toString() !== oldQueries?.toString()) {
queriesStatus.value = {};
for (const key of Object.keys(queriesStatus.value)) {
if (!newQueries.includes(key)) {
delete queriesStatus.value[key];
}
}
loadNext();
}
},
Expand Down
Loading