From deae2b6adedc7d030a5be09ba4c1c556510e0667 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 13 Feb 2020 12:35:22 -0500 Subject: [PATCH] Fix minor loading bug. --- ui/src/utils.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/src/utils.ts b/ui/src/utils.ts index 384d5c1d5..329168d26 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -613,11 +613,13 @@ export function createPostLikeFindRes(data: PostResponse, posts: Array) { } export function createPostLikeRes(data: PostResponse, post: Post) { - post.score = data.post.score; - post.upvotes = data.post.upvotes; - post.downvotes = data.post.downvotes; - if (data.post.my_vote !== null) { - post.my_vote = data.post.my_vote; + if (post) { + post.score = data.post.score; + post.upvotes = data.post.upvotes; + post.downvotes = data.post.downvotes; + if (data.post.my_vote !== null) { + post.my_vote = data.post.my_vote; + } } } @@ -629,9 +631,11 @@ export function editPostFindRes(data: PostResponse, posts: Array) { } export function editPostRes(data: PostResponse, post: Post) { - post.url = data.post.url; - post.name = data.post.name; - post.nsfw = data.post.nsfw; + if (post) { + post.url = data.post.url; + post.name = data.post.name; + post.nsfw = data.post.nsfw; + } } export function commentsToFlatNodes(