diff --git a/package.json b/package.json index e281fc882d..e320fc9ff2 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "idb-keyval": "^3.2.0", "intl-messageformat": "^8.3.9", "js-yaml": "^3.13.1", - "leaflet": "^1.4.0", + "leaflet": "^1.7.1", "leaflet-draw": "^1.0.4", "lit-element": "^2.5.0", "lit-html": "^1.4.0", @@ -169,8 +169,8 @@ "@types/chromecast-caf-receiver": "^5.0.11", "@types/chromecast-caf-sender": "^1.0.3", "@types/js-yaml": "^3.12.1", - "@types/leaflet": "^1.4.3", - "@types/leaflet-draw": "^1.0.1", + "@types/leaflet": "^1.7.0", + "@types/leaflet-draw": "^1.0.3", "@types/marked": "^1.2.2", "@types/memoize-one": "4.1.0", "@types/mocha": "^7.0.2", diff --git a/src/components/map/ha-locations-editor.ts b/src/components/map/ha-locations-editor.ts index 184813c32e..5991f36706 100644 --- a/src/components/map/ha-locations-editor.ts +++ b/src/components/map/ha-locations-editor.ts @@ -286,12 +286,11 @@ export class HaLocationsEditor extends LitElement { [location.latitude, location.longitude], options ) - .addEventListener( - "dragend", - // @ts-ignore - (ev: DragEndEvent) => this._updateLocation(ev) + .addEventListener("dragend", (ev: DragEndEvent) => + this._updateLocation(ev) ) .addEventListener( + // @ts-ignore "click", // @ts-ignore (ev: MouseEvent) => this._markerClicked(ev) diff --git a/src/panels/config/core/ha-config-core-form.ts b/src/panels/config/core/ha-config-core-form.ts index f14b1ca526..2d3bfff403 100644 --- a/src/panels/config/core/ha-config-core-form.ts +++ b/src/panels/config/core/ha-config-core-form.ts @@ -13,6 +13,7 @@ import { property, TemplateResult, } from "lit-element"; +import memoizeOne from "memoize-one"; import { UNIT_C } from "../../../common/const"; import "../../../components/ha-card"; import "../../../components/map/ha-location-editor"; @@ -62,7 +63,11 @@ class ConfigCoreForm extends LitElement { @@ -165,11 +170,9 @@ class ConfigCoreForm extends LitElement { input.inputElement.appendChild(createTimezoneListEl()); } - private get _locationValue() { - return this._location !== undefined - ? this._location - : [Number(this.hass.config.latitude), Number(this.hass.config.longitude)]; - } + private _locationValue = memoizeOne( + (location, lat, lng) => location || [Number(lat), Number(lng)] + ); private get _elevationValue() { return this._elevation !== undefined @@ -209,7 +212,11 @@ class ConfigCoreForm extends LitElement { private async _save() { this._working = true; try { - const location = this._locationValue; + const location = this._locationValue( + this._location, + this.hass.config.latitude, + this.hass.config.longitude + ); await saveCoreConfig(this.hass, { latitude: location[0], longitude: location[1], diff --git a/src/panels/config/tags/dialog-tag-detail.ts b/src/panels/config/tags/dialog-tag-detail.ts index 68e9f39b0e..3a8655fd6c 100644 --- a/src/panels/config/tags/dialog-tag-detail.ts +++ b/src/panels/config/tags/dialog-tag-detail.ts @@ -14,7 +14,6 @@ import { fireEvent } from "../../../common/dom/fire_event"; import { createCloseHeading } from "../../../components/ha-dialog"; import "../../../components/ha-formfield"; import "../../../components/ha-switch"; -import "../../../components/map/ha-location-editor"; import { Tag, UpdateTagParams } from "../../../data/tag"; import { HassDialog } from "../../../dialogs/make-dialog-manager"; import { haStyleDialog } from "../../../resources/styles"; diff --git a/src/panels/config/zone/dialog-zone-detail.ts b/src/panels/config/zone/dialog-zone-detail.ts index b2dd807734..d06e6bce0e 100644 --- a/src/panels/config/zone/dialog-zone-detail.ts +++ b/src/panels/config/zone/dialog-zone-detail.ts @@ -9,6 +9,7 @@ import { property, TemplateResult, } from "lit-element"; +import memoizeOne from "memoize-one"; import { fireEvent } from "../../../common/dom/fire_event"; import { addDistanceToCoord } from "../../../common/location/add_distance_to_coord"; import { computeRTLDirection } from "../../../common/util/compute_rtl"; @@ -141,7 +142,7 @@ class DialogZoneDetail extends LitElement { [Number(lat), Number(lng)]); private _locationChanged(ev) { [this._latitude, this._longitude] = ev.currentTarget.location; diff --git a/yarn.lock b/yarn.lock index 5591afd29b..1b7f205fdf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2786,10 +2786,10 @@ "@types/koa-compose" "*" "@types/node" "*" -"@types/leaflet-draw@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@types/leaflet-draw/-/leaflet-draw-1.0.1.tgz#66e0c2c8b93b23487f836a8d65a769b98aa0bc5b" - integrity sha512-/urwtXkpvv7rtre5A6plvXHSUDmFvDrwqpQRKseBCC2bIhIhBtMDf+plqQmi0vhvSk0Pqgk8qH1rtC8EVxPdmg== +"@types/leaflet-draw@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@types/leaflet-draw/-/leaflet-draw-1.0.3.tgz#73a003bf1def575c7cfd3205fa48d26bd0dc4273" + integrity sha512-ayNnO40vafd1Do3h7v0++toEzcO1CEjtFBqPunF3695WU0OTPzJ82XUQcd4MlYTuPSP3OsZm5ni361tgmcjxNw== dependencies: "@types/leaflet" "*" @@ -2800,10 +2800,10 @@ dependencies: "@types/geojson" "*" -"@types/leaflet@^1.4.3": - version "1.4.3" - resolved "https://registry.yarnpkg.com/@types/leaflet/-/leaflet-1.4.3.tgz#62638cb73770eeaed40222042afbcc7b495f0cc4" - integrity sha512-jFRBSsPHi1EwQSwrN0cOJLdPhwOZsRl4IMxvm/2ShLh0YM5GfCtQXCzsrv8RE7DWL+AykXdYSAd9bFLWbZT4CQ== +"@types/leaflet@^1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@types/leaflet/-/leaflet-1.7.0.tgz#3700fb5d29a8214fbd496565b08ec28e40cee808" + integrity sha512-ltv5jR+VjKSMtoDkxH61Rsbo0zLU7iqyOXpVPkAX4F+79fg2eymC7t0msWsfNaEZO1FGTIQATCCCQe+ijWoicg== dependencies: "@types/geojson" "*" @@ -8598,10 +8598,10 @@ leaflet-draw@^1.0.4: resolved "https://registry.yarnpkg.com/leaflet-draw/-/leaflet-draw-1.0.4.tgz#45be92f378ed253e7202fdeda1fcc71885198d46" integrity sha512-rsQ6saQO5ST5Aj6XRFylr5zvarWgzWnrg46zQ1MEOEIHsppdC/8hnN8qMoFvACsPvTioAuysya/TVtog15tyAQ== -leaflet@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.4.0.tgz#d5f56eeb2aa32787c24011e8be4c77e362ae171b" - integrity sha512-x9j9tGY1+PDLN9pcWTx9/y6C5nezoTMB8BLK5jTakx+H7bPlnbCHfi9Hjg+Qt36sgDz/cb9lrSpNQXmk45Tvhw== +leaflet@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.7.1.tgz#10d684916edfe1bf41d688a3b97127c0322a2a19" + integrity sha512-/xwPEBidtg69Q3HlqPdU3DnrXQOvQU/CCHA1tcDQVzOwm91YMYaILjNp7L4Eaw5Z4sOYdbBz6koWyibppd8Zqw== leven@^3.1.0: version "3.1.0"