From 6c952dfd593bc086e6fbcad49cd0926091447a55 Mon Sep 17 00:00:00 2001 From: Sendou Date: Sun, 15 Dec 2019 19:59:08 +0200 Subject: [PATCH] bug fix with top500 on users without twitter --- react-ui/src/components/user/UserPage.js | 3 ++- schemas/user.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/react-ui/src/components/user/UserPage.js b/react-ui/src/components/user/UserPage.js index ac1cf8b3e..8e51d0b89 100644 --- a/react-ui/src/components/user/UserPage.js +++ b/react-ui/src/components/user/UserPage.js @@ -73,7 +73,7 @@ const UserPage = () => { if ( userData.top500 || (userLeanQuery.data.user && userData.id === userLeanQuery.data.user.id) - ) + ) { panes.push({ menuItem: "X Rank", render: () => ( @@ -82,6 +82,7 @@ const UserPage = () => { ), }) + } const handleTabChange = (e, { activeIndex }) => { setActiveIndex(activeIndex) diff --git a/schemas/user.js b/schemas/user.js index 117fa52c6..9be19ea85 100644 --- a/schemas/user.js +++ b/schemas/user.js @@ -47,6 +47,11 @@ const resolvers = { top500: async root => { if (typeof root.top500 === "boolean") return root.top500 + if (!root.twitter_name) { + await User.findByIdAndUpdate(root._id, { top500: false }) + return false + } + const player = await Player.findOne({ twitter: root.twitter_name }).catch( e => { throw (new UserInputError(),