mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-11 06:55:01 +00:00
Merge branch 'dev' into federation
This commit is contained in:
commit
4e194ea851
3 changed files with 55 additions and 48 deletions
8
ui/src/components/community.tsx
vendored
8
ui/src/components/community.tsx
vendored
|
@ -283,12 +283,12 @@ export class Community extends Component<any, State> {
|
|||
} else if (res.op == UserOperation.EditPost) {
|
||||
let data = res.data as PostResponse;
|
||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||
|
||||
if (found) {
|
||||
found.url = data.post.url;
|
||||
found.name = data.post.name;
|
||||
found.nsfw = data.post.nsfw;
|
||||
|
||||
this.setState(this.state);
|
||||
}
|
||||
} else if (res.op == UserOperation.CreatePost) {
|
||||
let data = res.data as PostResponse;
|
||||
this.state.posts.unshift(data.post);
|
||||
|
@ -296,7 +296,7 @@ export class Community extends Component<any, State> {
|
|||
} else if (res.op == UserOperation.CreatePostLike) {
|
||||
let data = res.data as PostResponse;
|
||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||
|
||||
if (found) {
|
||||
found.score = data.post.score;
|
||||
found.upvotes = data.post.upvotes;
|
||||
found.downvotes = data.post.downvotes;
|
||||
|
@ -305,7 +305,7 @@ export class Community extends Component<any, State> {
|
|||
found.upvoteLoading = false;
|
||||
found.downvoteLoading = false;
|
||||
}
|
||||
|
||||
}
|
||||
this.setState(this.state);
|
||||
} else if (res.op == UserOperation.AddModToCommunity) {
|
||||
let data = res.data as AddModToCommunityResponse;
|
||||
|
|
7
ui/src/components/main.tsx
vendored
7
ui/src/components/main.tsx
vendored
|
@ -590,16 +590,17 @@ export class Main extends Component<any, MainState> {
|
|||
} else if (res.op == UserOperation.EditPost) {
|
||||
let data = res.data as PostResponse;
|
||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||
|
||||
if (found) {
|
||||
found.url = data.post.url;
|
||||
found.name = data.post.name;
|
||||
found.nsfw = data.post.nsfw;
|
||||
|
||||
this.setState(this.state);
|
||||
}
|
||||
} else if (res.op == UserOperation.CreatePostLike) {
|
||||
let data = res.data as PostResponse;
|
||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||
|
||||
if (found) {
|
||||
found.score = data.post.score;
|
||||
found.upvotes = data.post.upvotes;
|
||||
found.downvotes = data.post.downvotes;
|
||||
|
@ -608,8 +609,8 @@ export class Main extends Component<any, MainState> {
|
|||
found.upvoteLoading = false;
|
||||
found.downvoteLoading = false;
|
||||
}
|
||||
|
||||
this.setState(this.state);
|
||||
}
|
||||
} else if (res.op == UserOperation.AddAdmin) {
|
||||
let data = res.data as AddAdminResponse;
|
||||
this.state.siteRes.admins = data.admins;
|
||||
|
|
6
ui/src/components/post.tsx
vendored
6
ui/src/components/post.tsx
vendored
|
@ -409,6 +409,7 @@ export class Post extends Component<any, PostState> {
|
|||
} else if (res.op == UserOperation.EditComment) {
|
||||
let data = res.data as CommentResponse;
|
||||
let found = this.state.comments.find(c => c.id == data.comment.id);
|
||||
if (found) {
|
||||
found.content = data.comment.content;
|
||||
found.updated = data.comment.updated;
|
||||
found.removed = data.comment.removed;
|
||||
|
@ -419,16 +420,20 @@ export class Post extends Component<any, PostState> {
|
|||
found.read = data.comment.read;
|
||||
|
||||
this.setState(this.state);
|
||||
}
|
||||
} else if (res.op == UserOperation.SaveComment) {
|
||||
let data = res.data as CommentResponse;
|
||||
let found = this.state.comments.find(c => c.id == data.comment.id);
|
||||
if (found) {
|
||||
found.saved = data.comment.saved;
|
||||
this.setState(this.state);
|
||||
}
|
||||
} else if (res.op == UserOperation.CreateCommentLike) {
|
||||
let data = res.data as CommentResponse;
|
||||
let found: Comment = this.state.comments.find(
|
||||
c => c.id === data.comment.id
|
||||
);
|
||||
if (found) {
|
||||
found.score = data.comment.score;
|
||||
found.upvotes = data.comment.upvotes;
|
||||
found.downvotes = data.comment.downvotes;
|
||||
|
@ -437,6 +442,7 @@ export class Post extends Component<any, PostState> {
|
|||
found.upvoteLoading = false;
|
||||
found.downvoteLoading = false;
|
||||
}
|
||||
}
|
||||
this.setState(this.state);
|
||||
} else if (res.op == UserOperation.CreatePostLike) {
|
||||
let data = res.data as PostResponse;
|
||||
|
|
Loading…
Reference in a new issue