Skip to content
Snippets Groups Projects
Commit e39134ae authored by Rafael Caferati's avatar Rafael Caferati
Browse files

Fixed chatMessage bug

parent 877c67b2
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ Template.messageBox.events
KonchatNotification.removeRoomNotification @_id
'keyup .input-message': (event) ->
Template.instance().chatMessages.keyup(@_id, event, Template.instance())
chatMessages[Session.get('openedRoom')].keyup(@_id, event, Template.instance())
'paste .input-message': (e) ->
if not e.originalEvent.clipboardData?
......@@ -80,22 +80,21 @@ Template.messageBox.events
fileUpload files
'keydown .input-message': (event) ->
Template.instance().chatMessages.keydown(@_id, event, Template.instance())
chatMessages[Session.get('openedRoom')].keydown(@_id, event, Template.instance())
'click .message-form .icon-paper-plane': (event) ->
input = $(event.currentTarget).siblings("textarea")
Template.instance().chatMessages.send(this._id, input.get(0))
chatMessages[Session.get('openedRoom')].send(this._id, input.get(0))
event.preventDefault()
event.stopPropagation()
input.focus()
input.get(0).updateAutogrow()
"click .editing-commands-cancel > a": (e) ->
Template.instance().chatMessages.clearEditing()
chatMessages[Session.get('openedRoom')].clearEditing()
"click .editing-commands-save > a": (e) ->
chatMessages = Template.instance().chatMessages
chatMessages.send(@_id, chatMessages.input)
chatMessages[Session.get('openedRoom')].send(@_id, chatMessages.input)
......@@ -131,5 +130,6 @@ Template.messageBox.events
t.$('.mic').removeClass('hidden')
Template.messageBox.onRendered ->
this.chatMessages = new ChatMessages
this.chatMessages.init(this.firstNode)
\ No newline at end of file
# unless window.chatMessages[Session.get('openedRoom')]
# window.chatMessages[Session.get('openedRoom')] = new ChatMessages
# this.chatMessages.init(this.firstNode)
\ No newline at end of file
class @ChatMessages
init: (node) ->
this.editing = {}
this.messageMaxSize = RocketChat.settings.get('Message_MaxAllowedSize')
this.wrapper = $(node).find(".wrapper")
this.input = $(node).find(".input-message").get(0)
......@@ -41,7 +40,7 @@ class @ChatMessages
edit: (element, index) ->
id = element.getAttribute("id")
message = ChatMessage.findOne { _id: id }
message = ChatMessage.findOne { _id: id }
hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid)
editAllowed = RocketChat.settings.get 'Message_AllowEditing'
editOwn = message?.u?._id is Meteor.userId()
......
......@@ -368,11 +368,10 @@ Template.room.events
'click .pin-message': (event) ->
message = @_arguments[1]
instance = Template.instance()
if message.pinned
instance.chatMessages.unpinMsg(message)
chatMessages[Session.get('openedRoom')].unpinMsg(message)
else
instance.chatMessages.pinMsg(message)
chatMessages[Session.get('openedRoom')].pinMsg(message)
'dragenter .dropzone': (e) ->
e.currentTarget.classList.add 'over'
......@@ -444,8 +443,11 @@ Template.room.onDestroyed ->
Template.room.onRendered ->
this.chatMessages = new ChatMessages
this.chatMessages.init(this.firstNode)
unless window.chatMessages
window.chatMessages = {}
unless window.chatMessages[Session.get('openedRoom')]
window.chatMessages[Session.get('openedRoom')] = new ChatMessages
chatMessages[Session.get('openedRoom')].init(this.firstNode)
# ScrollListener.init()
wrapper = this.find('.wrapper')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment