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

Follow an ignore/unignore user event with an initial sync #1703

Open
Velin92 opened this issue Mar 24, 2023 · 7 comments
Open

Follow an ignore/unignore user event with an initial sync #1703

Velin92 opened this issue Mar 24, 2023 · 7 comments

Comments

@Velin92
Copy link
Member

Velin92 commented Mar 24, 2023

TODO is here:

// TODO: I think I should reset all the storage and perform a new local sync

@kevinaboos
Copy link
Contributor

kevinaboos commented Jul 22, 2024

I just spent a few hours trying to figure out why ignore lists were seemingly wrong after calling ignore() or unignore() for a given user ID, even though the actual server call to ignore/unignore did properly work. Then I found this comment in the code and stumbled upon this issue.

I'm happy to work on this, but am not sure where exactly to start; would appreciate some pointers.

On a related note, I also feel that it's unfortunate and inefficient that the matrix_sdk_ui's Timeline logic causes all timelines in the entire account to be fully cleared upon a change to the ignore list. That surprised me, although I do understand why it's done.

kevinaboos added a commit to kevinaboos/robrix that referenced this issue Jul 23, 2024
…uired afterwards, but there is no way to currently do that in the Matrix SDK. So, while the logic for sending the (un)ignore request and handling the response are all correct, the timelines get completely cleared and we don't yet know how to re-establish them (perform that full sync).

There is a related GitHub issue here, but it has been stagnant for a long time: <matrix-org/matrix-rust-sdk#1703>

Relevant message from the Matrix SDK chat room: <https://matrix.to/#/!qSsPTKDfMGYqhgiLPJ:flipdot.org/$hCVXmEJh4EvbT2puuSxuv4rgnzXbQ6R07NJyT6VVwKQ?via=flipdot.org&via=matrix.org&via=element.io>
@bnjbvr
Copy link
Member

bnjbvr commented Jul 23, 2024

On a related note, I also feel that it's unfortunate and inefficient that the matrix_sdk_ui's Timeline logic causes all timelines in the entire account to be fully cleared upon a change to the ignore list. That surprised me, although I do understand why it's done.

Indeed, modulo it's happening in the event cache now.

So, when ignoring a user, we could do slightly better by removing only events from the ignored users in all the rooms we know about, and that would avoid the full flush. But when unignoring a user, we don't quite have a choice, because we don't which rooms may include events from the unignored user, only the server may tell us that.

@kevinaboos
Copy link
Contributor

But when unignoring a user, we don't quite have a choice, because we don't which rooms may include events from the unignored user, only the server may tell us that.

True, that's fair.

In general, needing to clear all the timeline caches is okay, but I need a way to actually tell the Client or SlidingSync instance to re-fetch everything. Any ideas on how to do that?

@bnjbvr
Copy link
Member

bnjbvr commented Jul 25, 2024

So there's no way to do that in the client, as far as I know (except if you restart the sync completely, after dropping all the local caches, etc.). On the other hand, you can do it a room granularity level, using back-pagination: the server will properly filter out events from ignored users, in that case.

@kevinaboos
Copy link
Contributor

using back-pagination

oh that's a clever idea! Thanks, I didn't think about using pagination; I'll give it a shot.

@kevinaboos
Copy link
Contributor

update: it works well, thanks @bnjbvr!

Note that I'd still be interested in helping to fix this issue within the SDK itself; I'm just not sure where to begin.

@bnjbvr
Copy link
Member

bnjbvr commented Oct 17, 2024

Nice! I think the way to go here would be to have the event cache automatically trigger back-pagination (as it then remembers the events that have been back-paginated, so re-opening a previously-cleared room will include the back-paginated events).

However, we cannot do this at scale: imagine a user with 4000 rooms ignoring another user; this would trigger lots and lots of back-paginations, and because of the lack of persistent storage for the event cache (#3280), all those back-pagination results would be lost after an app restart.

Nevertheless: implementing some kind of support for "automatic", background back-pagination is one step along the way. The idea is that a room event cache could decide to trigger back-pagination on its own, while right now, this requires a manual function call through an API.

This would probably require having an optional tokio task JoinHandle in a RoomEventCacheInner instance, so we know whether a back-pagination is already happening in the room or not. If that's the case and the task is not cancelled/done, then we'd have any manual back-pagination wait on that task, instead of starting a new back-pagination from start. Otherwise, we could have manual back-pagination fill in that task, and we could spawn this task from within a room event cache, based on Heuristics™ (e.g. a user has been ignored). Having the machinery without implementing any heuristics triggering automatic back-paginations would be a great first step.

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

No branches or pull requests

3 participants