-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Wrap receiver in broadcast so that receiver can be called multiple times #2411
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2411 +/- ##
==========================================
+ Coverage 27.25% 27.71% +0.46%
==========================================
Files 645 649 +4
Lines 43480 43724 +244
==========================================
+ Hits 11849 12117 +268
+ Misses 31631 31607 -24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
native/acter/src/api/verification.rs
Outdated
#[derive(Clone, Debug)] | ||
#[derive(Clone, Debug, Default)] | ||
pub struct VerificationEvent { | ||
client: SdkClient, | ||
controller: VerificationController, | ||
event_type: String, | ||
flow_id: String, | ||
sender: OwnedUserId, | ||
sender: String, | ||
/// event content | ||
content: HashMap<String, String>, | ||
/// emoji array | ||
emojis: Vec<VerificationEmoji>, | ||
} |
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.
impl Stream<Item = VerificationEvent>
needs for VerificationEvent
to derive Default
trait.
I removed client
and controller
fields from VerificationEvent
, because they didn't derive Default
.
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.
this seems wrong. why does it need to be Default
?
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.
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.
Fixed by 2e26894
final Client client; | ||
|
||
const CrossSigning({super.key, required this.client}); |
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.
Why? this is a Consumer
, thus ref.read(alwaysClient)
should be used... Passing around complex objects to many widget is not a great pattern. Please refactor this accordingly.
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.
Fixed by 2e26894
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 think this can be simplified further.
native/acter/src/api/verification.rs
Outdated
pub fn verification_event_rx(&self) -> impl Stream<Item = OptionVerificationEvent> { | ||
BroadcastStream::new(self.verification_controller.event_rx.resubscribe()) | ||
.map(|o| OptionVerificationEvent::new(o.ok())) |
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.
Do I understand correctly that this entire new type and the wrapping and all is due to that event sometimes being None
? Wouldn't .filter_map
do enough for us here?
pub fn verification_event_rx(&self) -> impl Stream<Item = OptionVerificationEvent> { | |
BroadcastStream::new(self.verification_controller.event_rx.resubscribe()) | |
.map(|o| OptionVerificationEvent::new(o.ok())) | |
pub fn verification_event_rx(&self) -> impl Stream<Item = VerificationEvent> { | |
BroadcastStream::new(self.verification_controller.event_rx.resubscribe()) | |
.filter_map(|o| o.ok()) |
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.
Fixed by 8ff8191
Will replace
Mutext<Option<Receiver<...>>>
withBroadcastStream<Receiver<...>>
.