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

Change GetWidgetsAsync to always return a valid list #2687

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

dkbennett
Copy link
Member

@dkbennett dkbennett commented Apr 18, 2024

Summary of the pull request

Changes GetWidgetsAsync to always return a list instead of a list or null. Returning null is what the underlying GetWidgets() returns and that seems to slip through the nullable type checking. This change ensures GetWidgetsAsync always returns a list of Widgets, or an empty list if there were errors or null was returned from GetWidgets().

This fixes the empty pin widgets dialog when there were no widgets because the list was null and not checked, causing the dialog to crash. Null check is no longer required and this method will always have a valid list.

References and relevant issues

Closes #2686

Detailed description of the pull request / Additional comments

  • Updated GetWidgetsAsync to always return an empty list if GetWidgets returns null or there was an error.
  • Updated callers of GetWidgetsAsync to no longer need to check for null where null was being checked.
  • Updated GetPreviouslyPinnedWidgets to also return empty list instead of null.
  • Updated callers of GetPreviouslyPinnedWidgets to no longer need to check for null.
  • Updated comments on GetWidgetAsync to indicate it no longer can return null.
     

Validation steps performed

  • Manually verified pinning works when there are no widgets.
  • Pinned a widget, removed it, pinned another one.
  • Verifed restarting devhome recovers the widgets as expected and they remain pinned.

PR checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated

@dkbennett dkbennett marked this pull request as ready for review April 18, 2024 18:57
@dkbennett dkbennett changed the title Change GetWidgesAsync to always return a valid list Change GetWidgetsAsync to always return a valid list Apr 18, 2024
@dkbennett dkbennett added the Needs-Second Pull request that needs another approval label Apr 18, 2024
@krschau krschau merged commit c95bba2 into main Apr 18, 2024
4 checks passed
@krschau krschau removed the Needs-Second Pull request that needs another approval label Apr 18, 2024
@krschau krschau deleted the user/dkbennett/nullwidgetlistfix branch May 16, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to pin new widgets after removing all widgets
3 participants