mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-09-20 01:56:33 +00:00
fix data issue switching btwn profiles, add (0) to empty tabs
This commit is contained in:
parent
cb2e24099f
commit
9c2b0701fd
@ -32,8 +32,7 @@ export default abstract class BaseComponent<Props = {}, State = {}> extends Pure
|
||||
}, path);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.unmounted = true;
|
||||
unsubscribe() {
|
||||
Object.keys(this.eventListeners).forEach(k => {
|
||||
const l = this.eventListeners[k];
|
||||
l && l.off();
|
||||
@ -41,6 +40,11 @@ export default abstract class BaseComponent<Props = {}, State = {}> extends Pure
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.unmounted = true;
|
||||
this.unsubscribe();
|
||||
}
|
||||
|
||||
isUserAgentCrawler() {
|
||||
// return true; // for testing
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
|
@ -171,10 +171,10 @@ class Profile extends View {
|
||||
renderTabs() {
|
||||
return html`
|
||||
<div class="tabs">
|
||||
<${Link} activeClassName="active" href="/profile/${this.props.id}">${t('posts')}<//>
|
||||
<${Link} activeClassName="active" href="/replies/${this.props.id}">${t('replies')}<//>
|
||||
<${Link} activeClassName="active" href="/likes/${this.props.id}">${t('likes')}<//>
|
||||
<${Link} activeClassName="active" href="/media/${this.props.id}">${t('media')}<//>
|
||||
<${Link} activeClassName="active" href="/profile/${this.props.id}">${t('posts')} ${this.state.noPosts ? '(0)' : ''}<//>
|
||||
<${Link} activeClassName="active" href="/replies/${this.props.id}">${t('replies')} ${this.state.noReplies ? '(0)' : ''}<//>
|
||||
<${Link} activeClassName="active" href="/likes/${this.props.id}">${t('likes')} ${this.state.noLikes ? '(0)' : ''}<//>
|
||||
<${Link} activeClassName="active" href="/media/${this.props.id}">${t('media')} ${this.state.noMedia ? '(0)' : ''}<//>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -236,6 +236,7 @@ class Profile extends View {
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.id !== this.props.id) {
|
||||
this.unsubscribe();
|
||||
this.componentDidMount();
|
||||
}
|
||||
}
|
||||
@ -281,7 +282,18 @@ class Profile extends View {
|
||||
const pub = this.props.id;
|
||||
this.followedUsers = new Set();
|
||||
this.followers = new Set();
|
||||
this.setState({followedUserCount: 0, followerCount: 0, name: '', photo: '', about: '', blocked: false});
|
||||
this.setState({
|
||||
followedUserCount: 0,
|
||||
followerCount: 0,
|
||||
noPosts: false,
|
||||
noReplies: false,
|
||||
noLikes: false,
|
||||
noMedia: false,
|
||||
name: '',
|
||||
photo: '',
|
||||
about: '',
|
||||
blocked: false,
|
||||
});
|
||||
this.isMyProfile = Session.getPubKey() === pub;
|
||||
const chat = Session.channels[pub];
|
||||
if (pub.length < 40) {
|
||||
@ -318,6 +330,17 @@ class Profile extends View {
|
||||
this.setState({blocked});
|
||||
}
|
||||
));
|
||||
State.public.user(this.props.id).on(this.sub(
|
||||
(user, id) => {
|
||||
console.log('user', id, user);
|
||||
this.setState({
|
||||
noPosts: !user.msgs,
|
||||
noMedia: !user.media,
|
||||
noLikes: !user.likes,
|
||||
noReplies: !user.replies,
|
||||
});
|
||||
}
|
||||
));
|
||||
if (this.isUserAgentCrawler() && !this.state.ogImageUrl && !this.state.photo) {
|
||||
new iris.Attribute({type: 'keyID', value: this.props.id}).identiconSrc({width: 300, showType: false}).then(src => {
|
||||
if (!this.state.ogImageUrl && !this.state.photo) {
|
||||
|
Loading…
Reference in New Issue
Block a user