Skip to content

Commit

Permalink
trust / app.id fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmarkclements committed May 9, 2024
1 parent 465ee54 commit 7d2234c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
14 changes: 7 additions & 7 deletions decal.html
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ <h1 id="header">Unknown app</h1>
await Pear.Window.self.close()
})
}
setKey (key) {
this.key.innerText = 'pear://' + key
setLink (link) {
this.key.innerText = link
}
})
</script>
Expand Down Expand Up @@ -644,14 +644,14 @@ <h1 id="header">Unknown app</h1>
}

if (type === 'permissionRequired') {
const decalDialog = document.createElement('decal-dialog')
const trustConfirm = document.createElement('decal-dialog')
const ctrl = document.createElement('pear-ctrl')
document.documentElement.classList.add('dialog')
document.body.appendChild(ctrl)
document.body.appendChild(decalDialog)
decalDialog.setKey(report.key)
decalDialog.trust = async () => {
await this.ipc.trust({ id: this.gid, key: report.key })
document.body.appendChild(trustConfirm)
trustConfirm.setLink(report.key.link)
trustConfirm.trust = async () => {
await this.ipc.trust({ z32: report.key.z32 })
await this.ipc.restart({ id: this.gid })
}

Expand Down
3 changes: 3 additions & 0 deletions electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ async function electronMain (cmd) {
flags: cmd.flags
})
Context.storage(ctx)

if (ctx.error) {
console.error(ctx.error)
electron.app.quit(1)
return
}

const gui = new GUI({
socketPath: SOCKET_PATH,
connectTimeout: CONNECT_TIMEOUT,
tryboot,
ctx
})

await gui.ready()

// note: would be unhandled rejection on failure, but should never fail:
Expand Down
13 changes: 6 additions & 7 deletions gui/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,10 @@ class Window extends GuiCtrl {
}
})

if (this.id === null) this.id = idify(this)
this.constructor[kMap].set(this.id, this)

if (decal === false) {
if (this.id === null) this.id = idify(this)
this.constructor[kMap].set(this.id, this)
await this.win.loadURL(this.entry)
this.opening = false
this.closed = false
Expand Down Expand Up @@ -1070,10 +1071,8 @@ class Window extends GuiCtrl {
viewInitialized()
this.view.webContents.once('did-finish-load', () => { viewLoaded() })

if (this.id === null) {
this.id = idify(this)
this.constructor[kMap].set(this.id, this)
}
this.id = idify(this)
this.constructor[kMap].set(this.id, this)

await decalLoading
if (this.closing) return false
Expand Down Expand Up @@ -1673,7 +1672,7 @@ class PearGUI extends ReadyResource {

reports () { return this.ipc.reports() }

trust ({ id, key }) { return this.ipc.trust({ z32: key }) }
trust ({ z32 }) { return this.ipc.trust({ z32 }) }

// DEPRECATED - assess to remove from Sep 2024
preferences () { return this.ipc.preferences() }
Expand Down
1 change: 1 addition & 0 deletions gui/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = class PearGUI extends ReadyResource {
constructor ({ API, ctx }) {
super()
const id = this.id = electron.ipcRenderer.sendSync('id')

this.ipc = new IPC()
electron.ipcRenderer.on('ipc', (e, data) => {
this.ipc.stream.push(Buffer.from(data))
Expand Down

0 comments on commit 7d2234c

Please sign in to comment.