mirror of
https://github.com/vale981/ement.el
synced 2025-03-05 09:21:37 -05:00
Change/Fix: (ement--write-session) Clear unnecessary slots
I found that some ement-user structs were not being read properly (and who knows why--tracing that down may be tedious), which caused errors when rooms were displayed after loading the session, so for now we'll just clear these slots. This means that the first sync will be an initial sync, so we aren't persisting the whole session. That may not be ideal, but it's much simpler and avoids a whole lot of potential bugs, too.
This commit is contained in:
parent
ae759fb041
commit
82e0f20669
1 changed files with 13 additions and 6 deletions
19
ement.el
19
ement.el
|
@ -137,10 +137,7 @@ session and log in again."
|
|||
(if-let ((saved-session (ement--read-session)))
|
||||
(progn
|
||||
;; FIXME: Overwrites any current session.
|
||||
(setf ement-sessions (list saved-session)
|
||||
;; Unset has-synced flag so room list will be displayed.
|
||||
;; MAYBE: Make this more customizeable.
|
||||
(ement-session-has-synced-p (car ement-sessions)) nil)
|
||||
(setf ement-sessions (list saved-session))
|
||||
(ement--sync (car ement-sessions)))
|
||||
;; Unable to read session: log in again.
|
||||
(let ((ement-save-session nil))
|
||||
|
@ -501,8 +498,18 @@ Adds sender to `ement-users' when necessary."
|
|||
(with-temp-file ement-session-file
|
||||
(let* ((print-level nil)
|
||||
(print-length nil)
|
||||
(print-circle t)) ; Very important!
|
||||
(prin1 session (current-buffer))))
|
||||
;; Very important to use `print-circle', although it doesn't
|
||||
;; solve everything. Writing/reading Lisp data can be tricky...
|
||||
(print-circle t)
|
||||
;; We only want to write certain slots of the session to disk for now (because of problems
|
||||
;; reading certain data back, the solving of which will probably require descending into
|
||||
;; various rabbit holes), so we write a copy of the session with other slots cleared.
|
||||
(saved-session (copy-ement-session session)))
|
||||
;; NOTE: If slots are added to the session struct, they may need to be cleared here.
|
||||
(setf (ement-session-rooms saved-session) nil
|
||||
(ement-session-next-batch saved-session) nil
|
||||
(ement-session-has-synced-p saved-session) nil)
|
||||
(prin1 saved-session (current-buffer))))
|
||||
;; Ensure permissions are safe.
|
||||
(chmod ement-session-file #o600))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue