diff --git a/pkg/interface/src/logic/reducers/contact-update.ts b/pkg/interface/src/logic/reducers/contact-update.ts index 44cbc6cfb..932852ece 100644 --- a/pkg/interface/src/logic/reducers/contact-update.ts +++ b/pkg/interface/src/logic/reducers/contact-update.ts @@ -59,18 +59,16 @@ const edit = (json: ContactUpdate, state: S) => { if (!field) { return; } - const contact = state.contacts?.[ship]; + const value = data['edit-field'][field]; - if(!contact) { - return; - } if(field === 'add-group') { - contact.groups.push(value); + state.contacts[ship].groups.push(value); } else if (field === 'remove-group') { - contact.groups = contact.groups.filter(g => g !== value); + state.contacts[ship].groups = + state.contacts[ship].groups.filter(g => g !== value); } else { - contact[field] = value; + state.contacts[ship][field] = value; } } }; diff --git a/pkg/interface/src/views/apps/chat/ChatResource.tsx b/pkg/interface/src/views/apps/chat/ChatResource.tsx index 5e8a35e95..6b47a4409 100644 --- a/pkg/interface/src/views/apps/chat/ChatResource.tsx +++ b/pkg/interface/src/views/apps/chat/ChatResource.tsx @@ -80,49 +80,52 @@ export function ChatResource(props: ChatResourceProps) { }, [station]); const [showBanner, setShowBanner] = useState(false); + const [hasLoadedAllowed, setHasLoadedAllowed] = useState(false); const [recipients, setRecipients] = useState([]); const res = resourceFromPath(groupPath); useEffect(() => { (async () => { - if (!res) { return; } - if (!group) { return; } - if (group.hidden) { - const members = _.compact(await Promise.all( - Array.from(group.members) - .map(s => { - const ship = `~${s}`; - if(s === window.ship) { - return Promise.resolve(null); - } - return props.api.contacts.fetchIsAllowed( - `~${window.ship}`, - 'personal', - ship, - true - ).then(isAllowed => { - return isAllowed ? null : ship; - }); - }) - )); + if (!res) { return; } + if (!group) { return; } + if (group.hidden) { + const members = _.compact(await Promise.all( + Array.from(group.members) + .map(s => { + const ship = `~${s}`; + if(s === window.ship) { + return Promise.resolve(null); + } + return props.api.contacts.fetchIsAllowed( + `~${window.ship}`, + 'personal', + ship, + true + ).then(isAllowed => { + return isAllowed ? null : ship; + }); + }) + )); + + if(members.length > 0) { + setShowBanner(true); + setRecipients(members); + } else { + setShowBanner(false); + } - if(members.length > 0) { - setShowBanner(true); - setRecipients(members); } else { - setShowBanner(false); + const groupShared = await props.api.contacts.fetchIsAllowed( + `~${window.ship}`, + 'personal', + res.ship, + true + ); + setShowBanner(!groupShared); } - } else { - const groupShared = await props.api.contacts.fetchIsAllowed( - `~${window.ship}`, - 'personal', - res.ship, - true - ); - setShowBanner(!groupShared); - } + setHasLoadedAllowed(true); })(); }, [groupPath]); @@ -151,7 +154,10 @@ export function ChatResource(props: ChatResourceProps) { history={props.history} graph={graph} unreadCount={unreadCount} - contacts={!showBanner ? contacts : modifiedContacts} + contacts={ + (!showBanner && hasLoadedAllowed) ? + contacts : modifiedContacts + } association={props.association} associations={props.associations} groups={props.groups} @@ -166,9 +172,13 @@ export function ChatResource(props: ChatResourceProps) { ref={chatInput} api={props.api} station={station} - ourContact={!showBanner ? ourContact : null} + ourContact={ + (!showBanner && hasLoadedAllowed) ? ourContact : null + } envelopes={[]} - contacts={contacts} + contacts={ + (!showBanner && hasLoadedAllowed) ? contacts : modifiedContacts + } onUnmount={appendUnsent} s3={props.s3} placeholder="Message..." diff --git a/pkg/interface/src/views/apps/chat/css/custom.css b/pkg/interface/src/views/apps/chat/css/custom.css index 85cb51c97..702106082 100644 --- a/pkg/interface/src/views/apps/chat/css/custom.css +++ b/pkg/interface/src/views/apps/chat/css/custom.css @@ -95,16 +95,8 @@ h2 { font-family: "Inter", sans-serif; } -.embed-container { - width: 100%; - height: 14rem; -} - .embed-container iframe { - max-width: 24rem; - width: 100%; - height: 100%; - max-height: 26rem; + max-width: 100%; } .mh-16 { diff --git a/pkg/interface/src/views/apps/profile/components/Profile.tsx b/pkg/interface/src/views/apps/profile/components/Profile.tsx index 77b3bc0d1..0072b591b 100644 --- a/pkg/interface/src/views/apps/profile/components/Profile.tsx +++ b/pkg/interface/src/views/apps/profile/components/Profile.tsx @@ -14,6 +14,7 @@ import { Button, Text } from "@tlon/indigo-react"; +import RichText from '~/views/components/RichText' import useLocalState from "~/logic/state/local"; import { useHistory } from "react-router-dom"; import {useTutorialModal} from "~/views/components/useTutorialModal"; @@ -65,8 +66,9 @@ export function Profile(props: any) { maxWidth="600px" width="100%"> + {ship === `~${window.ship}` ? ( - + <> - + ) : null} - + {contact?.status ?? ""} + overflow="hidden" display="inline-block" verticalAlign="middle">{contact?.status ?? ""} {cover} diff --git a/pkg/interface/src/views/components/Invite/index.tsx b/pkg/interface/src/views/components/Invite/index.tsx index fc6e9b192..c39c1d5e8 100644 --- a/pkg/interface/src/views/components/Invite/index.tsx +++ b/pkg/interface/src/views/components/Invite/index.tsx @@ -61,7 +61,7 @@ export function InviteItem(props: InviteItemProps) { if (props.groups?.[resource]?.hidden) { const { metadata } = associations.graph[resource]; - if (name.startsWith("dm--")) { + if (metadata?.module === 'chat') { history.push(`/~landscape/messages/resource/${metadata.module}${resource}`); } else { history.push(`/~landscape/home/resource/${metadata.module}${resource}`); @@ -126,7 +126,7 @@ export function InviteItem(props: InviteItemProps) { You are joining a DM with - {cite("~hastuc-dibtux")} + {cite(`~${invite!.ship}`)} diff --git a/pkg/interface/src/views/components/ProfileOverlay.tsx b/pkg/interface/src/views/components/ProfileOverlay.tsx index 367d81186..a77f3737d 100644 --- a/pkg/interface/src/views/components/ProfileOverlay.tsx +++ b/pkg/interface/src/views/components/ProfileOverlay.tsx @@ -14,6 +14,7 @@ import { ColProps, Icon } from '@tlon/indigo-react'; +import RichText from './RichText'; import { withLocalState } from '~/logic/state/local'; import { ProfileStatus } from './ProfileStatus'; @@ -132,7 +133,7 @@ class ProfileOverlay extends PureComponent { onClick={() => history.push(`/~profile/~${ship}`)}> {img} - + { contact={contact} /> ) : ( - + {contact?.status ? contact.status : ''} - + ) } diff --git a/pkg/interface/src/views/components/RichText.js b/pkg/interface/src/views/components/RichText.js index 4b40655f3..1ca377ece 100644 --- a/pkg/interface/src/views/components/RichText.js +++ b/pkg/interface/src/views/components/RichText.js @@ -33,10 +33,10 @@ const RichText = React.memo(({ disableRemoteContent, ...props }) => ( videoShown: false, oembedShown: false } : null; - if (hasProvider(linkProps.href)) { + if (!disableRemoteContent && hasProvider(linkProps.href)) { return ; } - + return {linkProps.children}; }, linkReference: (linkProps) => { diff --git a/pkg/interface/src/views/components/StatusBar.js b/pkg/interface/src/views/components/StatusBar.js index b674354a8..16a2e2666 100644 --- a/pkg/interface/src/views/components/StatusBar.js +++ b/pkg/interface/src/views/components/StatusBar.js @@ -107,7 +107,7 @@ const StatusBar = (props) => { width="auto" alignY="top" alignX="right" - flexShrink={0} + flexShrink={'0'} options={ 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; diff --git a/pkg/interface/src/views/landscape/components/NewChannel.tsx b/pkg/interface/src/views/landscape/components/NewChannel.tsx index deff84835..91d375042 100644 --- a/pkg/interface/src/views/landscape/components/NewChannel.tsx +++ b/pkg/interface/src/views/landscape/components/NewChannel.tsx @@ -100,7 +100,7 @@ export function NewChannel(props: NewChannelProps & RouteComponentProps) { await waiter(p => Boolean(p?.groups?.[`/ship/~${window.ship}/${resId}`])); } actions.setStatus({ success: null }); - const resourceUrl = parentPath(location.pathname); + const resourceUrl = (location.pathname.includes("/messages")) ? "/~landscape/messages" : parentPath(location.pathname); history.push( `${resourceUrl}/resource/${moduleType}/ship/~${window.ship}/${resId}` ); diff --git a/pkg/interface/src/views/landscape/components/Participants.tsx b/pkg/interface/src/views/landscape/components/Participants.tsx index dabea1845..6ae9275fb 100644 --- a/pkg/interface/src/views/landscape/components/Participants.tsx +++ b/pkg/interface/src/views/landscape/components/Participants.tsx @@ -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 ( <> {avatar} - + {hasNickname && ( - + + {contact.nickname} + )} {cite(contact.patp)}