Change: Call ement-list-rooms after login

Users can disable this by customizing ement-after-login-hook.
This commit is contained in:
Adam Porter 2020-12-04 03:12:49 -06:00
parent 8df425710a
commit c7d19f38a5
3 changed files with 10 additions and 8 deletions

View file

@ -58,7 +58,7 @@
;;;; Commands
;;;###autoload
(defun ement-room-list ()
(defun ement-room-list (&rest _ignore)
"Show buffer listing joined rooms.
Calls `pop-to-buffer-same-window'. Interactively, with prefix,
call `pop-to-buffer'."

View file

@ -58,6 +58,7 @@
Used to avoid overlapping requests.")
(declare-function ement-view-room "ement.el")
(declare-function ement-list-rooms "ement.el")
(defvar ement-room-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "g") #'ement-room-sync)

View file

@ -73,10 +73,6 @@
(defvar ement-progress-value nil
"Used to report progress while processing sync events.")
(defvar ement-login-callback-hook '(ement--auto-sync)
"Hook run after successful login.
Run with one argument, the session logged into.")
(defvar ement-sync-callback-hook '(ement--update-room-buffers ement--auto-sync)
"Hook run after `ement--sync-callback'.
Hooks are called with one argument, the session that was
@ -111,6 +107,11 @@ synced.")
"Automatically sync again after syncing."
:type 'boolean)
(defcustom ement-after-initial-sync-hook '(ement-list-rooms)
"Hook run after initial sync.
Run with one argument, the session synced."
:type 'hook)
;;;; Commands
;;;###autoload
@ -164,12 +165,11 @@ be read, but other commands in them won't work."
(message "Disconnected %s" id)))
(defun ement--login-callback (session data)
"Finish logging in to SESSION with DATA and sync."
"Record DATA from logging in to SESSION."
(pcase-let* (((map ('access_token token) ('device_id device-id)) data))
(setf ement-sessions (list session)
(ement-session-token session) token
(ement-session-device-id session) device-id)
(run-hook-with-args 'ement-login-callback-hook session)))
(ement-session-device-id session) device-id)))
;; FIXME: Make a room-buffer-name function or something.
(defvar ement-room-buffer-name-prefix)
@ -285,6 +285,7 @@ Runs `ement-sync-callback-hook' with SESSION."
(run-hook-with-args 'ement-sync-callback-hook session)
(message (concat "Ement: Sync done."
(unless (ement-session-has-synced-p session)
(run-hook-with-args 'ement-after-initial-sync-hook session)
;; Show tip after initial sync.
(setf (ement-session-has-synced-p session) t)
" Use commands `ement-list-rooms' or `ement-view-room' to view a room.")))))