this.handleCommentDownvote = this.handleCommentDownvote.bind(this);
}
- componentDidUpdate(prevProps: CommentNodeProps) {
- let prevComment = prevProps.node.comment;
- let comment = this.props.node.comment;
- if (
- prevComment.saved !== comment.saved ||
- prevComment.deleted !== comment.deleted ||
- prevComment.read !== comment.read
- ) {
- setupTippy();
- }
- }
-
componentWillReceiveProps(nextProps: CommentNodeProps) {
this.state.my_vote = nextProps.node.comment.my_vote;
this.state.upvotes = nextProps.node.comment.upvotes;
createPostLikeFindRes,
editPostFindRes,
commentsToFlatNodes,
+ setupTippy,
} from '../utils';
import { i18n } from '../i18next';
this.state.posts = data.posts;
this.state.loading = false;
this.setState(this.state);
+ setupTippy();
} else if (res.op == UserOperation.EditPost) {
let data = res.data as PostResponse;
editPostFindRes(data, this.state.posts);
editPostFindRes,
commentsToFlatNodes,
commentSortSortType,
+ setupTippy,
} from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
this.state.posts = data.posts;
this.state.loading = false;
this.setState(this.state);
+ setupTippy();
} else if (res.op == UserOperation.CreatePost) {
let data = res.data as PostResponse;
import { Component } from 'inferno';
import moment from 'moment';
-import { getMomentLanguage, setupTippy, capitalizeFirstLetter } from '../utils';
+import { getMomentLanguage, capitalizeFirstLetter } from '../utils';
import { i18n } from '../i18next';
interface MomentTimeProps {
moment.locale(lang);
}
- componentDidMount() {
- setupTippy();
- }
-
render() {
if (this.props.data.updated) {
return (
fetchLimit,
isCommentType,
toast,
- setupTippy,
} from '../utils';
import { version } from '../version';
import { i18n } from '../i18next';
WebSocketService.Instance.getSite();
}
- componentDidMount() {
- setupTippy();
- }
-
render() {
return this.navbar();
}
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
- if (data.site) {
+ if (data.site && !this.state.siteName) {
this.state.siteName = data.site.name;
WebSocketService.Instance.site = data.site;
this.setState(this.state);
}
}
- componentDidUpdate(prevProps: PostListingProps) {
- let prevPost = prevProps.post;
- let post = this.props.post;
- if (
- prevPost.saved !== post.saved ||
- prevPost.deleted !== post.deleted ||
- prevPost.locked !== post.locked ||
- prevPost.stickied !== post.stickied
- ) {
- setupTippy();
- }
- }
-
componentWillReceiveProps(nextProps: PostListingProps) {
this.state.my_vote = nextProps.post.my_vote;
this.state.upvotes = nextProps.post.upvotes;
createCommentLikeRes,
createPostLikeRes,
commentsToFlatNodes,
+ setupTippy,
} from '../utils';
import { PostListing } from './post-listing';
import { PostListings } from './post-listings';
}
this.setState(this.state);
+ setupTippy();
} else if (res.op == UserOperation.CreateComment) {
let data = res.data as CommentResponse;
let data = res.data as CommentResponse;
saveCommentRes(data, this.state.comments);
this.setState(this.state);
+ setupTippy();
} else if (res.op == UserOperation.CreateCommentLike) {
let data = res.data as CommentResponse;
createCommentLikeRes(data, this.state.comments);
let data = res.data as PostResponse;
this.state.post = data.post;
this.setState(this.state);
+ setupTippy();
} else if (res.op == UserOperation.SavePost) {
let data = res.data as PostResponse;
this.state.post = data.post;
this.setState(this.state);
+ setupTippy();
} else if (res.op == UserOperation.EditCommunity) {
let data = res.data as CommunityResponse;
this.state.community = data.community;
getUnixTime,
pictshareAvatarThumbnail,
showAvatars,
- setupTippy,
} from '../utils';
import { CommunityForm } from './community-form';
import { i18n } from '../i18next';
this.handleEditCancel = this.handleEditCancel.bind(this);
}
- componentDidUpdate() {
- setupTippy();
- }
-
render() {
return (
<div>
private constructor() {
this.ws = new ReconnectingWebSocket(wsUri);
+ let firstConnect = true;
this.subject = Observable.create((obs: any) => {
this.ws.onmessage = e => {
};
this.ws.onopen = () => {
console.log(`Connected to ${wsUri}`);
+
if (UserService.Instance.user) {
this.userJoin();
}
- let res: WebSocketJsonResponse = {
- reconnect: true,
- };
- obs.next(res);
+
+ if (!firstConnect) {
+ let res: WebSocketJsonResponse = {
+ reconnect: true,
+ };
+ obs.next(res);
+ }
+
+ firstConnect = false;
};
}).pipe(share());
}