From 87d03e1fe251af6ed2da397bbf4ff512edb8bc69 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Tue, 22 Oct 2024 13:10:10 +0300
Subject: frontend: update profile after upload run

---
 frontend/src/App.tsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'frontend/src/App.tsx')

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index bcc56fe..e39e1b6 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -45,10 +45,9 @@ const App: React.FC = () => {
     setGames(games);
   };
 
-  const _set_profile = async (user_id: string | undefined) => {
-    if (user_id) {
-      setProfile({} as UserProfile); // placeholder before we call actual user profile
-      const user = await API.get_profile(token!);
+  const _set_profile = async (user_id?: string) => {
+    if (user_id && token) {
+      const user = await API.get_profile(token);
       setProfile(user);
     }
   };
@@ -58,6 +57,7 @@ const App: React.FC = () => {
       setProfile(undefined);
       setIsModerator(false);
     } else {
+      setProfile({} as UserProfile); // placeholder before we call actual user profile
       _set_profile(get_user_id_from_token(token))
       const modStatus = get_user_mod_from_token(token)
       if (modStatus) {
@@ -83,7 +83,7 @@ const App: React.FC = () => {
     <>
       <UploadRunDialog token={token} open={uploadRunDialog} onClose={(updateProfile) => {
         setUploadRunDialog(false);
-        if (token) {
+        if (updateProfile && token) {
           _set_profile(get_user_id_from_token(token));
         }
       }} games={games} />
-- 
cgit v1.2.3

