]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/utils.ts
Reporting (#434)
[lemmy-ui.git] / src / shared / utils.ts
index ed644c6f129851e0eab1eac302110feb095bd6c7..9ea21fdd93c5f678d91454fda0490e6c395771a7 100644 (file)
@@ -2,6 +2,7 @@ import emojiShortName from "emoji-short-name";
 import {
   BlockCommunityResponse,
   BlockPersonResponse,
+  CommentReportView,
   CommentView,
   CommunityBlockView,
   CommunityView,
@@ -13,6 +14,7 @@ import {
   MyUserInfo,
   PersonBlockView,
   PersonViewSafe,
+  PostReportView,
   PostView,
   PrivateMessageView,
   Search,
@@ -1055,6 +1057,26 @@ export function editPostRes(data: PostView, post: PostView) {
   }
 }
 
+export function updatePostReportRes(
+  data: PostReportView,
+  reports: PostReportView[]
+) {
+  let found = reports.find(p => p.post.id == data.post.id);
+  if (found) {
+    found.post_report = data.post_report;
+  }
+}
+
+export function updateCommentReportRes(
+  data: CommentReportView,
+  reports: CommentReportView[]
+) {
+  let found = reports.find(c => c.comment.id == data.comment.id);
+  if (found) {
+    found.comment_report = data.comment_report;
+  }
+}
+
 export function commentsToFlatNodes(comments: CommentView[]): CommentNodeI[] {
   let nodes: CommentNodeI[] = [];
   for (let comment of comments) {