Skip to content

Commit

Permalink
fix: forget streamdeck studios when resetting config #3034
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Sep 16, 2024
1 parent d86c2de commit 7e90456
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion companion/lib/Data/ImportExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class DataImportExport extends CoreBase {
}

if (!config || config.surfaces) {
this.surfaces.reset()
await this.surfaces.reset()
}

if (!config || config.triggers) {
Expand Down
7 changes: 6 additions & 1 deletion companion/lib/Surface/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,15 @@ class SurfaceController extends CoreBase {
return result
}

reset() {
async reset() {
// Each active handler will re-add itself when doing the save as part of its own reset
this.db.setKey('deviceconfig', {})
this.db.setKey('surface-groups', {})
this.#outboundController.reset()

// Wait for the surfaces to disconnect before clearing their config
await new Promise((resolve) => setTimeout(resolve, 500))

this.#resetAllDevices()
this.updateDevicesList()
}
Expand Down
16 changes: 16 additions & 0 deletions companion/lib/Surface/Outbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ export class SurfaceOutboundController {
})
}

reset() {
this.#streamdeckTcpConnectionManager.disconnectFromAll()

/** @type {import('@companion-app/shared/Model/Surfaces.js').OutboundSurfacesUpdateRemoveOp[]} */
const ops = Object.keys(this.#storage).map((id) => ({
type: 'remove',
itemId: id,
}))
if (ops.length > 0) {
this.#io.emitToRoom(OutboundSurfacesRoom, 'surfaces:outbound:update', ops)
}

this.#storage = {}
this.#saveToDb()
}

quit() {
this.#streamdeckTcpConnectionManager.disconnectFromAll()
}
Expand Down

0 comments on commit 7e90456

Please sign in to comment.