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

Fix translations onboarding integration #17980

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/onboarding/onboarding-integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
public hassSubscribe(): Array<UnsubscribeFunc | Promise<UnsubscribeFunc>> {
return [
subscribeConfigFlowInProgress(this.hass, (flows) => {
this._discovered = flows;
this._discovered = flows.filter(
(flow) => !HIDDEN_DOMAINS.has(flow.handler)
);
const integrations: Set<string> = new Set();
for (const flow of flows) {
// To render title placeholders
if (flow.context.title_placeholders) {
integrations.add(flow.handler);
}
for (const flow of this._discovered) {
integrations.add(flow.handler);
}
this.hass.loadBackendTranslation("title", Array.from(integrations));
}),
Expand All @@ -60,12 +59,14 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
(messages) => {
let fullUpdate = false;
const newEntries: ConfigEntry[] = [];
const integrations: Set<string> = new Set();
messages.forEach((message) => {
if (message.type === null || message.type === "added") {
if (HIDDEN_DOMAINS.has(message.entry.domain)) {
return;
}
newEntries.push(message.entry);
integrations.add(message.entry.domain);
if (message.type === null) {
fullUpdate = true;
}
Expand All @@ -86,6 +87,7 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
if (!newEntries.length && !fullUpdate) {
return;
}
this.hass.loadBackendTranslation("title", Array.from(integrations));
const existingEntries = fullUpdate ? [] : this._entries;
this._entries = [...existingEntries!, ...newEntries];
},
Expand Down
Loading