Merge branch 'dev' into federation
This commit is contained in:
commit
f247b28262
3 changed files with 55 additions and 48 deletions
30
ui/src/components/community.tsx
vendored
30
ui/src/components/community.tsx
vendored
|
@ -283,12 +283,12 @@ export class Community extends Component<any, State> {
|
||||||
} else if (res.op == UserOperation.EditPost) {
|
} else if (res.op == UserOperation.EditPost) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||||
|
if (found) {
|
||||||
found.url = data.post.url;
|
found.url = data.post.url;
|
||||||
found.name = data.post.name;
|
found.name = data.post.name;
|
||||||
found.nsfw = data.post.nsfw;
|
found.nsfw = data.post.nsfw;
|
||||||
|
this.setState(this.state);
|
||||||
this.setState(this.state);
|
}
|
||||||
} else if (res.op == UserOperation.CreatePost) {
|
} else if (res.op == UserOperation.CreatePost) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
this.state.posts.unshift(data.post);
|
this.state.posts.unshift(data.post);
|
||||||
|
@ -296,16 +296,16 @@ export class Community extends Component<any, State> {
|
||||||
} else if (res.op == UserOperation.CreatePostLike) {
|
} else if (res.op == UserOperation.CreatePostLike) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||||
|
if (found) {
|
||||||
found.score = data.post.score;
|
found.score = data.post.score;
|
||||||
found.upvotes = data.post.upvotes;
|
found.upvotes = data.post.upvotes;
|
||||||
found.downvotes = data.post.downvotes;
|
found.downvotes = data.post.downvotes;
|
||||||
if (data.post.my_vote !== null) {
|
if (data.post.my_vote !== null) {
|
||||||
found.my_vote = data.post.my_vote;
|
found.my_vote = data.post.my_vote;
|
||||||
found.upvoteLoading = false;
|
found.upvoteLoading = false;
|
||||||
found.downvoteLoading = false;
|
found.downvoteLoading = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (res.op == UserOperation.AddModToCommunity) {
|
} else if (res.op == UserOperation.AddModToCommunity) {
|
||||||
let data = res.data as AddModToCommunityResponse;
|
let data = res.data as AddModToCommunityResponse;
|
||||||
|
|
31
ui/src/components/main.tsx
vendored
31
ui/src/components/main.tsx
vendored
|
@ -590,26 +590,27 @@ export class Main extends Component<any, MainState> {
|
||||||
} else if (res.op == UserOperation.EditPost) {
|
} else if (res.op == UserOperation.EditPost) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
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;
|
||||||
|
|
||||||
found.url = data.post.url;
|
this.setState(this.state);
|
||||||
found.name = data.post.name;
|
}
|
||||||
found.nsfw = data.post.nsfw;
|
|
||||||
|
|
||||||
this.setState(this.state);
|
|
||||||
} else if (res.op == UserOperation.CreatePostLike) {
|
} else if (res.op == UserOperation.CreatePostLike) {
|
||||||
let data = res.data as PostResponse;
|
let data = res.data as PostResponse;
|
||||||
let found = this.state.posts.find(c => c.id == data.post.id);
|
let found = this.state.posts.find(c => c.id == data.post.id);
|
||||||
|
if (found) {
|
||||||
found.score = data.post.score;
|
found.score = data.post.score;
|
||||||
found.upvotes = data.post.upvotes;
|
found.upvotes = data.post.upvotes;
|
||||||
found.downvotes = data.post.downvotes;
|
found.downvotes = data.post.downvotes;
|
||||||
if (data.post.my_vote !== null) {
|
if (data.post.my_vote !== null) {
|
||||||
found.my_vote = data.post.my_vote;
|
found.my_vote = data.post.my_vote;
|
||||||
found.upvoteLoading = false;
|
found.upvoteLoading = false;
|
||||||
found.downvoteLoading = false;
|
found.downvoteLoading = false;
|
||||||
|
}
|
||||||
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(this.state);
|
|
||||||
} else if (res.op == UserOperation.AddAdmin) {
|
} else if (res.op == UserOperation.AddAdmin) {
|
||||||
let data = res.data as AddAdminResponse;
|
let data = res.data as AddAdminResponse;
|
||||||
this.state.siteRes.admins = data.admins;
|
this.state.siteRes.admins = data.admins;
|
||||||
|
|
42
ui/src/components/post.tsx
vendored
42
ui/src/components/post.tsx
vendored
|
@ -409,33 +409,39 @@ export class Post extends Component<any, PostState> {
|
||||||
} else if (res.op == UserOperation.EditComment) {
|
} else if (res.op == UserOperation.EditComment) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
let found = this.state.comments.find(c => c.id == data.comment.id);
|
let found = this.state.comments.find(c => c.id == data.comment.id);
|
||||||
found.content = data.comment.content;
|
if (found) {
|
||||||
found.updated = data.comment.updated;
|
found.content = data.comment.content;
|
||||||
found.removed = data.comment.removed;
|
found.updated = data.comment.updated;
|
||||||
found.deleted = data.comment.deleted;
|
found.removed = data.comment.removed;
|
||||||
found.upvotes = data.comment.upvotes;
|
found.deleted = data.comment.deleted;
|
||||||
found.downvotes = data.comment.downvotes;
|
found.upvotes = data.comment.upvotes;
|
||||||
found.score = data.comment.score;
|
found.downvotes = data.comment.downvotes;
|
||||||
found.read = data.comment.read;
|
found.score = data.comment.score;
|
||||||
|
found.read = data.comment.read;
|
||||||
|
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
}
|
||||||
} else if (res.op == UserOperation.SaveComment) {
|
} else if (res.op == UserOperation.SaveComment) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
let found = this.state.comments.find(c => c.id == data.comment.id);
|
let found = this.state.comments.find(c => c.id == data.comment.id);
|
||||||
found.saved = data.comment.saved;
|
if (found) {
|
||||||
this.setState(this.state);
|
found.saved = data.comment.saved;
|
||||||
|
this.setState(this.state);
|
||||||
|
}
|
||||||
} else if (res.op == UserOperation.CreateCommentLike) {
|
} else if (res.op == UserOperation.CreateCommentLike) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
let found: Comment = this.state.comments.find(
|
let found: Comment = this.state.comments.find(
|
||||||
c => c.id === data.comment.id
|
c => c.id === data.comment.id
|
||||||
);
|
);
|
||||||
found.score = data.comment.score;
|
if (found) {
|
||||||
found.upvotes = data.comment.upvotes;
|
found.score = data.comment.score;
|
||||||
found.downvotes = data.comment.downvotes;
|
found.upvotes = data.comment.upvotes;
|
||||||
if (data.comment.my_vote !== null) {
|
found.downvotes = data.comment.downvotes;
|
||||||
found.my_vote = data.comment.my_vote;
|
if (data.comment.my_vote !== null) {
|
||||||
found.upvoteLoading = false;
|
found.my_vote = data.comment.my_vote;
|
||||||
found.downvoteLoading = false;
|
found.upvoteLoading = false;
|
||||||
|
found.downvoteLoading = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (res.op == UserOperation.CreatePostLike) {
|
} else if (res.op == UserOperation.CreatePostLike) {
|
||||||
|
|
Loading…
Reference in a new issue