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

Refactor Bluetooth ViewModel and HomeScreen logic #101

Closed
1 task done
Basler182 opened this issue Sep 16, 2024 · 0 comments · Fixed by #155
Closed
1 task done

Refactor Bluetooth ViewModel and HomeScreen logic #101

Basler182 opened this issue Sep 16, 2024 · 0 comments · Fixed by #155
Labels
ENGAGE HF ENGAGE-HF-specific issues enhancement New feature or request

Comments

@Basler182
Copy link
Contributor

Problem

The BluetoothViewModel currently handles a lot more than it should and is tightly coupled with the Home Screen logic.

Solution

  • Create a new component named MessageHandler and extract the message logic currently residing in BluetoothViewModel into this component.
  • Inject the MessageHandler into MainActivityViewModel and invoke a new action that will internally call the handler.
  • Rename BluetoothViewModel to HomeScreenViewModel to better reflect its purpose.
  • Extract Bluetooth-related logic into its own service to promote separation of concerns and improve maintainability.

Additional context

This refactor will simplify the ViewModel, improve the separation of concerns, and make the application easier to test and extend in the future.

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines
@Basler182 Basler182 added enhancement New feature or request ENGAGE HF ENGAGE-HF-specific issues labels Sep 16, 2024
PSchmiedmayer added a commit that referenced this issue Dec 9, 2024
# Initial app permissions

## ♻️ Current situation & Problem
- We already have an
[issue](#101) to improve
bluetooth/home viewmodel as it is growing and we should extract some
logic into smaller components. As part of this PR I just did the
renaming from `BluetoothViewModel` to `HomeViewModel`
- We are now requesting also notification permissions in home right
after login
- Since bluetooth permissions are also needed to display the devices
header in home, those are also kept and requested right after
notification permission.
- Requested permissions are cleared after their result is received, so
that the next permission can be requested
- Introduced `BuildInfo` and `NotificationPermissions` component and
unit tested.
- Adapted `PermissionChecker` component to return also `granted` status


## ⚙️ Release Notes 
*Add a bullet point list summary of the feature and possible migration
guides if this is a breaking change so this section can be added to the
release notes.*
*Include code snippets that provide examples of the feature implemented
or links to the documentation if it appends or changes the public
interface.*


## 📚 Documentation
*Please ensure that you properly document any additions in conformance
to [Spezi Documentation
Guide](https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md).*
*You can use this section to describe your solution, but we encourage
contributors to document your reasoning and changes using in-line
documentation.*


## ✅ Testing
*Please ensure that the PR meets the testing requirements set by CodeCov
and that new functionality is appropriately tested.*
*This section describes important information about the tests and why
some elements might not be testable.*


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [ ] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Paul Schmiedmayer <[email protected]>
eldcn added a commit that referenced this issue Dec 16, 2024
…del (#155)

# *Message completion*

## ♻️ Current situation & Problem
- Fixes #101 by extracting message handling logic out of home view model
and reuse in main activity during push notifications flow
- Fixes #153 by using `dismissMessage` firebase function instead of
updating `completionDate` field. Messages are dismissed correctly now,
and we receive a new update (within a couple of seconds) upon dismissal
via the snapshot listener
- Adapt and extend unit tests

## ⚙️ Release Notes 
*Add a bullet point list summary of the feature and possible migration
guides if this is a breaking change so this section can be added to the
release notes.*
*Include code snippets that provide examples of the feature implemented
or links to the documentation if it appends or changes the public
interface.*


## 📚 Documentation
*Please ensure that you properly document any additions in conformance
to [Spezi Documentation
Guide](https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md).*
*You can use this section to describe your solution, but we encourage
contributors to document your reasoning and changes using in-line
documentation.*


## ✅ Testing
*Please ensure that the PR meets the testing requirements set by CodeCov
and that new functionality is appropriately tested.*
*This section describes important information about the tests and why
some elements might not be testable.*


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [ ] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Kilian Schneider <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENGAGE HF ENGAGE-HF-specific issues enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant