{"action":"created","issue":{"url":"https://api.github.com/repos/andrerpena/chatjs/issues/12","labels_url":"https://api.github.com/repos/andrerpena/chatjs/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/andrerpena/chatjs/issues/12/comments","events_url":"https://api.github.com/repos/andrerpena/chatjs/issues/12/events","html_url":"https://github.com/andrerpena/chatjs/issues/12","id":59918901,"number":12,"title":"Closing chat/pm windows then re-opening","user":{"login":"onsetrese","id":422065,"avatar_url":"https://avatars.githubusercontent.com/u/422065?v=3","gravatar_id":"","url":"https://api.github.com/users/onsetrese","html_url":"https://github.com/onsetrese","followers_url":"https://api.github.com/users/onsetrese/followers","following_url":"https://api.github.com/users/onsetrese/following{/other_user}","gists_url":"https://api.github.com/users/onsetrese/gists{/gist_id}","starred_url":"https://api.github.com/users/onsetrese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onsetrese/subscriptions","organizations_url":"https://api.github.com/users/onsetrese/orgs","repos_url":"https://api.github.com/users/onsetrese/repos","events_url":"https://api.github.com/users/onsetrese/events{/privacy}","received_events_url":"https://api.github.com/users/onsetrese/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-03-05T08:14:49Z","updated_at":"2015-12-04T15:37:50Z","closed_at":null,"body":"When you open then close a chatbox then reopen the same window( userClicked function ), and type in the textbox and press send, the messages get double send. the client adapter onMessagesChanged function/listener gets called in as many times as you close open the private chat box with the same user. I hope you understand what Im saying :)"},"comment":{"url":"https://api.github.com/repos/andrerpena/chatjs/issues/comments/161998449","html_url":"https://github.com/andrerpena/chatjs/issues/12#issuecomment-161998449","issue_url":"https://api.github.com/repos/andrerpena/chatjs/issues/12","id":161998449,"user":{"login":"eniebla","id":14164322,"avatar_url":"https://avatars.githubusercontent.com/u/14164322?v=3","gravatar_id":"","url":"https://api.github.com/users/eniebla","html_url":"https://github.com/eniebla","followers_url":"https://api.github.com/users/eniebla/followers","following_url":"https://api.github.com/users/eniebla/following{/other_user}","gists_url":"https://api.github.com/users/eniebla/gists{/gist_id}","starred_url":"https://api.github.com/users/eniebla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eniebla/subscriptions","organizations_url":"https://api.github.com/users/eniebla/orgs","repos_url":"https://api.github.com/users/eniebla/repos","events_url":"https://api.github.com/users/eniebla/events{/privacy}","received_events_url":"https://api.github.com/users/eniebla/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T15:37:50Z","updated_at":"2015-12-04T15:37:50Z","body":"I think i find the final solution for this bug, it's simple. I mix @rpaschoal  and @onsetrese ideas, jejeje\r\nFIRST:--->\r\n   File: jquery.chatjs.messageboard.js\r\n   find this.options.adapter.client.onMessagesChanged, then add the 2nd parameter this.options.otherUserId at the end, basically youll have \r\n   this.options.adapter.client.onMessagesChanged(function (message) {...}, this.options.otherUserId);\r\n\r\nSECOND:--->\r\nFile: jquery.chatjs.adapter.demo.js\r\nfunction DemoClientAdapter() {\r\n        this.messagesChangedHandlers = [];\r\n        this.typingSignalReceivedHandlers = [];\r\n        this.userListChangedHandlers = [];\r\n        this.handlersIndex = new Array(); //this is the fix\r\n    }\r\n\r\nTHIRD AND FINALLY:---->\r\nFile: jquery.chatjs.adapter.demo.js\r\nDemoClientAdapter.prototype.onMessagesChanged = function (handler,otherUserId) {                \r\n        var shouldAddHandler=true;\r\n        if ('undefined'!==typeof otherUserId)\r\n            for(var i=0;i<this.handlersIndex.length;i++)\r\n                if(this.handlersIndex[i]['id']===otherUserId){                    \r\n                    this.messagesChangedHandlers[i]=handler;\r\n                    shouldAddHandler=false;break;\r\n                }        \r\n        if(shouldAddHandler){           \r\n            this.handlersIndex.push({id:otherUserId});            \r\n            this.messagesChangedHandlers.push(handler);          \r\n            console.log(\"Adding Handlers PM. Index => \" + (this.handlersIndex.length-1) +' for otherUserId=> ' + otherUserId);\r\n        }\r\n    };\r\n\r\nHope this helps, the author really should change that ASAP!\r\n"}}