Merge pull request #2640 from urbit/mp/groupify-2-dms-below

chat: DMs repositioned below grouped chats
This commit is contained in:
ixv 2020-04-02 10:48:25 -07:00 committed by GitHub
commit 1d59ca7a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 6 deletions

View File

@ -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 (

View File

@ -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(
<GroupItem
key={i}
@ -86,7 +83,7 @@ export class Sidebar extends Component {
)
});
if (groupedChannels["/~/"] && groupedChannels["/~/"].length !== 0) {
groupedItems.unshift(
groupedItems.push(
<GroupItem
association={"/~/"}
chatMetadata={props.associations["chat"]}
@ -94,7 +91,7 @@ export class Sidebar extends Component {
inbox={props.inbox}
station={props.station}
unreads={props.unreads}
index={0}
index={"/~/"}
key={"/~/"}
{...props}
/>