-
Notifications
You must be signed in to change notification settings - Fork 239
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(sdk): LocalEventTimelineItem
has a new send_state
field
#1419
feat(sdk): LocalEventTimelineItem
has a new send_state
field
#1419
Conversation
This patch is trying to resolve the following issue: When a local event is sent to the server, in case of an error, the `Timeline::send` method just returned the error but it wasn't reflected inside the `LocalEventTimelineItem` type itself. It's easy to loss this information. So now, there is a new enum: `LocalEventTimelineItemSendState` with 3 states: 1. `NotSentYet`, when the local event has not been sent yet, it's theorically the initial state, 2. `SendingFailed`, when the local event has been sent but it's failed! 3. `Sent`, when the local event has been sent successfully. Therefore, the `LocalEventTimelineItem` struct has a new field: `send_state`. The send state is managed by its `with_event_id` method which now receives an `Option<OwnedEventId>` (prev. `OwnedEventId` directly): * If it's `Some(_)`, then it means we got a successful response from the server after the sending, so the send state is set to `Sent`, * If it's `None`, then it means we got an error response from the server, so the send state is set to `SentFailed`. (A small change: The method `TimelineInner::add_event_id` has been renamed `TimelineInner::update_event_id_of_local_event`.) The `Timeline::send` still returns a `Result`, but the server's response is passed to a new method: `TimelinerInner::handle_local_event_send_response` (it's logically named after the `handle_local_event` method), which is responsible to call `TimelineInner:update_event_id_of_local_event` (which was previously called directly by `Timeline::send`). And `TimelineInner::update_event_id_of_local_event` was already calling `LocalEventTimelineItem::with_event_id`. So everything works like a charm here. The local send state is closely managed by `LocalEventTimelineItem`, I hope it will avoid state breakage as much as possible.
…::local_send_state`.
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.
Sounds sensible.
Codecov ReportBase: 72.71% // Head: 72.71% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1419 +/- ##
=======================================
Coverage 72.71% 72.71%
=======================================
Files 116 116
Lines 13124 13140 +16
=======================================
+ Hits 9543 9555 +12
- Misses 3581 3585 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Address #1103.
This patch is trying to resolve the following issue:
When a local event is sent to the server, in case of an error, the
Timeline::send
method just returned the error but it wasn't reflected inside theLocalEventTimelineItem
type itself. It's easy to loss this information.So now, there is a new enum:
LocalEventTimelineItemSendState
with 3 states:NotSentYet
, when the local event has not been sent yet, it's theorically the initial state,SendingFailed
, when the local event has been sent but it's failed!Sent
, when the local event has been sent successfully.Therefore, the
LocalEventTimelineItem
struct has a new field:send_state
. The send state is managed by itswith_event_id
method which now receives anOption<OwnedEventId>
(prev.OwnedEventId
directly):Some(_)
, then it means we got a successful response from the server after the sending, so the send state is set toSent
,None
, then it means we got an error response from the server, so the send state is set toSentFailed
.(A small change: The method
TimelineInner::add_event_id
has been renamedTimelineInner::update_event_id_of_local_event
.)The
Timeline::send
still returns aResult
, but the server's response is passed to a new method:TimelinerInner::handle_local_event_send_response
(it's logically named after thehandle_local_event
method), which is responsible to callTimelineInner:update_event_id_of_local_event
(which was previously called directly byTimeline::send
).And
TimelineInner::update_event_id_of_local_event
was already callingLocalEventTimelineItem::with_event_id
. So everything works like a charm here.The local send state is closely managed by
LocalEventTimelineItem
, I hope it will avoid state breakage as much as possible.Progression