diff --git a/pkg/interface/chat/src/js/components/lib/group-item.js b/pkg/interface/chat/src/js/components/lib/group-item.js index 4ad159b644..37f80ab545 100644 --- a/pkg/interface/chat/src/js/components/lib/group-item.js +++ b/pkg/interface/chat/src/js/components/lib/group-item.js @@ -17,7 +17,30 @@ export class GroupItem extends Component { let first = (props.index === 0) ? "pt1" : "pt4" - let channelItems = channels.map((each, i) => { + let channelItems = channels.sort((a, b) => { + if (props.index === "/~/") { + let aPreview = props.messagePreviews[a]; + let bPreview = props.messagePreviews[b]; + let aWhen = !!aPreview ? aPreview.when : 0; + let bWhen = !!bPreview ? bPreview.when : 0; + + return bWhen - aWhen; + } else { + let aAssociation = a in props.chatMetadata ? props.chatMetadata[a] : {}; + let bAssociation = b in props.chatMetadata ? props.chatMetadata[b] : {}; + let aTitle = a; + let bTitle = b; + if (aAssociation.metadata && aAssociation.metadata.title) { + aTitle = (aAssociation.metadata.title !== "") + ? aAssociation.metadata.title : a; + } + if (bAssociation.metadata && bAssociation.metadata.title) { + bTitle = + bAssociation.metadata.title !== "" ? bAssociation.metadata.title : b; + } + return aTitle.toLowerCase().localeCompare(bTitle.toLowerCase()); + } + }).map((each, i) => { let unread = props.unreads[each]; let title = each.substr(1); if ( diff --git a/pkg/interface/chat/src/js/components/sidebar.js b/pkg/interface/chat/src/js/components/sidebar.js index 5f9820a4c7..8962924ba7 100644 --- a/pkg/interface/chat/src/js/components/sidebar.js +++ b/pkg/interface/chat/src/js/components/sidebar.js @@ -68,9 +68,6 @@ export class Sidebar extends Component { .map((each, i) => { let channels = groupedChannels[each] || []; if (channels.length === 0) return; - if (groupedChannels["/~/"] && groupedChannels["/~/"].length !== 0) { - i = i + 1; - } return(