Ensure Recently-Added library sections are treated like default kefin sections including the Restore Defaults button

This commit is contained in:
HighImKevin committed 2026-10-21 07:41:58 -04:00
1 parent f83eb5cd20
commit e86d0378d7
2 files changed
+95 -51

No files matched your search

+16 -3
View File
@@ -3951,10 +3951,15 @@
return null;
}
function isRecentlyAddedDefaultSection(section) {
return String(section?.id || '').startsWith('recently-added-');
}
function isKefinDefaultSection(section, context) {
if (context?.isCustomSection === true) return false;
const id = section?.id;
if (!id) return false;
if (isRecentlyAddedDefaultSection(section)) return true;
return getCanonicalDefaultSection(id) != null;
}
@@ -4693,12 +4698,20 @@
showSectionImportPasteModal(apply);
}
function handleHeaderRestoreDefaults(modalInstance) {
async function handleHeaderRestoreDefaults(modalInstance) {
const state = modalInstance?._hsaeState;
const dialog = modalInstance?.dialogContainer || modalInstance?.dialogContent;
if (!state || !dialog) return;
const sectionId = state.section?.id;
const canonical = getCanonicalDefaultSection(sectionId);
let canonical = getCanonicalDefaultSection(sectionId);
if (!canonical && isRecentlyAddedDefaultSection(state.section)) {
try {
canonical = await window.KefinHomeScreen?.buildRecentlyAddedDefaultSection?.(sectionId);
} catch (error) {
console.warn('[KefinTweaks] Failed to build Recently Added default:', error);
canonical = null;
}
}
if (!canonical) {
showHsaeToast('No default found for this section');
syncHeaderActions(modalInstance);
@@ -4789,7 +4802,7 @@
if (exportBtn) exportBtn.hidden = isDefault;
if (restoreBtn) {
restoreBtn.hidden = !isDefault;
if (isDefault && !getCanonicalDefaultSection(section.id)) {
if (isDefault && !getCanonicalDefaultSection(section.id) && !isRecentlyAddedDefaultSection(section)) {
restoreBtn.hidden = true;
}
}