From fd77a4bd6b255260d0f4cad11947b38f4d30030e Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Mon, 7 Aug 2023 13:29:54 -0700
Subject: feat: :children_crossing: sort history by reverse date

---
 extension/react-app/src/pages/history.tsx | 54 ++++++++++++++++---------------
 1 file changed, 28 insertions(+), 26 deletions(-)

(limited to 'extension/react-app/src/pages/history.tsx')

diff --git a/extension/react-app/src/pages/history.tsx b/extension/react-app/src/pages/history.tsx
index c3240a66..edf4d39f 100644
--- a/extension/react-app/src/pages/history.tsx
+++ b/extension/react-app/src/pages/history.tsx
@@ -59,32 +59,34 @@ function History() {
       </div>
       <table className="w-full">
         <tbody>
-          {sessions.map((session, index) => (
-            <Tr key={index}>
-              <td>
-                <TdDiv
-                  onClick={() => {
-                    client?.loadSession(session.session_id);
-                    navigate("/");
-                  }}
-                >
-                  <div className="text-lg">{session.title}</div>
-                  <div className="text-gray-400">
-                    {new Date(
-                      parseInt(session.date_created) * 1000
-                    ).toLocaleString("en-US", {
-                      weekday: "short",
-                      year: "numeric",
-                      month: "long",
-                      day: "numeric",
-                      hour: "numeric",
-                      minute: "numeric",
-                    })}
-                  </div>
-                </TdDiv>
-              </td>
-            </Tr>
-          ))}
+          {sessions
+            .sort((a, b) => parseInt(b.date_created) - parseInt(a.date_created))
+            .map((session, index) => (
+              <Tr key={index}>
+                <td>
+                  <TdDiv
+                    onClick={() => {
+                      client?.loadSession(session.session_id);
+                      navigate("/");
+                    }}
+                  >
+                    <div className="text-lg">{session.title}</div>
+                    <div className="text-gray-400">
+                      {new Date(
+                        parseInt(session.date_created) * 1000
+                      ).toLocaleString("en-US", {
+                        weekday: "short",
+                        year: "numeric",
+                        month: "long",
+                        day: "numeric",
+                        hour: "numeric",
+                        minute: "numeric",
+                      })}
+                    </div>
+                  </TdDiv>
+                </td>
+              </Tr>
+            ))}
         </tbody>
       </table>
       <br />
-- 
cgit v1.2.3-70-g09d2

