mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix promise constructors with returns (#15486)
This commit is contained in:
parent
05f2fb896c
commit
7adb49c772
@ -59,7 +59,6 @@
|
|||||||
"prefer-destructuring": "off",
|
"prefer-destructuring": "off",
|
||||||
"no-restricted-globals": [2, "event"],
|
"no-restricted-globals": [2, "event"],
|
||||||
"prefer-promise-reject-errors": "off",
|
"prefer-promise-reject-errors": "off",
|
||||||
"no-promise-executor-return": "warn",
|
|
||||||
"no-unsafe-optional-chaining": "warn",
|
"no-unsafe-optional-chaining": "warn",
|
||||||
"prefer-regex-literals": ["warn"],
|
"prefer-regex-literals": ["warn"],
|
||||||
"import/prefer-default-export": "off",
|
"import/prefer-default-export": "off",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import "@lit-labs/virtualizer";
|
||||||
import { mdiArrowDown, mdiArrowUp } from "@mdi/js";
|
import { mdiArrowDown, mdiArrowUp } from "@mdi/js";
|
||||||
import deepClone from "deep-clone-simple";
|
import deepClone from "deep-clone-simple";
|
||||||
import {
|
import {
|
||||||
@ -21,16 +22,15 @@ import { styleMap } from "lit/directives/style-map";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import "../search-input";
|
|
||||||
import { debounce } from "../../common/util/debounce";
|
import { debounce } from "../../common/util/debounce";
|
||||||
import { nextRender } from "../../common/util/render-status";
|
import { nextRender } from "../../common/util/render-status";
|
||||||
import { haStyleScrollbar } from "../../resources/styles";
|
import { haStyleScrollbar } from "../../resources/styles";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-checkbox";
|
import "../ha-checkbox";
|
||||||
import type { HaCheckbox } from "../ha-checkbox";
|
import type { HaCheckbox } from "../ha-checkbox";
|
||||||
import "../ha-svg-icon";
|
import "../ha-svg-icon";
|
||||||
|
import "../search-input";
|
||||||
import { filterData, sortData } from "./sort-filter";
|
import { filterData, sortData } from "./sort-filter";
|
||||||
import { HomeAssistant } from "../../types";
|
|
||||||
import "@lit-labs/virtualizer";
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@ -461,7 +461,9 @@ export class HaDataTable extends LitElement {
|
|||||||
const elapsed = curTime - startTime;
|
const elapsed = curTime - startTime;
|
||||||
|
|
||||||
if (elapsed < 100) {
|
if (elapsed < 100) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100 - elapsed));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 100 - elapsed);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (this.curRequest !== curRequest) {
|
if (this.curRequest !== curRequest) {
|
||||||
return;
|
return;
|
||||||
|
@ -282,7 +282,9 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
private async _navigateAwayClose() {
|
private async _navigateAwayClose() {
|
||||||
// allow new page to open before closing dialog
|
// allow new page to open before closing dialog
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 0);
|
||||||
|
});
|
||||||
fireEvent(this, "close-dialog");
|
fireEvent(this, "close-dialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,9 @@ export const checkForEntityUpdates = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
// there is no reliable way to know if all the updates are done updating, so we just wait a bit for now...
|
// there is no reliable way to know if all the updates are done updating, so we just wait a bit for now...
|
||||||
await new Promise((r) => setTimeout(r, 10000));
|
await new Promise((r) => {
|
||||||
|
setTimeout(r, 10000);
|
||||||
|
});
|
||||||
|
|
||||||
unsubscribeEvents();
|
unsubscribeEvents();
|
||||||
|
|
||||||
|
@ -467,7 +467,9 @@ class MoreInfoClimate extends LitElement {
|
|||||||
// We reset stateObj to re-sync the inputs with the state. It will be out
|
// We reset stateObj to re-sync the inputs with the state. It will be out
|
||||||
// of sync if our service call did not result in the entity to be turned
|
// of sync if our service call did not result in the entity to be turned
|
||||||
// on. Since the state is not changing, the resync is not called automatic.
|
// on. Since the state is not changing, the resync is not called automatic.
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 2000);
|
||||||
|
});
|
||||||
|
|
||||||
// No need to resync if we received a new state.
|
// No need to resync if we received a new state.
|
||||||
if (this.stateObj !== curState) {
|
if (this.stateObj !== curState) {
|
||||||
|
@ -147,7 +147,9 @@ class MoreInfoHumidifier extends LitElement {
|
|||||||
// We reset stateObj to re-sync the inputs with the state. It will be out
|
// We reset stateObj to re-sync the inputs with the state. It will be out
|
||||||
// of sync if our service call did not result in the entity to be turned
|
// of sync if our service call did not result in the entity to be turned
|
||||||
// on. Since the state is not changing, the resync is not called automatic.
|
// on. Since the state is not changing, the resync is not called automatic.
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 2000);
|
||||||
|
});
|
||||||
|
|
||||||
// No need to resync if we received a new state.
|
// No need to resync if we received a new state.
|
||||||
if (this.stateObj !== curState) {
|
if (this.stateObj !== curState) {
|
||||||
|
@ -323,7 +323,9 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
|
|||||||
// Load config strings for integrations
|
// Load config strings for integrations
|
||||||
(this as any)._loadFragmentTranslations(this.hass!.language, "config");
|
(this as any)._loadFragmentTranslations(this.hass!.language, "config");
|
||||||
// Make sure hass is initialized + the config/user callbacks have called.
|
// Make sure hass is initialized + the config/user callbacks have called.
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +315,9 @@ export class HuiDialogEditCard
|
|||||||
|
|
||||||
private async _confirmCancel() {
|
private async _confirmCancel() {
|
||||||
// Make sure the open state of this dialog is handled before the open state of confirm dialog
|
// Make sure the open state of this dialog is handled before the open state of confirm dialog
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 0);
|
||||||
|
});
|
||||||
const confirm = await showConfirmationDialog(this, {
|
const confirm = await showConfirmationDialog(this, {
|
||||||
title: this.hass!.localize(
|
title: this.hass!.localize(
|
||||||
"ui.panel.lovelace.editor.edit_card.unsaved_changes"
|
"ui.panel.lovelace.editor.edit_card.unsaved_changes"
|
||||||
|
@ -162,7 +162,9 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
<div class="controls-progress">
|
<div class="controls-progress">
|
||||||
${until(
|
${until(
|
||||||
// Only show spinner after 500ms
|
// Only show spinner after 500ms
|
||||||
new Promise((resolve) => setTimeout(resolve, 500)).then(
|
new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 500);
|
||||||
|
}).then(
|
||||||
() => html`<ha-circular-progress active></ha-circular-progress>`
|
() => html`<ha-circular-progress active></ha-circular-progress>`
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { atLeastVersion } from "../common/config/version";
|
import { atLeastVersion } from "../common/config/version";
|
||||||
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { computeLocalize, LocalizeFunc } from "../common/translations/localize";
|
import { computeLocalize, LocalizeFunc } from "../common/translations/localize";
|
||||||
import {
|
import {
|
||||||
computeRTLDirection,
|
computeRTLDirection,
|
||||||
@ -16,14 +17,13 @@ import {
|
|||||||
} from "../data/translation";
|
} from "../data/translation";
|
||||||
import { translationMetadata } from "../resources/translations-metadata";
|
import { translationMetadata } from "../resources/translations-metadata";
|
||||||
import { Constructor, HomeAssistant } from "../types";
|
import { Constructor, HomeAssistant } from "../types";
|
||||||
import { storeState } from "../util/ha-pref-storage";
|
|
||||||
import {
|
import {
|
||||||
getLocalLanguage,
|
getLocalLanguage,
|
||||||
getTranslation,
|
getTranslation,
|
||||||
getUserLocale,
|
getUserLocale,
|
||||||
} from "../util/common-translation";
|
} from "../util/common-translation";
|
||||||
|
import { storeState } from "../util/ha-pref-storage";
|
||||||
import { HassBaseEl } from "./hass-base-mixin";
|
import { HassBaseEl } from "./hass-base-mixin";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@ -373,7 +373,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
// overwritten when we call _updateHass the second time!
|
// overwritten when we call _updateHass the second time!
|
||||||
|
|
||||||
// Allow hass to be updated
|
// Allow hass to be updated
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 0);
|
||||||
|
});
|
||||||
|
|
||||||
if (language !== (this.hass ?? this._pendingHass).language) {
|
if (language !== (this.hass ?? this._pendingHass).language) {
|
||||||
// the language was changed, abort
|
// the language was changed, abort
|
||||||
|
Loading…
x
Reference in New Issue
Block a user