Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions src/components/map/ha-locations-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 14 additions & 7 deletions src/panels/config/core/ha-config-core-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -62,7 +63,11 @@ class ConfigCoreForm extends LitElement {
<ha-location-editor
class="flex"
.hass=${this.hass}
.location=${this._locationValue}
.location=${this._locationValue(
this._location,
this.hass.config.latitude,
this.hass.config.longitude
)}
@change=${this._locationChanged}
></ha-location-editor>
</div>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down
1 change: 0 additions & 1 deletion src/panels/config/tags/dialog-tag-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 3 additions & 4 deletions src/panels/config/zone/dialog-zone-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -141,7 +142,7 @@ class DialogZoneDetail extends LitElement {
<ha-location-editor
class="flex"
.hass=${this.hass}
.location=${this._locationValue}
.location=${this._locationValue(this._latitude, this._longitude)}
.radius=${this._radius}
.radiusColor=${this._passive
? passiveRadiusColor
Expand Down Expand Up @@ -228,9 +229,7 @@ class DialogZoneDetail extends LitElement {
`;
}

private get _locationValue() {
return [Number(this._latitude), Number(this._longitude)];
}
private _locationValue = memoizeOne((lat, lng) => [Number(lat), Number(lng)]);

private _locationChanged(ev) {
[this._latitude, this._longitude] = ev.currentTarget.location;
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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" "*"

Expand All @@ -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" "*"

Expand Down Expand Up @@ -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"
Expand Down