Closed victorgcramos closed 1 year ago
@tiagoalvesdulce Moving downloads services to core package is a good suggestion. I agree with it, but I'd like to share my thoughts with you. I don't think we should handle them as a pi service, since the pi plugin is implemented by the politeia app-shell, and we don't intend to use it elsewhere. Therefore, we would have to implement (copy/paste) the download service for each other app we create.
Initially, I thought of progress
to be just an "UI indicator", without much complexity around it, and this is why I didn't name it "download". This service is supposed to track the progress percentage of some external request, and not handle downloads itself. I couldn't think of a non-UI usage for this service...
As you said on your example, if we want to send an e-mail after some download finishes, we can create an "email service" to listen to our downloads, with an effect that sends you the downloaded payload.
Yeah, I agree it's a UI service, but I think it should be available to developers outside the common-ui if they want to use another UI framework, like angular or vue to develop since this service is vanillaJs.
This PR adds proposal votes downloads on politeia app-shell, and changes the approach used to fetch and integrate proposal downloads.
Changes were required after noticing that downloads were being canceled on routes changes, and since the ticketvote timestamps has an average 3h of download time on mainnet, users ended up having their navigation "blocked" in order to avoid download to be canceled.
This PR also adds the support for background downloads by adding global services handlers on our
appSetup
.Closes #2864
packages/comments
packages/common-ui
packages/core
matcher
support for app listener creators.global/progress/init
. Initializes progress counter for givenpayload
to be used as the amount of requests expected;global/progress/update
. Updates progress. Each update effect adds +1 to the progress counter;global/progress/end
. resets the progress counter to its initial state.global/message/set
. set message title and bodyglobal/message/clear
. clear message title and bodypackages/icketvote
apps/politeia
ProposalDownloads
componentui/progress
services to proposal downloads listenersstart
progress whenticketvoteTimestamps/fetchAll
orcommentsTimestamps/fetchAll
ispending
;update
progress for everyticketvoteTimestamps/fetch
orcommentsTimestamps/fetch
isfulfilled
;end
progress when.../fetchAll
requests are eitherfulfilled
orrejected
.Preview