interface: only display our contact when appropriate

This commit is contained in:
Logan Allen 2021-03-15 12:46:01 -05:00
parent 249b7555bc
commit 70866fb7c5
3 changed files with 19 additions and 15 deletions

View File

@ -139,9 +139,6 @@ export function ChatResource(props: ChatResourceProps) {
return <Loading />;
}
const modifiedContacts = { ...contacts };
delete modifiedContacts[`~${window.ship}`];
return (
<Col {...bind} height="100%" overflow="hidden" position="relative">
<ShareProfile
@ -160,10 +157,7 @@ export function ChatResource(props: ChatResourceProps) {
history={props.history}
graph={graph}
unreadCount={unreadCount}
contacts={
(!showBanner && hasLoadedAllowed) ?
contacts : modifiedContacts
}
showOurContact={ !showBanner && hasLoadedAllowed }
association={props.association}
pendingSize={Object.keys(graphTimesentMap[graphPath] || {}).length}
group={group}
@ -181,9 +175,6 @@ export function ChatResource(props: ChatResourceProps) {
(!showBanner && hasLoadedAllowed) ? ourContact : null
}
envelopes={[]}
contacts={
(!showBanner && hasLoadedAllowed) ? contacts : modifiedContacts
}
onUnmount={appendUnsent}
placeholder="Message..."
message={unsent[station] || ''}

View File

@ -263,6 +263,7 @@ class ChatMessage extends Component<ChatMessageProps> {
history,
api,
highlighted,
showOurContact,
fontSize
} = this.props;
@ -295,6 +296,7 @@ class ChatMessage extends Component<ChatMessageProps> {
style,
containerClass,
isPending,
showOurContact,
history,
api,
scrollWindow,
@ -355,6 +357,7 @@ export const MessageAuthor = ({
api,
history,
scrollWindow,
showOurContact,
...rest
}) => {
const osDark = useLocalState((state) => state.dark);
@ -367,7 +370,11 @@ export const MessageAuthor = ({
.unix(msg['time-sent'] / 1000)
.format(DATESTAMP_FORMAT);
const contact =
`~${msg.author}` in contacts ? contacts[`~${msg.author}`] : false;
( ( (msg.author === window.ship && showOurContact) ||
msg.author !== window.ship) &&
`~${msg.author}` in contacts
) ? contacts[`~${msg.author}`] : false;
const showNickname = useShowNickname(contact);
const { hideAvatars } = useSettingsState(selectCalmState);
const shipName = showNickname ? contact.nickname : cite(msg.author);

View File

@ -209,7 +209,7 @@ class ChatWindow extends Component<
api,
association,
group,
contacts,
showOurContact,
graph,
history,
groups,
@ -219,13 +219,14 @@ class ChatWindow extends Component<
const messageProps = {
association,
group,
contacts,
showOurContact,
unreadMarkerRef,
history,
api,
groups,
associations
};
const msg = graph.get(index)?.post;
if (!msg) return null;
if (!this.state.initialized) {
@ -256,6 +257,7 @@ class ChatWindow extends Component<
msg,
...messageProps
};
return (
<ChatMessage
key={index.toString()}
@ -277,6 +279,7 @@ class ChatWindow extends Component<
history,
groups,
associations,
showOurContact,
pendingSize
} = this.props;
@ -292,6 +295,9 @@ class ChatWindow extends Component<
const unreadIndex = graph.keys()[this.props.unreadCount];
const unreadMsg = unreadIndex && graph.get(unreadIndex);
const contactsModified =
showOurContact ? 0 : 100;
return (
<Col height='100%' overflow='hidden' position='relative'>
<UnreadNotice
@ -317,7 +323,7 @@ class ChatWindow extends Component<
onScroll={this.onScroll}
data={graph}
size={graph.size}
pendingSize={pendingSize}
pendingSize={pendingSize + contactsModified}
id={association.resource}
averageHeight={22}
renderer={this.renderer}
@ -332,4 +338,4 @@ export default withState(ChatWindow, [
[useGroupState, ['groups']],
[useMetadataState, ['associations']],
[useGraphState, ['pendingSize']]
]);
]);