From af161537d7c5fe31c29ae25068e1d4902de82617 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 May 2025 22:07:58 +0200 Subject: [PATCH] fix shadows + lp diff accounts --- src/app/components/Lobby.tsx | 4 ++-- src/app/components/Ranked.tsx | 10 +++++----- src/app/components/Session.tsx | 16 ++++++++-------- src/app/globals.css | 1 - src/app/lib/utils.ts | 23 ++++++++++++++++++++--- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/app/components/Lobby.tsx b/src/app/components/Lobby.tsx index 5b658ee..d6d9e84 100644 --- a/src/app/components/Lobby.tsx +++ b/src/app/components/Lobby.tsx @@ -79,7 +79,7 @@ export default function Lobby ( { player }: { player: string } ) >
-
+
{ player.tag ? `${ player.tag } ${ player.name }` : player.name }
@@ -96,7 +96,7 @@ export default function Lobby ( { player }: { player: string } ) backgroundImage: `url(${ player.positionIcon })`, } } >
-
+
{ player.wr }%
diff --git a/src/app/components/Ranked.tsx b/src/app/components/Ranked.tsx index 823b341..1714702 100644 --- a/src/app/components/Ranked.tsx +++ b/src/app/components/Ranked.tsx @@ -55,7 +55,7 @@ export default function Ranked ( { name, tag }: { name: string; tag: string } ) return (
-
+
{ [ "MASTER", "GRANDMASTER", "CHALLENGER" ].includes( data.tier ) ? (
{ data.tier } { data.lp } LP @@ -68,9 +68,9 @@ export default function Ranked ( { name, tag }: { name: string; tag: string } )
-
{ data.wins }W
-
{ data.losses }L
-
+
{ data.wins }W
+
{ data.losses }L
+
{ data.winrate }%
@@ -92,7 +92,7 @@ export default function Ranked ( { name, tag }: { name: string; tag: string } ) style={ { backgroundImage: `url('${ match.championImg }')` } } />
-
+
{ match.kills }/{ match.deaths }/{ match.assists }
diff --git a/src/app/components/Session.tsx b/src/app/components/Session.tsx index 69ed457..3733ca6 100644 --- a/src/app/components/Session.tsx +++ b/src/app/components/Session.tsx @@ -69,15 +69,15 @@ export default function Session ( { name, tag }: { name: string; tag: string } )
- + { data.kills } - / - + / + { data.deaths } - / - + / + { data.assists }
@@ -86,17 +86,17 @@ export default function Session ( { name, tag }: { name: string; tag: string } )
-
+
{ data.wins }W
-
+
{ data.losses }L
{ typeof data.lpGain === "number" && data.lpGain !== 0 && (
0 + className={ `lp text-3xl text-center px-1 text-shadow-sm text-shadow-black ${ data.lpGain > 0 ? "text-sky-600" : data.lpGain < 0 ? "text-red-600" diff --git a/src/app/globals.css b/src/app/globals.css index 3ef8188..c5b0362 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -83,7 +83,6 @@ body { transform: scale(0.5); } - .slide-animation { animation: slideInOut 30s ease-in-out forwards; } diff --git a/src/app/lib/utils.ts b/src/app/lib/utils.ts index 2c911b8..84e87d8 100644 --- a/src/app/lib/utils.ts +++ b/src/app/lib/utils.ts @@ -224,27 +224,44 @@ export async function getSessionData ( name: string, tag: string ) let initialLP = currentLP; const now = Date.now(); + let shouldResetSession = false; + if ( sessionCookie ) { try { const sessionData = JSON.parse( sessionCookie.value ); const sessionTime = sessionData.timestamp; + const sessionPuuid = sessionData.puuid; - if ( now - sessionTime < TWELVE_HOURS_IN_MS ) + if ( sessionPuuid !== account.puuid ) + { + shouldResetSession = true; + } else if ( now - sessionTime < TWELVE_HOURS_IN_MS ) { initialLP = sessionData.initialLP; lpGain = currentLP - initialLP; + } else + { + shouldResetSession = true; } } catch { + shouldResetSession = true; } + } else + { + shouldResetSession = true; } - if ( !sessionCookie || lpGain === 0 ) + if ( shouldResetSession ) { ( await cookieStore ).set( "lpSession", - JSON.stringify( { initialLP: currentLP, timestamp: now } ), + JSON.stringify( { + initialLP: currentLP, + timestamp: now, + puuid: account.puuid, + } ), { path: "/", maxAge: TWELVE_HOURS_IN_MS / 1000,