Skip to content

Commit

Permalink
Fix live updating postres edit. Fixes #908 (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored Feb 3, 2023
1 parent 31715ca commit e03d3c4
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/shared/components/post/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,9 @@ export class Post extends Component<any, PostState> {
op == UserOperation.SavePost
) {
let data = wsJsonToRes<PostResponse>(msg);
let pv = this.state.postRes?.post_view;
if (pv) {
pv = data.post_view;
let res = this.state.postRes;
if (res) {
res.post_view = data.post_view;
this.setState(this.state);
setupTippy();
}
Expand All @@ -717,10 +717,10 @@ export class Post extends Component<any, PostState> {
} else if (op == UserOperation.BanFromCommunity) {
let data = wsJsonToRes<BanFromCommunityResponse>(msg);

let postRes = this.state.postRes;
if (postRes) {
if (postRes.post_view.creator.id == data.person_view.person.id) {
postRes.post_view.creator_banned_from_community = data.banned;
let res = this.state.postRes;
if (res) {
if (res.post_view.creator.id == data.person_view.person.id) {
res.post_view.creator_banned_from_community = data.banned;
}
}

Expand All @@ -730,9 +730,9 @@ export class Post extends Component<any, PostState> {
this.setState(this.state);
} else if (op == UserOperation.AddModToCommunity) {
let data = wsJsonToRes<AddModToCommunityResponse>(msg);
let postRes = this.state.postRes;
if (postRes) {
postRes.moderators = data.moderators;
let res = this.state.postRes;
if (res) {
res.moderators = data.moderators;
this.setState(this.state);
}
} else if (op == UserOperation.BanPerson) {
Expand All @@ -741,10 +741,10 @@ export class Post extends Component<any, PostState> {
.filter(c => c.creator.id == data.person_view.person.id)
.forEach(c => (c.creator.banned = data.banned));

let postRes = this.state.postRes;
if (postRes) {
if (postRes.post_view.creator.id == data.person_view.person.id) {
postRes.post_view.creator.banned = data.banned;
let res = this.state.postRes;
if (res) {
if (res.post_view.creator.id == data.person_view.person.id) {
res.post_view.creator.banned = data.banned;
}
}
this.setState(this.state);
Expand All @@ -762,11 +762,11 @@ export class Post extends Component<any, PostState> {
this.setState({ siteRes: data });
} else if (op == UserOperation.TransferCommunity) {
let data = wsJsonToRes<GetCommunityResponse>(msg);
let postRes = this.state.postRes;
if (postRes) {
postRes.community_view = data.community_view;
postRes.post_view.community = data.community_view.community;
postRes.moderators = data.moderators;
let res = this.state.postRes;
if (res) {
res.community_view = data.community_view;
res.post_view.community = data.community_view.community;
res.moderators = data.moderators;
this.setState(this.state);
}
} else if (op == UserOperation.BlockPerson) {
Expand Down

0 comments on commit e03d3c4

Please sign in to comment.