Skip to content

Commit ce2ff7b

Browse files
authored
Update fast-search-card.js
1 parent 69a8eaa commit ce2ff7b

File tree

1 file changed

+30
-52
lines changed

1 file changed

+30
-52
lines changed

dist/fast-search-card.js

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11588,71 +11588,49 @@ class FastSearchCard extends HTMLElement {
1158811588
});
1158911589
}
1159011590

11591-
// 🎯 NAVIGATE TO ACTION DETAIL - Event-Simulation mit Retry-Logik
11591+
// 🎯 NAVIGATE TO ACTION DETAIL - Finale, funktionierende Version
1159211592
navigateToActionDetail(actionId, actionDomain) {
1159311593
console.log(`🎯 Simulating click on ${actionDomain}: ${actionId}`);
1159411594

1159511595
// 1. Bestimme Ziel-Kategorie
1159611596
const targetCategory = this.getTargetCategoryForDomain(actionDomain);
1159711597

11598-
// 2. Wechsle Kategorie
11598+
// 2. Wechsle Kategorie und verlasse Detailansicht
1159911599
this.activeCategory = targetCategory;
11600-
11601-
// 3. Rendere Hauptansicht
1160211600
this.isDetailView = false;
1160311601
this.currentDetailItem = null;
11604-
this.render();
11605-
11606-
// 4. Starte Retry-Logik
11607-
this.tryFindAndClickItem(actionId, 0);
11608-
}
11609-
11610-
// 🔄 RETRY LOGIC für Item-Suche
11611-
tryFindAndClickItem(actionId, attempt) {
11612-
const maxAttempts = 5;
11613-
11614-
// 🔧 KORRIGIERT: Verwende die richtigen CSS-Selektoren
11615-
const viewMode = this.currentViewMode;
11616-
const itemSelector = viewMode === 'grid' ? '.device-card' : '.device-list-item';
11617-
const allItemsInView = this.shadowRoot.querySelectorAll(itemSelector);
1161811602

11619-
console.log(`🔄 Attempt ${attempt + 1}: Looking for items with selector: ${itemSelector}`);
11620-
console.log(`🔄 Attempt ${attempt + 1}: Found ${allItemsInView.length} items in ${viewMode} view`);
11621-
11622-
if (allItemsInView.length === 0 && attempt < maxAttempts) {
11623-
// Noch keine Items, nochmal versuchen
11624-
console.log(`⏳ No items found, retrying in 200ms...`);
11625-
setTimeout(() => {
11626-
this.tryFindAndClickItem(actionId, attempt + 1);
11627-
}, 200);
11628-
return;
11629-
}
11603+
// 3. ❗ ENTSCHEIDENDE ÄNDERUNG: Rufe die korrekte Funktion auf,
11604+
// um die Items für die neue Kategorie zu filtern und zu rendern.
11605+
this.showCurrentCategoryItems();
1163011606

11631-
// Items gefunden oder max attempts erreicht
11632-
if (allItemsInView.length > 0) {
11633-
// 🔍 DEBUG: Schauen was verfügbar ist
11634-
allItemsInView.forEach((item, index) => {
11635-
console.log(`🔍 Item ${index}:`, {
11636-
entity: item.dataset.entity,
11637-
id: item.dataset.id,
11638-
innerHTML: item.innerHTML.substring(0, 100) + '...'
11639-
});
11640-
});
11607+
// 4. Warte zuverlässig mit requestAnimationFrame, bis das Element da ist
11608+
const waitForElementAndClick = (selector, targetId, retries = 30) => {
11609+
const element = this.shadowRoot.querySelector(`${selector}[data-entity="${targetId}"]`);
1164111610

11642-
// Suche nach der Action
11643-
for (const item of allItemsInView) {
11644-
const itemId = item.dataset.entity || item.dataset.id;
11645-
console.log(`🔍 Checking: ${itemId} === ${actionId}`);
11646-
11647-
if (itemId === actionId) {
11648-
console.log(`✅ Found item after ${attempt + 1} attempts, simulating click`);
11649-
item.click();
11650-
return;
11651-
}
11611+
// Wenn Element gefunden, klicken und aufhören
11612+
if (element) {
11613+
console.log(`✅ Element ${targetId} gefunden! Klick wird ausgeführt.`);
11614+
element.click();
11615+
return;
1165211616
}
11653-
}
11654-
11655-
console.warn(`❌ Item not found for: ${actionId} after ${attempt + 1} attempts`);
11617+
11618+
// Wenn Versuche aufgebraucht, abbrechen
11619+
if (retries <= 0) {
11620+
console.warn(`❌ Element ${targetId} wurde nach mehreren Versuchen nicht gefunden.`);
11621+
return;
11622+
}
11623+
11624+
// Nächsten Versuch im nächsten Browser-Render-Frame planen (zuverlässiger als setTimeout)
11625+
requestAnimationFrame(() => {
11626+
waitForElementAndClick(selector, targetId, retries - 1);
11627+
});
11628+
};
11629+
11630+
// Starte den Warte-Prozess
11631+
const viewMode = this.currentViewMode;
11632+
const itemSelector = viewMode === 'grid' ? '.device-card' : '.device-list-item';
11633+
waitForElementAndClick(itemSelector, actionId);
1165611634
}
1165711635

1165811636
// 🎯 GET TARGET CATEGORY FOR DOMAIN

0 commit comments

Comments
 (0)