diff --git a/configuration/homeScreen-configuration.js b/configuration/homeScreen-configuration.js
index fa0478e..6096570 100644
--- a/configuration/homeScreen-configuration.js
+++ b/configuration/homeScreen-configuration.js
@@ -4930,48 +4930,42 @@ window.KefinTweaksConfig = ${JSON.stringify(configToBackup, null, 2)};`;
});
confirmBtn?.addEventListener('click', async () => {
- const selectedIndices = Array.from(dialog.querySelectorAll('.import-community-check:checked'))
+ const selectedIndices = Array.from(dialog.querySelectorAll('.import-community-check:checked:not(:disabled)'))
.map(c => parseInt(c.dataset.index, 10));
if (selectedIndices.length === 0) {
- showToast('Please select at least one section to import.');
+ showToast('Please select at least one new section to import.');
return;
}
- if (!currentConfig.CUSTOM_SECTION_GROUPS) currentConfig.CUSTOM_SECTION_GROUPS = [];
-
const selectedSections = selectedIndices.map(i => {
const section = JSON.parse(JSON.stringify(collection.sections[i]));
return convertToHomeScreenSection(section);
});
- const importedGroup = {
- name: collection.name || 'Imported Collection',
- author: collection.author,
- description: collection.description,
- sections: selectedSections.map(section => {
- if (section.id && sectionIdExists(currentConfig, section.id)) {
- section.id = `${section.id}_community_${Date.now()}_${Math.floor(Math.random() * 1000)}`;
- }
- return section;
- })
- };
+ const { importedCount, skippedCount } = importCommunitySectionsIntoConfig(
+ collection,
+ selectedSections
+ );
- currentConfig.CUSTOM_SECTION_GROUPS.push(importedGroup);
- const importedCount = selectedSections.length;
+ if (importedCount === 0) {
+ showToast(skippedCount > 0
+ ? 'Selected sections are already imported.'
+ : 'Nothing new to import.');
+ return;
+ }
- if (importedCount > 0) {
- confirmBtn.disabled = true;
- try {
- await saveConfig(currentConfig);
- window.ModalSystem.close(COMMUNITY_IMPORT_MODAL_ID);
- showToast(`Successfully imported ${importedCount} sections. Refreshing...`);
- refreshMainModal();
- } catch (e) {
- ERR('Error importing community sections:', e);
- showToast('Error importing sections');
- confirmBtn.disabled = false;
- }
+ confirmBtn.disabled = true;
+ try {
+ await saveConfig(currentConfig);
+ window.ModalSystem.close(COMMUNITY_IMPORT_MODAL_ID);
+ const skipNote = skippedCount > 0 ? ` (${skippedCount} already present)` : '';
+ showToast(`Successfully imported ${importedCount} section${importedCount !== 1 ? 's' : ''}${skipNote}. Refreshing...`);
+ refreshMainModal();
+ } catch (e) {
+ ERR('Error importing community sections:', e);
+ showToast('Error importing sections');
+ confirmBtn.disabled = false;
}
});
}
@@ -4992,19 +4986,28 @@ window.KefinTweaksConfig = ${JSON.stringify(configToBackup, null, 2)};`;
return;
}
+ const existingGroup = findCommunityImportGroup(currentConfig.CUSTOM_SECTION_GROUPS || [], collection);
+ let availableCount = 0;
+
sectionsList.innerHTML = `
${collection.sections.map((s, i) => {
const name = escapeHtml(s.name || 'Unnamed');
+ const alreadyImported = isCommunitySectionInGroup(existingGroup, s);
+ if (!alreadyImported) availableCount++;
const desc = s.description
? `
${escapeHtml(String(s.description))}
`
: '';
+ const importedNote = alreadyImported
+ ? `
Already imported
`
+ : '';
return `
-