From 3e2df028d28765475912ba604958a18e20cb4231 Mon Sep 17 00:00:00 2001 From: TwilightLogic Date: Mon, 17 Jun 2024 15:43:41 +0800 Subject: [PATCH] chore: expired session key --- .../settings/components/manage-sessions.tsx | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/infra/rooch-portal/src/pages/settings/components/manage-sessions.tsx b/infra/rooch-portal/src/pages/settings/components/manage-sessions.tsx index 6892c02ef2..7d07b2ae76 100644 --- a/infra/rooch-portal/src/pages/settings/components/manage-sessions.tsx +++ b/infra/rooch-portal/src/pages/settings/components/manage-sessions.tsx @@ -28,9 +28,8 @@ interface ExpandableRowProps { } const isSessionExpired = (createTime: number, maxInactiveInterval: number) => { - const currentTime = Date.now() - const expirationTime = createTime + maxInactiveInterval * 1000 - return currentTime > expirationTime + const expirationTime = new Date(createTime).getTime() + maxInactiveInterval * 1000 + return Date.now() > expirationTime } export const ManageSessions: React.FC = () => { @@ -51,9 +50,7 @@ export const ManageSessions: React.FC = () => { async (authKey: string) => { setLoading(authKey) try { - await removeSession({ - authKey: authKey, - }) + await removeSession({ authKey }) await refetch() } catch (error) { console.error(error) @@ -98,8 +95,6 @@ export const ManageSessions: React.FC = () => { ) } - console.log(sessionKeys) - return (
@@ -135,11 +130,7 @@ const ExpandableRow: React.FC = ({ session, remove, loading const handleCopy = (key: string) => { copyToClipboard(key, (value) => { - if (value) { - setCopiedKeys((prev) => [...prev, key]) - } else { - setCopiedKeys((prev) => prev.filter((item) => item !== key)) - } + setCopiedKeys((prev) => (value ? [...prev, key] : prev.filter((item) => item !== key))) }) } @@ -163,11 +154,9 @@ const ExpandableRow: React.FC = ({ session, remove, loading {formatTimestamp(session.createTime)} - {/*{session.createTime}*/} {formatTimestamp(session.lastActiveTime)} - {/*{session.lastActiveTime}*/} {session.maxInactiveInterval} @@ -221,3 +210,5 @@ const ExpandableRow: React.FC = ({ session, remove, loading ) } + +export default ManageSessions