Skip to content

Commit

Permalink
fix: make suggestions lazier
Browse files Browse the repository at this point in the history
  • Loading branch information
maxakuru committed Sep 18, 2024
1 parent 21b2b7b commit a96d42e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
27 changes: 15 additions & 12 deletions tools/oversight/elements/url-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class URLSelector extends HTMLElement {
`;
}

async connectedCallback() {
connectedCallback() {
this.innerHTML = this.template;
const datalist = this.querySelector('datalist');
const input = this.querySelector('input');
Expand All @@ -56,22 +56,25 @@ export default class URLSelector extends HTMLElement {
}
});
} else {
const resp = await fetch('https://rum.fastly-aem.page/domains?suggested=true', {
fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
accept: 'application/json',
authorization: `Bearer ${token}`,
},
});
if (!resp.ok) {
}).then(async (resp) => {
if (!resp.ok) {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
}).catch(() => {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
});
}

input.addEventListener('focus', () => {
Expand Down
27 changes: 15 additions & 12 deletions tools/rum/elements/url-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class URLSelector extends HTMLElement {
`;
}

async connectedCallback() {
connectedCallback() {
this.innerHTML = this.template;
const datalist = this.querySelector('datalist');
const input = this.querySelector('input');
Expand All @@ -46,22 +46,25 @@ export default class URLSelector extends HTMLElement {
input.disabled = true;
datalist.remove();
} else {
const resp = await fetch('https://rum.fastly-aem.page/domains?suggested=true', {
fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
accept: 'application/json',
authorization: `Bearer ${token}`,
},
});
if (!resp.ok) {
}).then(async (resp) => {
if (!resp.ok) {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
}).catch(() => {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
});
}

input.addEventListener('focus', () => {
Expand Down

0 comments on commit a96d42e

Please sign in to comment.