Skip to content

Commit

Permalink
Add reload window to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Jan 1, 2020
1 parent c4df84c commit 667d39b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/HacsFrontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
property,
TemplateResult
} from "lit-element";
import { HACS, Hacs } from "./Hacs";
import { HACS } from "./Hacs";
import { HacsStyle } from "./style/hacs-style";

import {
Expand Down Expand Up @@ -52,7 +52,9 @@ class HacsFrontendBase extends LitElement {
if (this.hacs.isnullorempty(repositories))
repositories = this.hacs.repositories;
if (this.hacs.isnullorempty(status)) status = this.hacs.status;
this.hacs = new Hacs(configuration, repositories, status);
this.hacs.configuration = configuration;
this.hacs.repositories = repositories;
this.hacs.status = status;
this.requestUpdate();
}

Expand Down Expand Up @@ -144,6 +146,7 @@ class HacsFrontendBase extends LitElement {
this.addEventListener("hacs-location-change", this.locationChanged);
this.addEventListener("hacs-onboarding-done", this.onboardingDone);
this.addEventListener("hacs-recreate", this._recreatehacs);
this.addEventListener("hacs-force-reload", this._reload);
window.onpopstate = function() {
window.location.reload();
};
Expand Down Expand Up @@ -184,7 +187,9 @@ class HacsFrontendBase extends LitElement {
}

_reload(e: any) {
window.location.reload(e.data.force);
const force =
(e.data && e.data.force) || (e.detail && e.detail.force) || false;
window.location.reload(force);
}

protected render(): TemplateResult | void {
Expand Down
1 change: 1 addition & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"missing_category": "You need to select a category",
"open_repository": "Open repository",
"reload_data": "Reload data",
"reload_window": "Reload window",
"repository_configuration": "Repository configuration",
"save": "Save",
"table_view": "Table view",
Expand Down
14 changes: 14 additions & 0 deletions src/misc/HacsMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class HacsMenu extends LitElement {
${this.hacs.localize("settings.reload_data")}
</paper-item>
<paper-item @click=${this.ReloadWindow}>
${this.hacs.localize("settings.reload_window")}
</paper-item>
${this.location.includes("installed")
? html`
<paper-item @click=${this.UpgradeAll} class="uninstall-button">
Expand Down Expand Up @@ -126,6 +130,16 @@ export class HacsMenu extends LitElement {
});
}

ReloadWindow() {
this.dispatchEvent(
new CustomEvent("hacs-force-reload", {
detail: { force: true },
bubbles: true,
composed: true
})
);
}

ReloadData() {
if (this.status.background_task) {
this.disabledAction();
Expand Down

0 comments on commit 667d39b

Please sign in to comment.