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

---
 frontend/src/App.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index d1d501d..6953de9 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -81,7 +81,6 @@ const App: React.FC = () => {
 
   return (
     <>
-      <UploadRunDialog token={token} open={uploadRunDialog} onClose={() => setUploadRunDialog(false)} games={games} />
       <Sidebar setToken={setToken} profile={profile} setProfile={setProfile} onUploadRun={() => setUploadRunDialog(true)} />
       <Routes>
         <Route path="/" element={<Homepage />} />
@@ -95,6 +94,12 @@ const App: React.FC = () => {
         <Route path='/rankings' element={<Rankings />}></Route>
         <Route path="*" element={"404"} />
       </Routes>
+      <UploadRunDialog token={token} open={uploadRunDialog} onClose={(updateProfile) => {
+        setUploadRunDialog(false);
+        if (token) {
+          _set_profile(get_user_id_from_token(token));
+        }
+      }} games={games} />
     </>
   );
 };
-- 
cgit v1.2.3


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

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

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

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 6953de9..bcc56fe 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -81,6 +81,12 @@ const App: React.FC = () => {
 
   return (
     <>
+      <UploadRunDialog token={token} open={uploadRunDialog} onClose={(updateProfile) => {
+        setUploadRunDialog(false);
+        if (token) {
+          _set_profile(get_user_id_from_token(token));
+        }
+      }} games={games} />
       <Sidebar setToken={setToken} profile={profile} setProfile={setProfile} onUploadRun={() => setUploadRunDialog(true)} />
       <Routes>
         <Route path="/" element={<Homepage />} />
@@ -94,12 +100,6 @@ const App: React.FC = () => {
         <Route path='/rankings' element={<Rankings />}></Route>
         <Route path="*" element={"404"} />
       </Routes>
-      <UploadRunDialog token={token} open={uploadRunDialog} onClose={(updateProfile) => {
-        setUploadRunDialog(false);
-        if (token) {
-          _set_profile(get_user_id_from_token(token));
-        }
-      }} games={games} />
     </>
   );
 };
-- 
cgit v1.2.3


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


From 0f81fafe764f6fc4b8f64e184520b5ea0a26a0d0 Mon Sep 17 00:00:00 2001
From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>
Date: Tue, 22 Oct 2024 13:32:47 +0300
Subject: frontend: update profile on delete run

---
 frontend/src/App.tsx           | 15 ++++-----------
 frontend/src/pages/Profile.tsx |  1 +
 2 files changed, 5 insertions(+), 11 deletions(-)

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

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index e39e1b6..c6952b1 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { Routes, Route, useLocation } from "react-router-dom";
+import { Routes, Route } from "react-router-dom";
 
 import { UserProfile } from './types/Profile';
 import Sidebar from './components/Sidebar';
@@ -18,22 +18,15 @@ import { API } from './api/Api';
 import Maplist from './pages/Maplist';
 import Rankings from './pages/Rankings';
 import { get_user_id_from_token, get_user_mod_from_token } from './utils/Jwt';
-import { MapDeleteEndpoint } from './types/Map';
 
 const App: React.FC = () => {
   const [token, setToken] = React.useState<string | undefined>(undefined);
   const [profile, setProfile] = React.useState<UserProfile | undefined>(undefined);
   const [isModerator, setIsModerator] = React.useState<boolean>(false);
 
-  const [msgIsOpen, setMsgIsOpen] = React.useState<boolean>(false);
-
   const [games, setGames] = React.useState<Game[]>([]);
 
   const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false);
-  const [uploadRunDialogMapID, setUploadRunDialogMapID] = React.useState<number | undefined>(undefined);
-
-  const [confirmDialogOpen, setConfirmDialogOpen] = React.useState<boolean>(false);
-  const [currDeleteMapInfo, setCurrDeleteMapInfo] = React.useState<MapDeleteEndpoint>();
 
   const _fetch_token = async () => {
     const token = await API.get_token();
@@ -83,18 +76,18 @@ const App: React.FC = () => {
     <>
       <UploadRunDialog token={token} open={uploadRunDialog} onClose={(updateProfile) => {
         setUploadRunDialog(false);
-        if (updateProfile && token) {
+        if (updateProfile) {
           _set_profile(get_user_id_from_token(token));
         }
       }} games={games} />
       <Sidebar setToken={setToken} profile={profile} setProfile={setProfile} onUploadRun={() => setUploadRunDialog(true)} />
       <Routes>
         <Route path="/" element={<Homepage />} />
-        <Route path="/profile" element={<Profile profile={profile} token={token} gameData={games} onDeleteRecord={() => setConfirmDialogOpen(true)} />} />
+        <Route path="/profile" element={<Profile profile={profile} token={token} gameData={games} onDeleteRecord={() => _set_profile(get_user_id_from_token(token))} />} />
         <Route path="/users/*" element={<User profile={profile} token={token} gameData={games} />} />
         <Route path="/games" element={<Games games={games} />} />
         <Route path='/games/:id' element={<Maplist />}></Route>
-        <Route path="/maps/*" element={<Maps token={token} isModerator={isModerator} />}/>
+        <Route path="/maps/*" element={<Maps token={token} isModerator={isModerator} />} />
         <Route path="/rules" element={<Rules />} />
         <Route path="/about" element={<About />} />
         <Route path='/rankings' element={<Rankings />}></Route>
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx
index 05f372e..5d1c75d 100644
--- a/frontend/src/pages/Profile.tsx
+++ b/frontend/src/pages/Profile.tsx
@@ -72,6 +72,7 @@ const Profile: React.FC<ProfileProps> = ({ profile, token, gameData, onDeleteRec
     const api_success = await API.delete_map_record(token!, map_id, record_id);
     if (api_success) {
       await message("Delete Record", "Successfully deleted record.");
+      onDeleteRecord();
     } else {
       await message("Delete Record", "Could not delete record.");
     }
-- 
cgit v1.2.3

