UI updates

This commit is contained in:
2026-06-15 11:01:26 -04:00
parent 6a5d4b3c1d
commit 0151d4ad02
3 changed files with 32 additions and 13 deletions
+25 -10
View File
@@ -32,9 +32,13 @@
(setq buffer-read-only t)
(setq-local header-line-format
(concat " U "
(format "%-20s" "Name")
(format "%-40s" "Last message")
"When")))
(format "%-18s" "Name")
(format "%-42s" "Last message")
"When"))
(when (bound-and-true-p evil-mode)
(let ((m (make-sparse-keymap)))
(define-key m (kbd "RET") #'noise-chat-list-open)
(setq-local evil-normal-state-local-map m))))
;;;###autoload
(defun noise-chat-list ()
@@ -50,10 +54,21 @@
(let ((inhibit-read-only t)
(conversations (noise-db-get-all-conversations)))
(erase-buffer)
;; Clear old fringe overlays
(remove-overlays (point-min) (point-max) 'noise-fringe t)
(if (null conversations)
(insert "No conversations. Sync from signal-cli with `g`.\n")
(dolist (conv conversations)
(insert (noise-chat-list--format-row conv) "\n")))
(let ((unread (or (gethash "unread_count" conv) 0))
(row (noise-chat-list--format-row conv)))
(insert row "\n")
(when (> unread 0)
(let ((ov (make-overlay (line-beginning-position 0)
(line-beginning-position 0))))
(overlay-put ov 'noise-fringe t)
(overlay-put ov 'before-string
(propertize " " 'display
'(left-fringe filled-rectangle warning))))))))
(noise-chat-list--update-modeline conversations)
(goto-char (point-min))
(set-buffer-modified-p nil)))
@@ -93,13 +108,13 @@ Today: HH:MM, this week: Ddd, older: Mon DD."
(defun noise-chat-list--format-row (conv)
"Format a single conversation row for display.
CONV is a hash table with string keys from noise-db."
CONV is a hash table with string keys from noise-db.
The unread dot is rendered in the Emacs fringe, not inline."
(let* ((unread (or (gethash "unread_count" conv) 0))
(name (or (gethash "name" conv) "Unknown"))
(preview (or (gethash "last_message_preview" conv) ""))
(sender (or (gethash "last_message_sender" conv) ""))
(timestamp (or (gethash "last_message_time" conv) 0))
(fringe (if (> unread 0) "" " "))
(unread-str (if (> unread 0) (format "%3d" unread) " "))
(name-str (truncate-string-to-width name 18 nil nil ""))
(preview-prefix
@@ -107,11 +122,11 @@ CONV is a hash table with string keys from noise-db."
((string= sender "") preview)
((string= sender "me") (concat "me: " preview))
(t (concat sender ": " preview))))
(preview-str (truncate-string-to-width preview-prefix 36 nil nil ""))
(preview-str (truncate-string-to-width preview-prefix 42 nil nil ""))
(time-str (noise-chat-list--format-time timestamp)))
(concat (propertize fringe 'face 'warning) " " unread-str " "
(propertize (format "%-18s" name-str) 'face 'bold) " "
preview-str " "
(concat unread-str " "
(propertize (format "%-18s" name-str) 'face 'bold)
(propertize (format "%-42s" preview-str) 'face 'shadow)
(propertize time-str 'face 'shadow))))
(defun noise-chat-list--conversation-at-point ()
+5 -1
View File
@@ -47,7 +47,11 @@
"Major mode for a Noise Signal conversation buffer.
\\{noise-conversation-mode-map}"
:group 'noise
(setq-local header-line-format noise-conversation--mode-header))
(setq-local header-line-format noise-conversation--mode-header)
(when (bound-and-true-p evil-mode)
(let ((m (make-sparse-keymap)))
(define-key m (kbd "RET") #'noise-conversation-send)
(setq-local evil-normal-state-local-map m))))
;;;###autoload
(defun noise-conversation-open (conversation-id)
+2 -2
View File
@@ -39,7 +39,7 @@
(noise-chat-list-test--make-row "conv-1" "Sarah" 3
"are you taking the girls?"
"Sarah" (float-time)))))
(should (string-match "" row))
(should (string-match " 3" row))
(should (string-match "Sarah" row))
(should (string-match "are you taking" row))))
@@ -49,4 +49,4 @@
(noise-chat-list-test--make-row "conv-2" "Mark Okafor" 0
"merged" "me" (float-time)))))
(should (string-match "Mark Okafor" row))
(should-not (string-match "" row))))
(should (string-match "^ " row))))