address reviews

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

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

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

Loading…
Cancel
Save