2020-11-30 10:56:54 -06:00
|
|
|
;;; ement-structs.el --- Ement structs -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;; Copyright (C) 2020 Adam Porter
|
|
|
|
|
|
|
|
;; Author: Adam Porter <adam@alphapapa.net>
|
2021-07-27 21:50:05 -05:00
|
|
|
;; Keywords: comm
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-12-01 03:57:44 -06:00
|
|
|
;;;; Debugging
|
|
|
|
|
2022-05-05 13:55:26 -05:00
|
|
|
;; NOTE: Uncomment this form and `emacs-lisp-byte-compile-and-load' the file to enable
|
|
|
|
;; `ement-debug' messages. This is commented out by default because, even though the
|
|
|
|
;; messages are only displayed when `warning-minimum-log-level' is `:debug' at runtime, if
|
|
|
|
;; that is so at expansion time, the expanded macro calls format the message and check the
|
|
|
|
;; log level at runtime, which is not zero-cost.
|
|
|
|
|
|
|
|
;; (eval-and-compile
|
|
|
|
;; (setq-local warning-minimum-log-level nil)
|
|
|
|
;; (setq-local warning-minimum-log-level :debug))
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
;;;; Requirements
|
|
|
|
|
|
|
|
(require 'cl-lib)
|
|
|
|
|
|
|
|
;;;; Structs
|
|
|
|
|
|
|
|
(cl-defstruct ement-user
|
2022-05-12 17:45:40 -05:00
|
|
|
id displayname account-data
|
|
|
|
(color nil :documentation "Color in which to display user's name.")
|
|
|
|
(message-color nil :documentation "Color in which to display user's messages.")
|
|
|
|
(username nil
|
|
|
|
;; NOTE: Not exactly according to spec, I guess, but useful for now.
|
|
|
|
:documentation "Username part of user's Matrix ID.")
|
|
|
|
(avatar-url nil :documentation "MXC URL to user's avatar.")
|
|
|
|
(avatar nil :documentation "One-space string with avatar image in display property.")
|
|
|
|
(room-display-names (make-hash-table) :documentation "Hash table mapping rooms to the user's per-room display name."))
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
(cl-defstruct ement-event
|
2021-08-23 20:37:52 -05:00
|
|
|
id sender content origin-server-ts type unsigned state-key
|
2022-03-29 07:34:51 -05:00
|
|
|
receipts
|
Merge: Add: Show reactions
Squashed commit of the following:
commit 1f393d7dde91acf315d5e218e9d52e69b1a5aa28
Author: Adam Porter <adam@alphapapa.net>
Date: Thu Jul 22 10:48:19 2021 -0500
Comment: TODOs
commit 7e039a7b4f2b8c05d1a3a8e5e763344f783dfdbe
Author: Adam Porter <adam@alphapapa.net>
Date: Thu Jul 22 10:48:08 2021 -0500
WIP: Docstring for handler lambdas
commit 441c23113cf52b53773e6a9cb3cb66870da87c24
Author: Adam Porter <adam@alphapapa.net>
Date: Thu Jul 22 10:40:58 2021 -0500
WIP: Don't insert reaction events as nodes
This seems to work well. However, the event-processing needs some
refactoring, because the logic is now spread across a few places.
commit 4fdf0ddf37399eb2b8c75639c7f8ff40897e45b6
Author: Adam Porter <adam@alphapapa.net>
Date: Thu Jul 22 10:30:28 2021 -0500
WIP: Key face, and fix help-echo
Remaining issue is that reactions still insert empty events in the
buffer.
commit 5f700ccc16276b9ce8bb1682e2446e14b6c6873a
Author: Adam Porter <adam@alphapapa.net>
Date: Thu Jul 22 09:30:18 2021 -0500
WIP: Fix: Use pushnew to avoid duplicating reactions
commit a40a6e6bc1f97d6ada7291d0b216cff0d9ab8074
Author: Adam Porter <adam@alphapapa.net>
Date: Wed Jul 21 20:17:32 2021 -0500
WIP: And in -retro-callback
A bug now is that, every time a room's buffer is created anew, the
reactions are duplicated.
commit dbfec18e45f1371cf1f45ae301445055ce670960
Author: Adam Porter <adam@alphapapa.net>
Date: Wed Jul 21 19:49:47 2021 -0500
WIP: Call -room---process-events in -room--buffer
This almost seems to work, in that reactions from old timeline
events are displayed when the buffer is made...or not? It seems to
work in some cases, but not in others, like when retro-loading...
The big issue now is that the reaction events cause blank events to be
inserted into the buffer. Fixing that will require conditionally
inserting events, which probably means moving message event handling
into the defevent macro, which will require some more refactoring...
commit 81757536f27d14c868cee42b70a6cd806020d148
Author: Adam Porter <adam@alphapapa.net>
Date: Wed Jul 21 17:02:29 2021 -0500
WIP: Add: Reactions
It works for newly received reactions, but after initial sync,
reactions that happened in the past are not displayed. I think it's
because the related events aren't found in the room's timeline, but I
tried to fix that, and it still doesn't work.
I'm guessing there are some assumptions that I'm making wrongly, or
something that I don't understand about how the server sends events.
We may have to save a list of certain types of events and process them
after all other events have been processed. Ugh.
The good news is that EWOC makes it pretty easy and reliable to update
messages in the buffer.
2021-07-22 10:48:41 -05:00
|
|
|
;; The local slot is an alist used by the local client only.
|
|
|
|
local)
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
(cl-defstruct ement-server
|
2021-08-03 02:25:52 -05:00
|
|
|
name uri-prefix)
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
(cl-defstruct ement-session
|
2020-12-02 14:28:00 -06:00
|
|
|
user server token transaction-id rooms next-batch
|
2021-07-28 23:21:12 -05:00
|
|
|
device-id initial-device-display-name has-synced-p
|
2021-08-01 05:09:07 -05:00
|
|
|
account-data
|
|
|
|
;; Hash table of all seen events, keyed on event ID.
|
|
|
|
events)
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
(cl-defstruct ement-room
|
2020-12-01 00:28:13 -06:00
|
|
|
id display-name prev-batch
|
2021-07-29 02:05:22 -05:00
|
|
|
summary state timeline ephemeral account-data unread-notifications
|
2022-03-29 10:47:46 -05:00
|
|
|
latest-ts topic canonical-alias avatar status type invite-state
|
2022-05-12 17:45:40 -05:00
|
|
|
(members (make-hash-table :test #'equal) :documentation "Hash table mapping joined user IDs to user structs.")
|
2021-07-21 14:08:58 -05:00
|
|
|
;; The local slot is an alist used by the local client only.
|
2022-03-29 06:44:17 -05:00
|
|
|
local
|
2022-03-29 23:16:26 -05:00
|
|
|
(receipts (make-hash-table :test #'equal)))
|
2020-11-30 10:56:54 -06:00
|
|
|
|
|
|
|
;;;; Variables
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Customization
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Commands
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Functions
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Footer
|
|
|
|
|
|
|
|
(provide 'ement-structs)
|
|
|
|
|
|
|
|
;;; ement-structs.el ends here
|