From b882cb0c3f662fdddb318c168ae8cdf8f93c5fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Tamargo?= Date: Mon, 4 Nov 2024 12:01:24 +0100 Subject: [PATCH] Sort special icons before per-site when editing links On the sidebar, we only show the default per-site icon if none of the special icons apply. On the editing page, we were doing the other way around. Consolidating it seems sensible and if so we should do the special icons first, since overriding per-page ones is part of their whole point. --- root/static/scripts/edit/externalLinks.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/root/static/scripts/edit/externalLinks.js b/root/static/scripts/edit/externalLinks.js index 5805c0f0622..4fed3966d86 100644 --- a/root/static/scripts/edit/externalLinks.js +++ b/root/static/scripts/edit/externalLinks.js @@ -1429,13 +1429,7 @@ export class ExternalLink extends React.Component { const firstLink = props.relationships[0]; let faviconClass: string | void; - for (const key of Object.keys(FAVICON_CLASSES)) { - if (props.url.indexOf(key) > 0) { - faviconClass = FAVICON_CLASSES[key]; - break; - } - } - if (notEmpty && !faviconClass) { + if (notEmpty) { const isHomepage = props.relationships.some(link => { const linkType = link.type ? linkedEntities.link_type[link.type] @@ -1472,7 +1466,15 @@ export class ExternalLink extends React.Component { if (isReview) { faviconClass = 'review'; } else { - faviconClass = 'no'; + for (const key of Object.keys(FAVICON_CLASSES)) { + if (props.url.indexOf(key) > 0) { + faviconClass = FAVICON_CLASSES[key]; + break; + } + } + if (!faviconClass) { + faviconClass = 'no'; + } } } }