groups: pass new contacts obj, fix pending

Also uncovers why pending array wasn't matching.

Fixes urbit/landscape#422
Fixes urbit/landscape#312
This commit is contained in:
Matilde Park 2021-02-12 16:24:46 -05:00
parent 6c2d935913
commit 5b62417e49
2 changed files with 14 additions and 6 deletions

View File

@ -40,7 +40,9 @@ export function GroupsPane(props: GroupsPaneProps) {
const relativePath = (path: string) => baseUrl + path;
const groupPath = getGroupFromWorkspace(workspace);
const groupContacts = (groupPath && contacts[groupPath]) || undefined;
const groupContacts = Object.assign({}, ...Array.from(groups?.[groupPath]?.members ?? []).filter(e => contacts[`~${e}`]).map(e => {
return {[e]: contacts[`~${e}`]};
})) || {};
const rootIdentity = contacts?.["/~/default"]?.[window.ship];
const groupAssociation =
(groupPath && associations.groups[groupPath]) || undefined;

View File

@ -33,10 +33,12 @@ import { StatelessAsyncAction } from '~/views/components/StatelessAsyncAction';
import styled from 'styled-components';
import useLocalState from '~/logic/state/local';
const TruncText = styled(Box)`
const TruncText = styled(Text)`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
min-width: 0;
`;
type Participant = Contact & { patp: string; pending: boolean };
@ -57,8 +59,10 @@ function getParticipants(cs: Contacts, group: Group) {
patp,
pending: false
}));
const members: Participant[] = _.map(Array.from(group.members), m =>
emptyContact(m, false)
const members: Participant[] = _.map(
Array.from(group.members)
.filter(e => group?.policy?.invite?.pending ? !group.policy.invite.pending.has(e) : true), m =>
emptyContact(m, false)
);
const allMembers = _.unionBy(contacts, members, 'patp');
const pending: Participant[] =
@ -305,11 +309,13 @@ function Participant(props: {
return (
<>
<Box>{avatar}</Box>
<Col justifyContent="center" gapY="1" height="100%">
<Col justifyContent="center" gapY="1" height="100%" minWidth='0'>
{hasNickname && (
<TruncText title={contact.nickname} maxWidth="85%" color="black">
<Row minWidth='0' flexShrink='1'>
<TruncText title={contact.nickname} color="black">
{contact.nickname}
</TruncText>
</Row>
)}
<Text title={contact.patp} color="gray" fontFamily="mono">
{cite(contact.patp)}