feat: wrap paginationMode in getList check
This commit is contained in:
@@ -197,61 +197,67 @@ export const BrowserWindow = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paginationMode && getList) {
|
if (getList === true) {
|
||||||
// Only allow selection in pagination mode if type is not empty, 'scrollDown', or 'scrollUp'
|
// Handle pagination mode logic only when a list is being processed
|
||||||
if (paginationType !== '' && paginationType !== 'scrollDown' && paginationType !== 'scrollUp' && paginationType !== 'none') {
|
if (paginationMode) {
|
||||||
setPaginationSelector(highlighterData.selector);
|
// Only allow selection in pagination mode if type is not empty, 'scrollDown', or 'scrollUp'
|
||||||
addListStep(listSelector!, fields, currentListId || 0, { type: paginationType, selector: highlighterData.selector });
|
if (paginationType !== '' && paginationType !== 'scrollDown' && paginationType !== 'scrollUp' && paginationType !== 'none') {
|
||||||
}
|
setPaginationSelector(highlighterData.selector);
|
||||||
return;
|
addListStep(listSelector!, fields, currentListId || 0, { type: paginationType, selector: highlighterData.selector });
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
if (getList === true && !listSelector) {
|
}
|
||||||
setListSelector(highlighterData.selector);
|
|
||||||
notify(`info`, `List selected succesfully. Select the text data for extraction.`)
|
// If no listSelector is set yet, set the listSelector
|
||||||
setCurrentListId(Date.now());
|
if (!listSelector) {
|
||||||
setFields({});
|
setListSelector(highlighterData.selector);
|
||||||
} else if (getList === true && listSelector && currentListId) {
|
notify(`info`, `List selected successfully. Select the text data for extraction.`);
|
||||||
const attribute = options[0].value;
|
setCurrentListId(Date.now());
|
||||||
const data = attribute === 'href' ? highlighterData.elementInfo?.url || '' :
|
setFields({});
|
||||||
attribute === 'src' ? highlighterData.elementInfo?.imageUrl || '' :
|
} else if (listSelector && currentListId) {
|
||||||
highlighterData.elementInfo?.innerText || '';
|
const attribute = options[0].value;
|
||||||
// Add fields to the list
|
const data = attribute === 'href' ? highlighterData.elementInfo?.url || '' :
|
||||||
if (options.length === 1) {
|
attribute === 'src' ? highlighterData.elementInfo?.imageUrl || '' :
|
||||||
const attribute = options[0].value;
|
highlighterData.elementInfo?.innerText || '';
|
||||||
const newField: TextStep = {
|
|
||||||
id: Date.now(),
|
// Add fields to the list
|
||||||
type: 'text',
|
if (options.length === 1) {
|
||||||
label: `Label ${Object.keys(fields).length + 1}`,
|
const newField: TextStep = {
|
||||||
data: data,
|
id: Date.now(),
|
||||||
selectorObj: {
|
type: 'text',
|
||||||
selector: highlighterData.selector,
|
label: `Label ${Object.keys(fields).length + 1}`,
|
||||||
tag: highlighterData.elementInfo?.tagName,
|
data: data,
|
||||||
attribute
|
selectorObj: {
|
||||||
}
|
selector: highlighterData.selector,
|
||||||
};
|
tag: highlighterData.elementInfo?.tagName,
|
||||||
|
attribute
|
||||||
setFields(prevFields => {
|
}
|
||||||
const updatedFields = {
|
};
|
||||||
...prevFields,
|
|
||||||
[newField.id]: newField
|
setFields(prevFields => {
|
||||||
};
|
const updatedFields = {
|
||||||
return updatedFields;
|
...prevFields,
|
||||||
});
|
[newField.id]: newField
|
||||||
|
};
|
||||||
if (listSelector) {
|
return updatedFields;
|
||||||
addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector });
|
});
|
||||||
|
|
||||||
|
// Add new field and update the list step
|
||||||
|
if (listSelector) {
|
||||||
|
addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector });
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
setAttributeOptions(options);
|
||||||
|
setSelectedElement({
|
||||||
|
selector: highlighterData.selector,
|
||||||
|
info: highlighterData.elementInfo
|
||||||
|
});
|
||||||
|
setShowAttributeModal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
setAttributeOptions(options);
|
|
||||||
setSelectedElement({
|
|
||||||
selector: highlighterData.selector,
|
|
||||||
info: highlighterData.elementInfo
|
|
||||||
});
|
|
||||||
setShowAttributeModal(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user