Skip to content

Async process for getQuestionnairePages #2639

Open
@FikriMilano

Description

@FikriMilano

Is your feature request related to a problem? Please describe.
getQuestionnairePages delays the UI update for ~2 seconds after changing an answer, when we have a lot of skip logic (that applies to pages).

private suspend fun getQuestionnaireState(): QuestionnaireState {
val questionnaireItemList = questionnaire.item
val questionnaireResponseItemList = questionnaireResponse.item
// Only display items on the current page while editing a paginated questionnaire, otherwise,
// display all items.
val questionnaireItemViewItems =
if (!isReadOnly && !isInReviewModeFlow.value && questionnaire.isPaginated) {
pages = getQuestionnairePages()
if (currentPageIndexFlow.value == null) {
currentPageIndexFlow.value = pages!!.first { it.enabled && !it.hidden }.index
}

Describe the solution you'd like

  1. Process the getQuestionnairePages right after changing an answer
  2. Add a progress bar on the next page, to prevent user to go to the next page until getQuestionnairePages finishes. If not, user can potentially open a blank page. The progress bar shall only be shown if the item that has it's answer changed, is going to affect pages with skip logic

Describe alternatives you've considered
Open to it

Additional context
Video of the progress bar:

Screen_recording_20240807_093625.webm
Screen_recording_20240802_145126.1.webm

Would you like to work on the issue?
Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions