Skip to content

Commit

Permalink
Revert "only add message listener when we're adding a new channel"
Browse files Browse the repository at this point in the history
This reverts commit 1dbd522.

It seems this commit introduced a regression in functionality such that
messages do not appear in channels
(#78) and might also be
responsible for a similar bug in cabal-desktop@6.0.8

It would be good to only add the relevant message listeners, instead of
duplicates, but I think it will have to be done anew with fresh eyes.
  • Loading branch information
cblgh committed Oct 23, 2021
1 parent ddaa61b commit 1bf10a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/cabal-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,10 @@ class CabalDetails extends EventEmitter {
const details = this.channels[channel]
if (!details) {
this.channels[channel] = new ChannelDetails(cabal, channel)
// note: only add listener if we don't have a channel registered (=> prevent duplicate listeners)
cabal.messages.events.on(channel, this.messageListener.bind(this))
}
// TODO: only do this for our joined channels, instead of all channels
// Calls fn with every new message that arrives in channel.
cabal.messages.events.on(channel, this.messageListener.bind(this))
this._emitUpdate('new-channel', { channel })
})
}
Expand Down
5 changes: 2 additions & 3 deletions src/initialization-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ module.exports.getArchivesCallback = function (err, archivedChannels) {
const details = this.channels[channel]
if (!details) {
this.channels[channel] = new ChannelDetails(cabal, channel)
// listen for updates that happen within the channel
// note: only add listener if we don't have a channel registered (=> prevent duplicate listeners)
cabal.messages.events.on(channel, this.messageListener.bind(this))
}
// mark archived channels as such
if (archivedChannels.indexOf(channel) >= 0) {
this.channels[channel].archive()
}
// listen for updates that happen within the channel
cabal.messages.events.on(channel, this.messageListener.bind(this))

// add all users joined to a channel
cabal.memberships.getUsers(channel, (err, users) => {
Expand Down

0 comments on commit 1bf10a9

Please sign in to comment.