Skip to content

show first visible view on default#6567

Merged
bramkragten merged 4 commits intohome-assistant:devfrom
iantrich:default-visible
Sep 11, 2020
Merged

show first visible view on default#6567
bramkragten merged 4 commits intohome-assistant:devfrom
iantrich:default-visible

Conversation

@iantrich
Copy link
Copy Markdown
Member

@iantrich iantrich commented Aug 7, 2020

Breaking change

Proposed change

Show the first view that is visible for the viewer as the default view.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

Comment thread src/panels/lovelace/hui-root.ts Outdated
Comment thread src/panels/lovelace/hui-root.ts Outdated
Comment thread src/panels/lovelace/hui-root.ts Outdated
Copy link
Copy Markdown
Member

@bramkragten bramkragten left a comment

Choose a reason for hiding this comment

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

Move the logic of what view to initial show to line 411

@iantrich iantrich requested a review from bramkragten September 5, 2020 22:19
Comment thread src/panels/lovelace/hui-root.ts Outdated
navigate(this, `${this.route!.prefix}/${views[0].path || 0}`, true);
newSelectView = 0;

if ((!viewPath && views.length) || viewPath === "default_view") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need to check for default_view?

Comment thread src/panels/lovelace/hui-root.ts Outdated

const viewPath = this.route!.path.split("/")[1];

const isVisible = (viewIndex) =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const isVisible = (viewIndex) =>
const isVisible = (view) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

After this suggested change the patch doesn't work. Without it works fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You would need to rename the var name in the function too

Comment thread src/panels/lovelace/hui-root.ts Outdated
Comment on lines +466 to +473
newSelectView = views.findIndex(isVisible);
navigate(
this,
`${this.route!.prefix}/${
views[newSelectView].path || newSelectView
}`,
true
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we extract this in a function so we don't have duplicate code?

@anyuta1166
Copy link
Copy Markdown

anyuta1166 commented Sep 9, 2020

Just tested this patch, works fine! Everything as expected. I was waiting for it so long time, because I need to show different sets of views for different users (kids, parents etc..).
Hope this will merged asap.

@bramkragten bramkragten merged commit dd1bf7b into home-assistant:dev Sep 11, 2020
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First view gets shown by default when it is not visible for user

6 participants