-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Replace paper-listbox in cast frontend #19954
Conversation
Monthly revisit: I'm going to keep this in draft until #19955 passes through since both PR's are similar and may receive the same comments. |
Co-authored-by: Bram Kragten <[email protected]>
Co-authored-by: Bram Kragten <[email protected]>
Co-authored-by: Bram Kragten <[email protected]>
attr-for-selected="data-path" | ||
.selected=${this.castManager.status.lovelacePath || ""} | ||
> | ||
<mwc-list @action=${this._handlePickView} activatable> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt this use the selected
event?
<mwc-list @action=${this._handlePickView} activatable> | |
<mwc-list @selected=${this._handlePickView} activatable> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work until you have a selectable list (list item with checkboxes): https://www.npmjs.com/package/@material/mwc-list#mwc-list-2
WalkthroughWalkthroughThe changes primarily focus on updating plugin configurations and refactoring list item structures. In the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant HcCast
participant MWCList
participant HAListItem
User->>HcCast: Select a view
HcCast->>MWCList: Handle view selection
MWCList->>HAListItem: Update list item
HAListItem-->>HcCast: Return updated item
HcCast-->>User: Display selected view
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional Context UsedBiome (9)
Additional comments not posted (4)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range comments (1)
cast/src/launcher/layout/hc-cast.ts (1)
Line range hint
203-203
: Specify a more precise type thanany
.Using
any
can lead to maintenance issues and bugs as it bypasses TypeScript's type checking. It's recommended to specify a more precise type.
attr-for-selected="data-path" | ||
.selected=${this.castManager.status.lovelacePath || ""} | ||
> | ||
<mwc-list @action=${this._handlePickView} activatable> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure accessibility by handling keyboard navigation.
It's important to ensure that the list can be navigated using the keyboard. Consider adding keyboard event handlers or using a component that inherently supports keyboard navigation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
private async _handlePickView(ev: CustomEvent<ActionDetail>) { | ||
const path = this.lovelaceViews![ev.detail.index].path ?? ev.detail.index; | ||
await ensureConnectedCastSession(this.castManager!, this.auth!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using non-null assertions as they can lead to runtime errors.
- const path = this.lovelaceViews![ev.detail.index].path ?? ev.detail.index;
+ const path = this.lovelaceViews?.[ev.detail.index].path ?? ev.detail.index;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
private async _handlePickView(ev: CustomEvent<ActionDetail>) { | |
const path = this.lovelaceViews![ev.detail.index].path ?? ev.detail.index; | |
await ensureConnectedCastSession(this.castManager!, this.auth!); | |
private async _handlePickView(ev: CustomEvent<ActionDetail>) { | |
const path = this.lovelaceViews?.[ev.detail.index].path ?? ev.detail.index; | |
await ensureConnectedCastSession(this.castManager!, this.auth!); |
const path = this.lovelaceViews![ev.detail.index].path ?? ev.detail.index; | ||
await ensureConnectedCastSession(this.castManager!, this.auth!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that castManager
and auth
are checked for null before usage to prevent potential runtime errors.
- await ensureConnectedCastSession(this.castManager!, this.auth!);
+ if (this.castManager && this.auth) {
+ await ensureConnectedCastSession(this.castManager, this.auth);
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const path = this.lovelaceViews![ev.detail.index].path ?? ev.detail.index; | |
await ensureConnectedCastSession(this.castManager!, this.auth!); | |
const path = this.lovelaceViews![ev.detail.index].path ?? ev.detail.index; | |
if (this.castManager && this.auth) { | |
await ensureConnectedCastSession(this.castManager, this.auth); | |
} |
@@ -1,7 +1,6 @@ | |||
import "@material/mwc-button/mwc-button"; | |||
import { ActionDetail } from "@material/mwc-list/mwc-list"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using type-only imports for type-only used imports to optimize the build.
- import { ActionDetail } from "@material/mwc-list/mwc-list";
+ import type { ActionDetail } from "@material/mwc-list/mwc-list";
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
import { ActionDetail } from "@material/mwc-list/mwc-list"; | |
import type { ActionDetail } from "@material/mwc-list/mwc-list"; |
Proposed change
Replace paper-listbox in cast frontend.
Please check visually before approval since I was not able to test this fully.Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
Summary by CodeRabbit
Refactor
HcCast
class for better performance and maintainability.Style