Skip to content

Commit df02fbb

Browse files
committed
Enhance link display logic in HomeApp
- Added functionality to hide the links section when no links are available, improving user experience. - Ensured the links section is displayed when links are present. - Updated error handling for non-array links input.
1 parent 1710a46 commit df02fbb

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

dt-apps/dt-home/assets/js/home-app.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,31 @@ class HomeApp {
202202
displayLinks(links) {
203203
let html = '';
204204

205+
const linksSection = document.querySelector('.links-section');
206+
205207
// Safety check: ensure links is an array
206208
if (!Array.isArray(this.links)) {
207209
console.error('Links is not an array:', this.links);
208210
html =
209211
'<div class="link-item"><div class="link-item__title">Error loading links.</div></div>';
210212
} else if (this.links.length === 0) {
211-
html =
212-
'<div class="link-item"><div class="link-item__title">No links available.</div></div>';
213+
// When there are no links, hide the entire links section (including header)
214+
if (linksSection) {
215+
linksSection.style.display = 'none';
216+
}
217+
218+
const linksListEmpty = document.getElementById('links-list');
219+
if (linksListEmpty) {
220+
linksListEmpty.innerHTML = '';
221+
}
222+
223+
return;
213224
} else {
225+
// Ensure the links section is visible when there are links
226+
if (linksSection) {
227+
linksSection.style.display = '';
228+
}
229+
214230
for (const link of this.links) {
215231
// Escape HTML to prevent XSS
216232
const safeUrl = (link.url || '#')

0 commit comments

Comments
 (0)