Skip to content
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: introduce a view model in ManageNotetypes #17804

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lukstbit
Copy link
Member

Purpose / Description

A bit more info in the commit message. The line count is big but it's mostly comments, copyright etc the actual code should be easy to read. Did this in one go as changing step by step into a view model would have introduced even more useless changes to review.

How the loading indicator looks:

processing

How Has This Been Tested?

Ran the tests, manually verified the app.

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Encapsulates a loading dialog like we use in withProgress {} into a
fragment so it can be handled in transactions and react to restores.
Improves the documentation. Removes the internal keyword, only useful
if we would actually used modules/libraries.

The rename was done to better integrate with the changes for transitioning
to a view model in ManageNotetypes.
The implemented viewmodel follows the official recommendations by
implementing UDF(unidirectional data flow): user events go to the
viewmodel and the viewmodel exposes states consumed by the ui.

Not all actions in ManageNotetypes are done in the style of the
reactive ManageNotetypeViewModel(delete/rename + the actions in
AddNewNotetype).
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One apparent issue with error handling, rest of the code looks great

And a few nits

Comment on lines +36 to +37
private val _uiState = MutableStateFlow(NotetypesUiState())
val uiState: StateFlow<NotetypesUiState> = _uiState.asStateFlow()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[no action needed, comment only]

I prefer exposing the mutable Flow, instead of the additional boilerplate

)
}
}
_uiState.update { state ->
Copy link
Member

@david-allison david-allison Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ An error appears to block the UI in a processing state.

Either an error in this method, or if callers don't call this method

}

/**
* Refreshes the list of notetypes, additionally filtering the list. Also calls to emit the new
Copy link
Member

@david-allison david-allison Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'emit the new' feels like it's a truncated sentence

@lukstbit lukstbit added the Needs Author Reply Waiting for a reply from the original author label Jan 13, 2025
@david-allison
Copy link
Member

david-allison commented Jan 15, 2025

@lukstbit Is there a chance we could split out the 'loading dialog' code and get it merged? I'd like to use it in another PR

I'll use a LinearProgressDialog for this


comment: the padding on the dialog should be a little larger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Author Reply Waiting for a reply from the original author Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants