Skip to content

Commit

Permalink
fixed sessions dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Andcool-Systems committed Sep 28, 2024
1 parent 11989d2 commit ba01dc2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/me/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ interface Session {
browser_version: string
}

const moveToStart = (arr: Session[]) => {
const filteredArray = arr.filter(el => !el.is_self);
const element = arr.find(el => el.is_self);
if (!element) return arr;
filteredArray.unshift(element);
return filteredArray;
}

const Safety = () => {
const [loading, setLoading] = useState<boolean>(true);
const [sessions, setSessions] = useState<Session[]>([]);
Expand All @@ -334,9 +342,8 @@ const Safety = () => {
});
}, []);

const sessions_elements = sessions
.sort((session1, session2) => new Date(session2.last_accessed).getTime() - new Date(session1.last_accessed).getTime())
.sort(session => session.is_self ? -1 : 1)
const sessions_elements = moveToStart(sessions
.sort((session1, session2) => new Date(session2.last_accessed).getTime() - new Date(session1.last_accessed).getTime()))
.map(session =>
<div key={session.id} className={Style_safety.container}>
<div className={Style_safety.session}>
Expand Down

0 comments on commit ba01dc2

Please sign in to comment.