refactor assessment updating using events
Feature Description
the app should be up 2 date. Also, we want to maintain two possible entry points to the app with different laoding paths.
-
the user goes to the dashboard, information is loaded for all assessments he is involved in. All of them are being updated too.
-
the user directly opens a link to an assessmentView -> only information relevant to that assessment is being loaded. the assessment is also being kept up2date (whenever an assessor is added/changes state, the assessment progresses, the meetingPoint is changed)
Motivation and Context
This is lazy-loading. Only load what the user actually is interested in. -> faster website
Possible Implementation
we have three different ways in which information can be loaded:
-
hoc-loading component, which calling a loading function whenever a component is mounted
-
callbacks / reactions to confirmation of transactions
-
events
I suggest the following actions/functions to be called
via the hoc-loading component:
Dashboard: fetchLatestAssessments()-> fetches all events, reduces them to a list of addresses, -> fetches basic data for them via fetchAssessment(), Also, it parses the fetched events for 'staked'-notifications and calls addAssessor(stakingAssessor) which adds the assessor to the assessment in the store. Later on, this function could load assessents from state and only fetch the latest events since then...
AssessorList(part of AssView): fetchAssessors(address) -> used to fetch all involved assessors via events when the assessmentView is mounted. Then calls updateAssessors() to get their stages & payouts. BUT: this will only happen, iff the assessment has not been previously filled via fetchLatestAssessments.
AssessmentData(part of AssView): fetchAssessmentData(address) -> fetches the static stuff (cost, assessee, size, timeLimits, assessedConcept) and calls updateAssessment() to fetch the dynamic data. Will only try to do fetch static data, if the assessment is not yet in state.
via events
These functions should be used to update the store
updateAssessment(address) -> fetches stuff that can change (stage, userStage, meeting Point) and dependent on the previous value of those also (userPayout, finalScore). Also, it uses updateAssessors(address, stage) to fetch the latest changes concerning the assessors
updateAssessors(address) -> fetches stages & (potentially payouts)
addAssessor(assessor, address) -> adds an address as an assessor to a given assessment in the store
how events are processed
*_sender will be the assessmentAddress
- 0 & 1: fetchAssessmentData(address)
- 2:
if(_user === userAddress || _assessmentAddress is in store)
-> addAssessor(_user, _assessmentAddress) - 4-7: updateAssessment(address)
via callbacks:
these are only needed if the change will not trigger an event.
user is in assessmentView and commits/reveals (while not being the last-user) -> updateAssessment() user is in assessmentView and changes the meetingPoint -> fetchStoredData()
/label ~"feature"