Skip to content

Commit

Permalink
Fix toast in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMachowski committed Mar 30, 2023
1 parent a3e9f48 commit d652d1e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ export class XiaomiVacuumMapCardEditor extends LitElement implements Omit<Lovela
window.dispatchEvent(new Event(EVENT_SERVICE_CALL_GET));
}

private static _setStaticConfig(): void {
window.dispatchEvent(new Event(EVENT_AUTOGENERATED_CONFIG_GET));
private _setStaticConfig(): void {
if (window.confirm(this._localize("editor.alerts.set_static_config"))) {
window.dispatchEvent(new Event(EVENT_AUTOGENERATED_CONFIG_GET));
}
}

private static _generateRoomsConfig(): void {
Expand Down Expand Up @@ -209,7 +211,7 @@ export class XiaomiVacuumMapCardEditor extends LitElement implements Omit<Lovela
</mwc-button>
</div>
<div class="values config-buttons-wrapper">
<mwc-button @click="${() => XiaomiVacuumMapCardEditor._setStaticConfig()}">
<mwc-button @click="${() => this._setStaticConfig()}">
${this._localize("editor.label.set_static_config")}
</mwc-button>
<mwc-button
Expand All @@ -221,7 +223,7 @@ export class XiaomiVacuumMapCardEditor extends LitElement implements Omit<Lovela
${this._localize("editor.label.copy_service_call")}
</mwc-button>
</div>
<div class="version">${this._localize("common.version")} ${CARD_VERSION}</dib>
<div class="version">${this._localize("common.version")} ${CARD_VERSION}</div>
${ToastRenderer.render("editor")}
</div>
`;
Expand Down
3 changes: 3 additions & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@
"config_set_failed": "Failed to update config.",
"generate_rooms_config": "Generate rooms config",
"copy_service_call": "Copy service call"
},
"alerts": {
"set_static_config": "You should use this functionality only if you want to manually adjust automatically generated configuration.\nContinue?"
}
}
}
3 changes: 3 additions & 0 deletions src/localize/languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@
"config_set_failed": "Błąd aktualizacji konfiguracji.",
"generate_rooms_config": "Wygeneruj konfigurację pokoi",
"copy_service_call": "Skopiuj wywołanie usługi"
},
"alerts": {
"set_static_config": "Ten przycisk powinien zostać użyty tylko wtedy, jeśli chcesz ręcznie dostosować automatycznie wygenerowaną konfigurację.\nKontynuować?"
}
}
}
2 changes: 1 addition & 1 deletion src/xiaomi-vacuum-map-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ export class XiaomiVacuumMapCard extends LitElement {
})
: new Promise(resolve => resolve(config.tiles ?? []));
tilesGenerated
.then(t => t.sort(sortTiles))
.then(t => [...t].sort(sortTiles))
.then(tiles => this._setPreset({ ...config, tiles: tiles, icons: icons }))
.then(() => setTimeout(() => this.requestUpdate(), 100))
.then(() => this._setCurrentMode(0, false));
Expand Down

0 comments on commit d652d1e

Please sign in to comment.