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 ( <> - setUploadRunDialog(false)} games={games} /> setUploadRunDialog(true)} /> } /> @@ -95,6 +94,12 @@ const App: React.FC = () => { }> + { + 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 ( <> + { + setUploadRunDialog(false); + if (token) { + _set_profile(get_user_id_from_token(token)); + } + }} games={games} /> setUploadRunDialog(true)} /> } /> @@ -94,12 +100,6 @@ const App: React.FC = () => { }> - { - 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 = () => { <> { 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(undefined); const [profile, setProfile] = React.useState(undefined); const [isModerator, setIsModerator] = React.useState(false); - const [msgIsOpen, setMsgIsOpen] = React.useState(false); - const [games, setGames] = React.useState([]); const [uploadRunDialog, setUploadRunDialog] = React.useState(false); - const [uploadRunDialogMapID, setUploadRunDialogMapID] = React.useState(undefined); - - const [confirmDialogOpen, setConfirmDialogOpen] = React.useState(false); - const [currDeleteMapInfo, setCurrDeleteMapInfo] = React.useState(); const _fetch_token = async () => { const token = await API.get_token(); @@ -83,18 +76,18 @@ const App: React.FC = () => { <> { setUploadRunDialog(false); - if (updateProfile && token) { + if (updateProfile) { _set_profile(get_user_id_from_token(token)); } }} games={games} /> setUploadRunDialog(true)} /> } /> - setConfirmDialogOpen(true)} />} /> + _set_profile(get_user_id_from_token(token))} />} /> } /> } /> }> - }/> + } /> } /> } /> }> 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 = ({ 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