Show channels as buttons
This commit is contained in:
parent
4e9a055cd0
commit
067147c996
1 changed files with 18 additions and 8 deletions
|
@ -69,8 +69,8 @@
|
|||
(funcall secret)
|
||||
secret)))))
|
||||
|
||||
(defun mattermost-print-post (post)
|
||||
"Prints the post in the current buffer"
|
||||
(defun mattermost-insert-post (post)
|
||||
"Inserts the post in the current buffer"
|
||||
(let* ((msg (plist-get post :message))
|
||||
;; ToDo: convert to a readable date
|
||||
;; (update-at (plist-get post :update_at))
|
||||
|
@ -165,6 +165,21 @@ if the user is not present"
|
|||
map)
|
||||
"The keymap for mattermost-root-mode")
|
||||
|
||||
(defun mattermost-insert-channel (channel)
|
||||
"Inserts a channel button in the current buffer"
|
||||
(let* ((channel-display-name (plist-get channel :display_name))
|
||||
(channel-name (plist-get channel :name))
|
||||
(name (if (string-empty-p channel-display-name)
|
||||
channel-name
|
||||
channel-display-name)))
|
||||
(insert-text-button (format "> %s\n" name)
|
||||
'action #'(lambda (b)
|
||||
(let* ((channel (button-get b 'channel))
|
||||
(channel-id (plist-get channel :id)))
|
||||
|
||||
(message "button action! %s" channel-id)))
|
||||
'channel channel)))
|
||||
|
||||
(defun show-root ()
|
||||
"Populates the Mattermost Root buffer and changes to it"
|
||||
(interactive)
|
||||
|
@ -178,12 +193,7 @@ if the user is not present"
|
|||
(channels (mattermost-get-channels team-id)))
|
||||
(insert (format "%s\n" team-display-name))
|
||||
(dolist (channel channels)
|
||||
(let ((channel-id (plist-get channel :id))
|
||||
(channel-display-name (plist-get channel :display_name))
|
||||
(channel-name (plist-get channel :name)))
|
||||
(insert (format "> [%s] %s\n" channel-id (if (string= channel-display-name "")
|
||||
channel-name
|
||||
channel-display-name)))))))))
|
||||
(mattermost-insert-channel channel))))))
|
||||
(switch-to-buffer rootb)
|
||||
(mattermost-root-mode)
|
||||
(beginning-of-buffer)))
|
||||
|
|
Loading…
Reference in a new issue