From e03d3c40e68f1dede03d322a56e0eaf9c5e79afd Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 2 Feb 2023 21:15:21 -0500 Subject: [PATCH] Fix live updating postres edit. Fixes #908 (#911) --- src/shared/components/post/post.tsx | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 4c44df7..8a51f1c 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -695,9 +695,9 @@ export class Post extends Component { op == UserOperation.SavePost ) { let data = wsJsonToRes(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(); } @@ -717,10 +717,10 @@ export class Post extends Component { } else if (op == UserOperation.BanFromCommunity) { let data = wsJsonToRes(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; } } @@ -730,9 +730,9 @@ export class Post extends Component { this.setState(this.state); } else if (op == UserOperation.AddModToCommunity) { let data = wsJsonToRes(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) { @@ -741,10 +741,10 @@ export class Post extends Component { .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); @@ -762,11 +762,11 @@ export class Post extends Component { this.setState({ siteRes: data }); } else if (op == UserOperation.TransferCommunity) { let data = wsJsonToRes(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) { -- 2.44.1