feat: wrap paginationMode in getList check

This commit is contained in:
karishmas6
2024-10-28 06:44:56 +05:30
parent 4aac64d30c
commit 163083df34

View File

@@ -197,7 +197,9 @@ export const BrowserWindow = () => {
} }
} }
if (paginationMode && getList) { if (getList === true) {
// Handle pagination mode logic only when a list is being processed
if (paginationMode) {
// Only allow selection in pagination mode if type is not empty, 'scrollDown', or 'scrollUp' // Only allow selection in pagination mode if type is not empty, 'scrollDown', or 'scrollUp'
if (paginationType !== '' && paginationType !== 'scrollDown' && paginationType !== 'scrollUp' && paginationType !== 'none') { if (paginationType !== '' && paginationType !== 'scrollDown' && paginationType !== 'scrollUp' && paginationType !== 'none') {
setPaginationSelector(highlighterData.selector); setPaginationSelector(highlighterData.selector);
@@ -206,19 +208,20 @@ export const BrowserWindow = () => {
return; return;
} }
if (getList === true && !listSelector) { // If no listSelector is set yet, set the listSelector
if (!listSelector) {
setListSelector(highlighterData.selector); setListSelector(highlighterData.selector);
notify(`info`, `List selected succesfully. Select the text data for extraction.`) notify(`info`, `List selected successfully. Select the text data for extraction.`);
setCurrentListId(Date.now()); setCurrentListId(Date.now());
setFields({}); setFields({});
} else if (getList === true && listSelector && currentListId) { } else if (listSelector && currentListId) {
const attribute = options[0].value; const attribute = options[0].value;
const data = attribute === 'href' ? highlighterData.elementInfo?.url || '' : const data = attribute === 'href' ? highlighterData.elementInfo?.url || '' :
attribute === 'src' ? highlighterData.elementInfo?.imageUrl || '' : attribute === 'src' ? highlighterData.elementInfo?.imageUrl || '' :
highlighterData.elementInfo?.innerText || ''; highlighterData.elementInfo?.innerText || '';
// Add fields to the list // Add fields to the list
if (options.length === 1) { if (options.length === 1) {
const attribute = options[0].value;
const newField: TextStep = { const newField: TextStep = {
id: Date.now(), id: Date.now(),
type: 'text', type: 'text',
@@ -239,6 +242,7 @@ export const BrowserWindow = () => {
return updatedFields; return updatedFields;
}); });
// Add new field and update the list step
if (listSelector) { if (listSelector) {
addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector }); addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector });
} }
@@ -253,6 +257,8 @@ export const BrowserWindow = () => {
} }
} }
} }
}
} }
}; };