mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-10 03:19:44 +00:00
improve _supportedConversationLanguagesChanged
This commit is contained in:
@@ -43,7 +43,7 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
|
|
||||||
@state() private _supportedLanguages?: string[];
|
@state() private _supportedLanguages?: string[];
|
||||||
|
|
||||||
@state() private _supportedConversationLanguages?: string[];
|
@state() private _supportedConversationLanguages?: string[] | "*";
|
||||||
|
|
||||||
public showDialog(params: VoiceAssistantPipelineDetailsDialogParams): void {
|
public showDialog(params: VoiceAssistantPipelineDetailsDialogParams): void {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
@@ -249,6 +249,16 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
this._data = { ...this._data, ...value };
|
this._data = { ...this._data, ...value };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getDefaultConversationLanguage() {
|
||||||
|
if (
|
||||||
|
!this._supportedConversationLanguages ||
|
||||||
|
this._supportedConversationLanguages === "*"
|
||||||
|
) {
|
||||||
|
return this._supportedLanguages?.[0] ?? null;
|
||||||
|
}
|
||||||
|
return this._supportedConversationLanguages[0];
|
||||||
|
}
|
||||||
|
|
||||||
private async _updatePipeline() {
|
private async _updatePipeline() {
|
||||||
this._submitting = true;
|
this._submitting = true;
|
||||||
try {
|
try {
|
||||||
@@ -257,10 +267,7 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
name: data.name!,
|
name: data.name!,
|
||||||
language: data.language!,
|
language: data.language!,
|
||||||
conversation_engine: data.conversation_engine!,
|
conversation_engine: data.conversation_engine!,
|
||||||
conversation_language:
|
conversation_language: this._getDefaultConversationLanguage(),
|
||||||
data.conversation_language ??
|
|
||||||
this._supportedConversationLanguages?.[0] ??
|
|
||||||
null,
|
|
||||||
prefer_local_intents: data.prefer_local_intents ?? true,
|
prefer_local_intents: data.prefer_local_intents ?? true,
|
||||||
stt_engine: data.stt_engine ?? null,
|
stt_engine: data.stt_engine ?? null,
|
||||||
stt_language: data.stt_language ?? null,
|
stt_language: data.stt_language ?? null,
|
||||||
@@ -289,12 +296,8 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
private _supportedConversationLanguagesChanged(
|
private _supportedConversationLanguagesChanged(
|
||||||
ev: CustomEvent<{ value: "*" | string[] | undefined }>
|
ev: CustomEvent<{ value: "*" | string[] | undefined }>
|
||||||
) {
|
) {
|
||||||
const value = ev.detail.value;
|
this._supportedConversationLanguages = ev.detail.value;
|
||||||
if (value && value !== "*") {
|
|
||||||
this._supportedConversationLanguages = ev.detail.value as string[];
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
value &&
|
|
||||||
this._data?.conversation_language &&
|
this._data?.conversation_language &&
|
||||||
!this._supportedConversationLanguages?.includes(
|
!this._supportedConversationLanguages?.includes(
|
||||||
this._data.conversation_language!
|
this._data.conversation_language!
|
||||||
@@ -302,7 +305,7 @@ export class DialogVoiceAssistantPipelineDetail extends LitElement {
|
|||||||
) {
|
) {
|
||||||
this._data = {
|
this._data = {
|
||||||
...this._data,
|
...this._data,
|
||||||
conversation_language: this._supportedConversationLanguages?.[0],
|
conversation_language: this._getDefaultConversationLanguage(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user