mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-16 09:24:00 +00:00
Better tippy loading. Fixes #577
This commit is contained in:
parent
d14504763a
commit
c999579c05
9 changed files with 22 additions and 45 deletions
12
ui/src/components/comment-node.tsx
vendored
12
ui/src/components/comment-node.tsx
vendored
|
@ -103,18 +103,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
this.handleCommentDownvote = this.handleCommentDownvote.bind(this);
|
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) {
|
componentWillReceiveProps(nextProps: CommentNodeProps) {
|
||||||
this.state.my_vote = nextProps.node.comment.my_vote;
|
this.state.my_vote = nextProps.node.comment.my_vote;
|
||||||
this.state.upvotes = nextProps.node.comment.upvotes;
|
this.state.upvotes = nextProps.node.comment.upvotes;
|
||||||
|
|
2
ui/src/components/community.tsx
vendored
2
ui/src/components/community.tsx
vendored
|
@ -43,6 +43,7 @@ import {
|
||||||
createPostLikeFindRes,
|
createPostLikeFindRes,
|
||||||
editPostFindRes,
|
editPostFindRes,
|
||||||
commentsToFlatNodes,
|
commentsToFlatNodes,
|
||||||
|
setupTippy,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
|
@ -341,6 +342,7 @@ export class Community extends Component<any, State> {
|
||||||
this.state.posts = data.posts;
|
this.state.posts = data.posts;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
setupTippy();
|
||||||
} else if (res.op == UserOperation.EditPost) {
|
} else if (res.op == UserOperation.EditPost) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
editPostFindRes(data, this.state.posts);
|
editPostFindRes(data, this.state.posts);
|
||||||
|
|
2
ui/src/components/main.tsx
vendored
2
ui/src/components/main.tsx
vendored
|
@ -52,6 +52,7 @@ import {
|
||||||
editPostFindRes,
|
editPostFindRes,
|
||||||
commentsToFlatNodes,
|
commentsToFlatNodes,
|
||||||
commentSortSortType,
|
commentSortSortType,
|
||||||
|
setupTippy,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
import { T } from 'inferno-i18next';
|
import { T } from 'inferno-i18next';
|
||||||
|
@ -620,6 +621,7 @@ export class Main extends Component<any, MainState> {
|
||||||
this.state.posts = data.posts;
|
this.state.posts = data.posts;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
setupTippy();
|
||||||
} else if (res.op == UserOperation.CreatePost) {
|
} else if (res.op == UserOperation.CreatePost) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
|
|
||||||
|
|
6
ui/src/components/moment-time.tsx
vendored
6
ui/src/components/moment-time.tsx
vendored
|
@ -1,6 +1,6 @@
|
||||||
import { Component } from 'inferno';
|
import { Component } from 'inferno';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { getMomentLanguage, setupTippy, capitalizeFirstLetter } from '../utils';
|
import { getMomentLanguage, capitalizeFirstLetter } from '../utils';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface MomentTimeProps {
|
interface MomentTimeProps {
|
||||||
|
@ -20,10 +20,6 @@ export class MomentTime extends Component<MomentTimeProps, any> {
|
||||||
moment.locale(lang);
|
moment.locale(lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
setupTippy();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.props.data.updated) {
|
if (this.props.data.updated) {
|
||||||
return (
|
return (
|
||||||
|
|
7
ui/src/components/navbar.tsx
vendored
7
ui/src/components/navbar.tsx
vendored
|
@ -26,7 +26,6 @@ import {
|
||||||
fetchLimit,
|
fetchLimit,
|
||||||
isCommentType,
|
isCommentType,
|
||||||
toast,
|
toast,
|
||||||
setupTippy,
|
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { version } from '../version';
|
import { version } from '../version';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
@ -85,10 +84,6 @@ export class Navbar extends Component<any, NavbarState> {
|
||||||
WebSocketService.Instance.getSite();
|
WebSocketService.Instance.getSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
setupTippy();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return this.navbar();
|
return this.navbar();
|
||||||
}
|
}
|
||||||
|
@ -283,7 +278,7 @@ export class Navbar extends Component<any, NavbarState> {
|
||||||
} else if (res.op == UserOperation.GetSite) {
|
} else if (res.op == UserOperation.GetSite) {
|
||||||
let data = res.data as GetSiteResponse;
|
let data = res.data as GetSiteResponse;
|
||||||
|
|
||||||
if (data.site) {
|
if (data.site && !this.state.siteName) {
|
||||||
this.state.siteName = data.site.name;
|
this.state.siteName = data.site.name;
|
||||||
WebSocketService.Instance.site = data.site;
|
WebSocketService.Instance.site = data.site;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
|
13
ui/src/components/post-listing.tsx
vendored
13
ui/src/components/post-listing.tsx
vendored
|
@ -102,19 +102,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
componentWillReceiveProps(nextProps: PostListingProps) {
|
||||||
this.state.my_vote = nextProps.post.my_vote;
|
this.state.my_vote = nextProps.post.my_vote;
|
||||||
this.state.upvotes = nextProps.post.upvotes;
|
this.state.upvotes = nextProps.post.upvotes;
|
||||||
|
|
5
ui/src/components/post.tsx
vendored
5
ui/src/components/post.tsx
vendored
|
@ -37,6 +37,7 @@ import {
|
||||||
createCommentLikeRes,
|
createCommentLikeRes,
|
||||||
createPostLikeRes,
|
createPostLikeRes,
|
||||||
commentsToFlatNodes,
|
commentsToFlatNodes,
|
||||||
|
setupTippy,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { PostListing } from './post-listing';
|
import { PostListing } from './post-listing';
|
||||||
import { PostListings } from './post-listings';
|
import { PostListings } from './post-listings';
|
||||||
|
@ -370,6 +371,7 @@ export class Post extends Component<any, PostState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
setupTippy();
|
||||||
} else if (res.op == UserOperation.CreateComment) {
|
} else if (res.op == UserOperation.CreateComment) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
|
|
||||||
|
@ -386,6 +388,7 @@ export class Post extends Component<any, PostState> {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
saveCommentRes(data, this.state.comments);
|
saveCommentRes(data, this.state.comments);
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
setupTippy();
|
||||||
} else if (res.op == UserOperation.CreateCommentLike) {
|
} else if (res.op == UserOperation.CreateCommentLike) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
createCommentLikeRes(data, this.state.comments);
|
createCommentLikeRes(data, this.state.comments);
|
||||||
|
@ -398,10 +401,12 @@ export class Post extends Component<any, PostState> {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
this.state.post = data.post;
|
this.state.post = data.post;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
setupTippy();
|
||||||
} else if (res.op == UserOperation.SavePost) {
|
} else if (res.op == UserOperation.SavePost) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
this.state.post = data.post;
|
this.state.post = data.post;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
setupTippy();
|
||||||
} else if (res.op == UserOperation.EditCommunity) {
|
} else if (res.op == UserOperation.EditCommunity) {
|
||||||
let data = res.data as CommunityResponse;
|
let data = res.data as CommunityResponse;
|
||||||
this.state.community = data.community;
|
this.state.community = data.community;
|
||||||
|
|
5
ui/src/components/sidebar.tsx
vendored
5
ui/src/components/sidebar.tsx
vendored
|
@ -13,7 +13,6 @@ import {
|
||||||
getUnixTime,
|
getUnixTime,
|
||||||
pictshareAvatarThumbnail,
|
pictshareAvatarThumbnail,
|
||||||
showAvatars,
|
showAvatars,
|
||||||
setupTippy,
|
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { CommunityForm } from './community-form';
|
import { CommunityForm } from './community-form';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
@ -47,10 +46,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
this.handleEditCancel = this.handleEditCancel.bind(this);
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
|
||||||
setupTippy();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
7
ui/src/services/WebSocketService.ts
vendored
7
ui/src/services/WebSocketService.ts
vendored
|
@ -61,6 +61,7 @@ export class WebSocketService {
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
this.ws = new ReconnectingWebSocket(wsUri);
|
this.ws = new ReconnectingWebSocket(wsUri);
|
||||||
|
let firstConnect = true;
|
||||||
|
|
||||||
this.subject = Observable.create((obs: any) => {
|
this.subject = Observable.create((obs: any) => {
|
||||||
this.ws.onmessage = e => {
|
this.ws.onmessage = e => {
|
||||||
|
@ -68,13 +69,19 @@ export class WebSocketService {
|
||||||
};
|
};
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
console.log(`Connected to ${wsUri}`);
|
console.log(`Connected to ${wsUri}`);
|
||||||
|
|
||||||
if (UserService.Instance.user) {
|
if (UserService.Instance.user) {
|
||||||
this.userJoin();
|
this.userJoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!firstConnect) {
|
||||||
let res: WebSocketJsonResponse = {
|
let res: WebSocketJsonResponse = {
|
||||||
reconnect: true,
|
reconnect: true,
|
||||||
};
|
};
|
||||||
obs.next(res);
|
obs.next(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
firstConnect = false;
|
||||||
};
|
};
|
||||||
}).pipe(share());
|
}).pipe(share());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue