Skip to content

Commit

Permalink
Bugfix 1.7.1 - Fix bad listeners detachment for characteristics (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
GogoVega authored Sep 24, 2024
1 parent 9951459 commit e14951b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.1] - 2024-09-24

### Fixed

- Fix bad listeners detachment for characteristics [#563](https://github.com/NRCHKB/node-red-contrib-homekit-bridged/issues/563)

## [1.7.0] - 2024-09-19

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-homekit-bridged",
"version": "1.7.0",
"version": "1.7.1",
"description": "Node-RED nodes to simulate Apple HomeKit devices.",
"main": "build/nodes/nrchkb.js",
"scripts": {
Expand Down
19 changes: 10 additions & 9 deletions src/lib/utils/CharacteristicUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,21 @@ module.exports = function (node: HAPServiceNodeType) {
service.optionalCharacteristics
)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)

allCharacteristics.map((characteristic) => {
const cKey = characteristic.constructor.name

supported.push(cKey)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)
characteristic.on('get', node.onCharacteristicGet)
characteristic.on('set', node.onCharacteristicSet)
characteristic.on('change', node.onCharacteristicChange)
Expand Down
23 changes: 12 additions & 11 deletions src/lib/utils/CharacteristicUtils2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,23 @@ module.exports = function (node: HAPService2NodeType) {
service.optionalCharacteristics
)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet(
service.characteristics
)
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)

allCharacteristics.map((characteristic) => {
const cKey = characteristic.constructor.name

supported.push(cKey)

// Listen to characteristic events and store the listener functions
// to be able to remove them later
node.onCharacteristicGet = ServiceUtils.onCharacteristicGet(
service.characteristics
)
node.onCharacteristicSet = ServiceUtils.onCharacteristicSet(
service.characteristics
)
node.onCharacteristicChange = ServiceUtils.onCharacteristicChange(
service.characteristics
)
characteristic.on('get', node.onCharacteristicGet)
characteristic.on('set', node.onCharacteristicSet)
characteristic.on('change', node.onCharacteristicChange)
Expand Down

0 comments on commit e14951b

Please sign in to comment.