-
Notifications
You must be signed in to change notification settings - Fork 270
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
feat(ui): Reset Timeline
when a user is ignored/unignored
#2467
feat(ui): Reset Timeline
when a user is ignored/unignored
#2467
Conversation
This patch updates the `RoomDataProvider` trait to add a new `client` method. This is going to be useful for what's coming next.
This patch updates `TimelineInner::subscribe` as follows: * It's no longer `async`, * It returns `impl Stream` instead of `(Vector<_>, impl Stream)`, * The first item returns by the `Stream` is `VectorDiff::Reset`, which replaces the initial `Vector<_>` from the tuple, * The `Stream` is a “switched stream”, it is reset to `VectorDiff::Reset` every time `BaseClient::ignore_user_list_changes` receives a new value, i.e. every time a user is ignored or unignored, the `Timeline` stream is reset. Consequently, `TimelineInner::subscribe_batched` is no longer `async` too. This propagates to `Timeline` where `subscribe` and `subscribe_batched` are no longer `async` too.
This patch updates `TimelineInner::subscribe` to clear the entire timeline when a user is ignored/unignored.
1a9b926
to
301d8fd
Compare
d4d924c
to
95e0414
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2467 +/- ##
==========================================
+ Coverage 77.33% 77.39% +0.05%
==========================================
Files 184 184
Lines 19447 19456 +9
==========================================
+ Hits 15039 15057 +18
+ Misses 4408 4399 -9
☔ View full report in Codecov by Sentry. |
@jplatte Ready to review! |
138221c
to
2a6aae2
Compare
…rite`. This patch splits the `TimelineInnerStateLock::lock` method into `::read` and `::write`. The idea is that a read-only lock doesn't hold a clone of the lock release observer (`lock_release_ob: SharedObservable<()>`), it will not notify the observer. Then it's only the write lock that holds a clone of the lock release observer, and will notify it. This patch updates the code accordingly as best as possible.
2a6aae2
to
6278bc0
Compare
let state = self.state.clone(); | ||
let ignore_user_list_stream = self.client.subscribe_to_ignore_user_list_changes(); | ||
|
||
stream! { | ||
pin_mut!(ignore_user_list_stream); | ||
|
||
loop { | ||
let (timeline_items, timeline_stream) = { | ||
let state = state.read().await; | ||
|
||
(state.items.clone(), state.items.subscribe()) | ||
}; | ||
|
||
yield stream::once( | ||
// Reset the stream with all its items. | ||
ready(VectorDiff::Reset { values: timeline_items } ), | ||
) | ||
.chain( | ||
timeline_stream | ||
); | ||
|
||
// When this is fired, let's loop. | ||
let _ = ignore_user_list_stream.next().await; | ||
|
||
// A user has been ignored/unignored? Let's clear the timeline. | ||
state.write().await.clear(); | ||
} | ||
} | ||
.switch() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be part of the "inner" bits of the timeline. Can you revert all the changes in this file and the unit tests please, and move the listening for the ignore user list changes one level higher, into the timeline
module? Then we don't need to touch the RoomDataProvider
trait either. (also, I think the RwLock
thing should be a separate PR, if we want to do it at all – if we do the eyeball-im
changes discussed today we probably don't need it)
This has been implemented in a different way in #2504. |
This PR can be reviewed commit-by-commit for more comfort.
The global idea is that the
Timeline
is cleared when a user is ignored/unignored.This PR also splits
TimelineInnerState::lock
to::read
and::write
, and the lock release observer is notified only for the write lock.