Fix inserting messages into DB

This commit is contained in:
Denis Zheleztsov 2017-11-13 11:21:06 +03:00
parent af56b59f93
commit fcf28eda57
2 changed files with 6 additions and 4 deletions

View File

@ -129,8 +129,8 @@ unread by default, but you can MARK-READ it."
repto
(get-message-field msg "echo")
(get-message-field msg "subj")
(get-message-field msg "time")
(s-join "\n" (get-message-field msg "body"))
(get-message-field msg "time")
mark-read))
(message (concat "IDEC: Message " id " stored in db"))
(message (concat "IDEC: Problem to store message " id))))
@ -167,9 +167,10 @@ unread by default, but you can MARK-READ it."
(let (msgs)
(setq msgs (make-list 0 (make-hash-table :test 'equal)))
(dolist (l (emacsql (open-echo-db echo)
[:select [id tags author recipient repto echo subj body time unread]
[:select [id, tags, author, recipient, repto, echo, subj, body, time, unread]
:from messages
:order-by time]))
:order-by time
:desc]))
(if (> (length l) 0)
(setq msgs (append msgs (make-list 1 (make-hash-from-msg-list l))))))
msgs))

View File

@ -276,11 +276,12 @@ optionaly return cursor to CHECKPOINT."
(let (counter)
(setq counter 0)
(dolist (msg (get-echo-messages echo))
(insert-button (concat (gethash "subj" msg) "\n")
(insert-button (concat (gethash "subj" msg))
'action (lambda (x) (display-message-hash (button-get x 'msg)))
'subj (gethash "subj" msg)
'help-echo (concat "Read message *" (gethash "subj" msg) "*")
'msg msg)
(princ (concat "\t" (gethash "time" msg) "\n"))
))
(idec-mode)))