Skip to content

Commit

Permalink
Unpair devices after pulling schema
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Sep 7, 2023
1 parent 8085c12 commit 4c0419a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,4 @@ dist
# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,intellij+all,git

.wrangler/
.dev.vars
10 changes: 10 additions & 0 deletions src/routes/pull-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ResponseData = {
modelResponse: ObjectType
detailsResponse: ObjectType
updateResponse: ObjectType
deleteResponse: boolean
errors: string[]
}

Expand Down Expand Up @@ -229,6 +230,15 @@ export async function pullSchema(
errors.push(`${e}`)
}

// unpair the device to make switching category possible
try {
responseContext.deleteResponse = await unpack(
tuya.device.delete({ device_id: devId }),
)
} catch (e) {
errors.push(`${e}`)
}

responseContext.cachedAt = Date.now()
responseContext.cacheKey = productKey

Expand Down

0 comments on commit 4c0419a

Please sign in to comment.