Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inserting messages out-of-order by timestamp? #322

Open
alphapapa opened this issue Nov 15, 2017 · 5 comments
Open

Support inserting messages out-of-order by timestamp? #322

alphapapa opened this issue Nov 15, 2017 · 5 comments
Milestone

Comments

@alphapapa
Copy link

Hi,

We're looking into using LUI for our Matrix client: alphapapa/matrix-client.el#15 However, Matrix messages need to be deduplicated by message ID and inserted in order by timestamp, e.g. when resyncing with a room or loading earlier messages. LUI already supports timestamps and messages IDs, but the insertion function seems to just insert new messages at the end of the buffer.

Would you be open to enhancing LUI to support insertion by timestamp, and conditionally on whether a message ID already exists in the buffer? Maybe the insertion function could be set with a variable so we could just rewrite that function for our own use, binding to our function around our code that calls LUI functions.

Thanks.

@jorgenschaefer jorgenschaefer added this to the v2.7 milestone Nov 24, 2017
@jorgenschaefer
Copy link
Collaborator

Hello, and thanks for the suggestion! Support for deletion of messages is rather new, and introduced the message ID concept at all. I don't see a reason not to support updating or out of order insertion now as well. :-)

@alphapapa
Copy link
Author

Thanks, that sounds great.

About deduplication, if you are interested in that: I guess scanning a large buffer of messages for a text-property with a certain value might get slower over time, as the buffer grows, so perhaps a hash-table could optionally be used for deduplication as well.

@jorgenschaefer
Copy link
Collaborator

Hm. If you add that, make sure it's an optional feature, since many applications do not use it at all. That might even be something for the user of lui, not lui itself, to handle. I.e. lui provides lui-insert and lui-update, and the client code has to remember if it already sent the message or not.

@jorgenschaefer jorgenschaefer modified the milestones: v2.7, v2.8 Jan 28, 2018
@alphapapa
Copy link
Author

FYI we've added this feature to matrix-client-el. It's probably not implemented as cleanly as you could do it, but it seems to work so far. :)

The issue of scanning the whole buffer for message IDs is mitigated by using date headers and message timestamps, so after finding the correct place to insert a message (go to correct header, then go to correct timestamp position before the next header), only the following message ID needs to be compared.

@Thaodan
Copy link
Contributor

Thaodan commented Apr 27, 2021

Hello, and thanks for the suggestion! Support for deletion of messages is rather new, and introduced the message ID concept at all. I don't see a reason not to support updating or out of order insertion now as well. :-)

Could be useful for:
https://ircv3.net/specs/extensions/message-ids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants