Fix update if no lastversion and change audio pickers to default (#5010)

This commit is contained in:
Bram Kragten 2020-02-27 11:44:09 +01:00 committed by GitHub
parent 93565f0ed9
commit 6b1e5a525f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -128,22 +128,27 @@ class HassioAddonAudio extends LitElement {
private _setInputDevice(ev): void { private _setInputDevice(ev): void {
const device = ev.detail.item.getAttribute("device"); const device = ev.detail.item.getAttribute("device");
this._selectedInput = device || null; this._selectedInput = device;
} }
private _setOutputDevice(ev): void { private _setOutputDevice(ev): void {
const device = ev.detail.item.getAttribute("device"); const device = ev.detail.item.getAttribute("device");
this._selectedOutput = device || null; this._selectedOutput = device;
} }
private async _addonChanged(): Promise<void> { private async _addonChanged(): Promise<void> {
this._selectedInput = this.addon.audio_input; this._selectedInput =
this._selectedOutput = this.addon.audio_output; this.addon.audio_input === null ? "default" : this.addon.audio_input;
this._selectedOutput =
this.addon.audio_output === null ? "default" : this.addon.audio_output;
if (this._outputDevices) { if (this._outputDevices) {
return; return;
} }
const noDevice: HassioHardwareAudioDevice = { device: null, name: "-" }; const noDevice: HassioHardwareAudioDevice = {
device: "default",
name: "Default",
};
try { try {
const { audio } = await fetchHassioHardwareAudio(this.hass); const { audio } = await fetchHassioHardwareAudio(this.hass);
@ -168,8 +173,10 @@ class HassioAddonAudio extends LitElement {
private async _saveSettings(): Promise<void> { private async _saveSettings(): Promise<void> {
this._error = undefined; this._error = undefined;
const data: HassioAddonSetOptionParams = { const data: HassioAddonSetOptionParams = {
audio_input: this._selectedInput || null, audio_input:
audio_output: this._selectedOutput || null, this._selectedInput === "default" ? null : this._selectedInput,
audio_output:
this._selectedOutput === "default" ? null : this._selectedOutput,
}; };
try { try {
await setHassioAddonOption(this.hass, this.addon.slug, data); await setHassioAddonOption(this.hass, this.addon.slug, data);

View File

@ -42,7 +42,9 @@ export class HassioUpdate extends LitElement {
!!value && !!value &&
(value.last_version (value.last_version
? value.version !== value.last_version ? value.version !== value.last_version
: value.version !== value.version_latest) : value.version_latest
? value.version !== value.version_latest
: false)
); );
}).length; }).length;
@ -102,7 +104,7 @@ export class HassioUpdate extends LitElement {
releaseNotesUrl: string, releaseNotesUrl: string,
icon?: string icon?: string
): TemplateResult { ): TemplateResult {
if (lastVersion === curVersion) { if (!lastVersion || lastVersion === curVersion) {
return html``; return html``;
} }
return html` return html`