diff --git a/pkg/interface/chat/src/js/lib/util.js b/pkg/interface/chat/src/js/lib/util.js index 88bbda6fad..db5a4ce461 100644 --- a/pkg/interface/chat/src/js/lib/util.js +++ b/pkg/interface/chat/src/js/lib/util.js @@ -138,14 +138,14 @@ export function alphabetiseAssociations(associations) { Object.keys(associations).sort((a, b) => { let aName = a.substr(1); let bName = b.substr(1); - if (a.metadata && a.metadata.title) { - aName = a.metadata.title !== "" - ? a.metadata.title + if (associations[a].metadata && associations[a].metadata.title) { + aName = associations[a].metadata.title !== "" + ? associations[a].metadata.title : a.substr(1); } - if (b.metadata && b.metadata.title) { - bName = b.metadata.title !== "" - ? b.metadata.title + if (associations[b].metadata && associations[b].metadata.title) { + bName = associations[b].metadata.title !== "" + ? associations[b].metadata.title : b.substr(1); } return aName.toLowerCase().localeCompare(bName.toLowerCase()); diff --git a/pkg/interface/link/src/js/lib/util.js b/pkg/interface/link/src/js/lib/util.js index 5870dcac3a..8c83886b77 100644 --- a/pkg/interface/link/src/js/lib/util.js +++ b/pkg/interface/link/src/js/lib/util.js @@ -171,14 +171,14 @@ export function alphabetiseAssociations(associations) { Object.keys(associations).sort((a, b) => { let aName = a.substr(1); let bName = b.substr(1); - if (a.metadata && a.metadata.title) { - aName = a.metadata.title !== "" - ? a.metadata.title + if (associations[a].metadata && associations[a].metadata.title) { + aName = associations[a].metadata.title !== "" + ? associations[a].metadata.title : a.substr(1); } - if (b.metadata && b.metadata.title) { - bName = b.metadata.title !== "" - ? b.metadata.title + if (associations[b].metadata && associations[b].metadata.title) { + bName = associations[b].metadata.title !== "" + ? associations[b].metadata.title : b.substr(1); } return aName.toLowerCase().localeCompare(bName.toLowerCase()); diff --git a/pkg/interface/publish/src/js/lib/util.js b/pkg/interface/publish/src/js/lib/util.js index 7407d895f8..fe4b3ad61f 100644 --- a/pkg/interface/publish/src/js/lib/util.js +++ b/pkg/interface/publish/src/js/lib/util.js @@ -97,14 +97,14 @@ export function alphabetiseAssociations(associations) { Object.keys(associations).sort((a, b) => { let aName = a.substr(1); let bName = b.substr(1); - if (a.metadata && a.metadata.title) { - aName = a.metadata.title !== "" - ? a.metadata.title + if (associations[a].metadata && associations[a].metadata.title) { + aName = associations[a].metadata.title !== "" + ? associations[a].metadata.title : a.substr(1); } - if (b.metadata && b.metadata.title) { - bName = b.metadata.title !== "" - ? b.metadata.title + if (associations[b].metadata && associations[b].metadata.title) { + bName = associations[b].metadata.title !== "" + ? associations[b].metadata.title : b.substr(1); } return aName.toLowerCase().localeCompare(bName.toLowerCase());