address reviews

pull/520/head
Maxim Shishmarev 6 years ago
parent 687e9db77b
commit 16692696e0

@ -326,7 +326,7 @@
window.lokiPublicChatAPI.setListOfMembers(allMembers);
};
if (this.model.id === 'publicChat:1@chat-dev.lokinet.org') {
if (this.model.isPublic()) {
updateMemberList();
setInterval(updateMemberList, 10000);
}
@ -2324,11 +2324,11 @@
? allMembers.filter(m => filterMembers(query, m))
: allMembers;
}
membersToShow = membersToShow.map(m => ({
authorPhoneNumber: m.authorPhoneNumber,
authorProfileName: m.authorProfileName,
id: m.id,
}));
membersToShow = membersToShow.map(m =>
_.pick(m, ['authorPhoneNumber', 'authorProfileName', 'id'])
);
this.memberView.updateMembers(membersToShow);
},

@ -21,6 +21,7 @@ interface MentionState {
}
class Mention extends React.Component<MentionProps, MentionState> {
private intervalHandle: any = null;
constructor(props: any) {
super(props);
@ -33,12 +34,11 @@ class Mention extends React.Component<MentionProps, MentionState> {
this.tryRenameMention();
// TODO: give up after some period of time?
const intervalHandle = setInterval(this.tryRenameMention, 30000);
this.clearOurInterval = this.clearOurInterval.bind(this, intervalHandle);
this.intervalHandle = setInterval(this.tryRenameMention, 30000);
}
public componentWillUnmount() {
this.clearOurInterval(null);
this.clearOurInterval();
}
public render() {
@ -51,9 +51,11 @@ class Mention extends React.Component<MentionProps, MentionState> {
us && 'mention-profile-name-us'
);
return (
<span className={className}>{this.state.found.authorProfileName}</span>
);
const profileName = this.state.found.authorProfileName;
const displayedName =
profileName && profileName.length > 0 ? profileName : 'Anonymous';
return <span className={className}>{displayedName}</span>;
} else {
return (
<span className="mention-profile-name">
@ -63,15 +65,15 @@ class Mention extends React.Component<MentionProps, MentionState> {
}
}
private clearOurInterval(handle: any) {
clearInterval(handle);
private clearOurInterval() {
clearInterval(this.intervalHandle);
}
private tryRenameMention() {
const found = this.findMember(this.props.text.slice(1));
if (found) {
this.setState({ found });
this.clearOurInterval(null);
this.clearOurInterval();
}
}

Loading…
Cancel
Save