-
Notifications
You must be signed in to change notification settings - Fork 489
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
Fix: allow to render a TimelinePoll even if the poll is loading #7518
Conversation
27bb102
to
3fcbf0a
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #7518 +/- ##
===========================================
+ Coverage 12.21% 12.37% +0.15%
===========================================
Files 1646 1646
Lines 163315 163364 +49
Branches 67037 67078 +41
===========================================
+ Hits 19944 20209 +265
+ Misses 142729 142494 -235
- Partials 642 661 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
3fcbf0a
to
27fd56d
Compare
Great idea!
I think here the fix is passing the delegate in the
To fix this we may try to change the dependency in the init of enum TimelinePollDetailsState {
case loading
case loaded(TimelinePollDetails)
case errored
} If we do that, I think we can change the init in the viewModel = TimelinePollViewModel(timelinePollDetailsSate: .loading)
try pollAggregator = PollAggregator(session: parameters.session, room: parameters.room, pollEvent: parameters.pollEvent, delegate: self) Of course I also expect this type to be used somewhere in Finally I think the public class PollAggregator {
....
public private(set) var poll: PollProtocol? What do you think? |
RiotSwiftUI/Modules/Room/TimelinePoll/View/TimelinePollView.swift
Outdated
Show resolved
Hide resolved
@alfogrillo I've updated the PR to reflect your comments. You're right, it is cleaner this way, let me know if it works for you. (the related matrix-ios-sdk PR has also been updated to make the poll optional on |
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.
LGTM!
RiotSwiftUI/Modules/Room/PollHistory/Service/MatrixSDK/PollHistoryService.swift
Outdated
Show resolved
Hide resolved
…toryService.swift Co-authored-by: Alfonso Grillo <alfogrillo@element.io>
Kudos, SonarCloud Quality Gate passed! |
This PR fix #7497
This PR is related to this one (matrix-ios-sdk): Fix: Refreshing the poll when receiving pollEnd can break the chronological order in the store. #1776
It displays a temporary poll while fetching the
pollStartEvent
:If we failed to get the start event (or to decrypt it), we'll fallback on the normal rendering:
Also, the
PollAggregator
delegate was not defined early enough inTimelinePollCoordinator
(and so the delegate's methods were not called).I had to make public the
PollAggregator.reloadPollData()
method because:func pollAggregatorDidUpdateData(_ aggregator: PollAggregator)
needs the viewModel which is not ready at this stage because we need to instantiate it with the poll built by thePollAggregator
To make it works, the
PollAggregator
no longer loads the poll data during itsinit
function, and is only called when the viewModel is ready.In this way, if the
PollAggregator
doesn't find thepollStartEvent
in the store, it will generate a temporary poll which will be replaced by the correct one once the fetch is complete.During this loading phase, the
PollView
will be in the.loading
state. And once the data have been loaded, its state will be.loaded
(or.invalidStartEvent
)