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)
|
(funcall secret)
|
||||||
secret)))))
|
secret)))))
|
||||||
|
|
||||||
(defun mattermost-print-post (post)
|
(defun mattermost-insert-post (post)
|
||||||
"Prints the post in the current buffer"
|
"Inserts the post in the current buffer"
|
||||||
(let* ((msg (plist-get post :message))
|
(let* ((msg (plist-get post :message))
|
||||||
;; ToDo: convert to a readable date
|
;; ToDo: convert to a readable date
|
||||||
;; (update-at (plist-get post :update_at))
|
;; (update-at (plist-get post :update_at))
|
||||||
|
@ -165,6 +165,21 @@ if the user is not present"
|
||||||
map)
|
map)
|
||||||
"The keymap for mattermost-root-mode")
|
"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 ()
|
(defun show-root ()
|
||||||
"Populates the Mattermost Root buffer and changes to it"
|
"Populates the Mattermost Root buffer and changes to it"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -178,12 +193,7 @@ if the user is not present"
|
||||||
(channels (mattermost-get-channels team-id)))
|
(channels (mattermost-get-channels team-id)))
|
||||||
(insert (format "%s\n" team-display-name))
|
(insert (format "%s\n" team-display-name))
|
||||||
(dolist (channel channels)
|
(dolist (channel channels)
|
||||||
(let ((channel-id (plist-get channel :id))
|
(mattermost-insert-channel channel))))))
|
||||||
(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)))))))))
|
|
||||||
(switch-to-buffer rootb)
|
(switch-to-buffer rootb)
|
||||||
(mattermost-root-mode)
|
(mattermost-root-mode)
|
||||||
(beginning-of-buffer)))
|
(beginning-of-buffer)))
|
||||||
|
|
Loading…
Reference in a new issue