From 79abf15fa811612b29e1a546f1b9653aec92a53e Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:06:08 -0500 Subject: [PATCH] Correctly sort messages sent in the same second --- spidercat.scm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/spidercat.scm b/spidercat.scm index df64c68..55e507b 100644 --- a/spidercat.scm +++ b/spidercat.scm @@ -70,11 +70,11 @@ "") "")] [message-time - (if last-message - (date->string (alist-ref 'user.chat.date - (cdr last-message)) - "[~H:~M:~S]") - "")]) + (if last-message + (date->string (alist-ref 'user.chat.date + (cdr last-message)) + "[~H:~M:~S]") + "")]) (html-from-template "templates/room-list-item.html" `(("ROOM_TITLE" . ,(html-encode-string room)) @@ -113,8 +113,16 @@ (sort (channel-messages irc-dir channel) (lambda (a b) - (date>? (alist-ref 'user.chat.date (cdr a)) - (alist-ref 'user.chat.date (cdr b)))))) + (let ([date-a (alist-ref 'user.chat.date (cdr a))] + [nano-a (alist-ref 'user.chat.date.nanoseconds (cdr a))] + [date-b (alist-ref 'user.chat.date (cdr b))] + [nano-b (alist-ref 'user.chat.date.nanoseconds (cdr b))]) + (cond [(and (date=? date-a date-b) + nano-a nano-b) + (> (string->number nano-b) + (string->number nano-a))] + [#t + (date