diff --git a/lib/system-status.js b/lib/system-status.js index 6497771..489ef96 100644 --- a/lib/system-status.js +++ b/lib/system-status.js @@ -73,6 +73,8 @@ customElements.define('system-status', class extends HTMLElement { this.shellProfiles = null this.root = this.attachShadow({ mode: 'open' }) this.#render() + this.updateButton = this.shadowRoot.querySelector('#update-button') + this.update = null } #render () { @@ -98,6 +100,12 @@ customElements.define('system-status', class extends HTMLElement { #tip { margin-top: 3rem; } + #update-button { + position: fixed; + left: 975px; + top: 170px; + display: none; + } h1 { padding: 0.5rem; display: inline-block; @@ -110,6 +118,7 @@ customElements.define('system-status', class extends HTMLElement { }

System Status

+ ${ this.#installed() ? '' @@ -120,14 +129,21 @@ customElements.define('system-status', class extends HTMLElement {

To finish installing Pear Runtime set your system path to

${BIN}

${!isWin? ' or click the button.' : ''}

- ${!isWin ? '

' : ''} + ${!isWin ? '

' : ''} ` } ` - this.shadowRoot.querySelector('button')?.addEventListener('click', () => { + this.shadowRoot.querySelector('#setup-button')?.addEventListener('click', () => { this.#install().then(() => this.#render()).catch((err) => this.#error(err)) }) + + Pear.updates((update) => { + this.update = update + this.updateButton.style.display = '' + this.updateButton.removeEventListener('click', this.#updateButtonListener) + this.updateButton.addEventListener('click', this.#updateButtonListener) + }) } #error (err) { @@ -200,4 +216,8 @@ customElements.define('system-status', class extends HTMLElement { process.env.PATH = `${BIN}:${process.env.PATH}` return Promise.resolve() } + + #updateButtonListener () { + Pear.restart({ platform: this.update.app === false }).catch(console.error) + } })