summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-02-04 11:19:05 -0500
committerDessalines <tyhou13@gmx.com>2020-02-04 11:19:05 -0500
commitb0b50098a4079daa0622a1ff9b4c52774d1d1d9f (patch)
tree527c63d46ae091558d0195915972a6b81cf7963c /ui/src/components
parente4dfa5e52f911a6dbb5df41932a70dd9af3c9753 (diff)
Websocket reconnect reload page data. Fixes #504
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/community.tsx2
-rw-r--r--ui/src/components/inbox.tsx2
-rw-r--r--ui/src/components/main.tsx2
-rw-r--r--ui/src/components/navbar.tsx2
-rw-r--r--ui/src/components/post.tsx4
-rw-r--r--ui/src/components/user.tsx2
6 files changed, 14 insertions, 0 deletions
diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx
index 7e3e2cd7..0fa8f7b5 100644
--- a/ui/src/components/community.tsx
+++ b/ui/src/components/community.tsx
@@ -254,6 +254,8 @@ export class Community extends Component<any, State> {
toast(i18n.t(msg.error), 'danger');
this.context.router.history.push('/');
return;
+ } else if (msg.reconnect) {
+ this.fetchPosts();
} else if (res.op == UserOperation.GetCommunity) {
let data = res.data as GetCommunityResponse;
this.state.community = data.community;
diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx
index 6f4d2377..6849b37d 100644
--- a/ui/src/components/inbox.tsx
+++ b/ui/src/components/inbox.tsx
@@ -313,6 +313,8 @@ export class Inbox extends Component<any, InboxState> {
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
return;
+ } else if (msg.reconnect) {
+ this.refetch();
} else if (res.op == UserOperation.GetReplies) {
let data = res.data as GetRepliesResponse;
this.state.replies = data.replies;
diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx
index 6d3e1815..0970381b 100644
--- a/ui/src/components/main.tsx
+++ b/ui/src/components/main.tsx
@@ -537,6 +537,8 @@ export class Main extends Component<any, MainState> {
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
return;
+ } else if (msg.reconnect) {
+ this.fetchPosts();
} else if (res.op == UserOperation.GetFollowedCommunities) {
let data = res.data as GetFollowedCommunitiesResponse;
this.state.subscribedCommunities = data.communities;
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx
index a916f69f..c675cfe7 100644
--- a/ui/src/components/navbar.tsx
+++ b/ui/src/components/navbar.tsx
@@ -208,6 +208,8 @@ export class Navbar extends Component<any, NavbarState> {
location.reload();
}
return;
+ } else if (msg.reconnect) {
+ this.fetchUnreads();
} else if (res.op == UserOperation.GetReplies) {
let data = res.data as GetRepliesResponse;
let unreadReplies = data.replies.filter(r => !r.read);
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index b0faf850..b399d3b2 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -370,6 +370,10 @@ export class Post extends Component<any, PostState> {
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
return;
+ } else if (msg.reconnect) {
+ WebSocketService.Instance.getPost({
+ id: Number(this.props.match.params.id),
+ });
} else if (res.op == UserOperation.GetPost) {
let data = res.data as GetPostResponse;
this.state.post = data.post;
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index ebdf6d5b..1c3c51d9 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -991,6 +991,8 @@ export class User extends Component<any, UserState> {
}
this.setState(this.state);
return;
+ } else if (msg.reconnect) {
+ this.refetch();
} else if (res.op == UserOperation.GetUserDetails) {
let data = res.data as UserDetailsResponse;
this.state.user = data.user;