From b6d8a2f5684c85c7a48bd7f592d5cb79fcd17f58 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 19 Dec 2016 00:49:18 -0500 Subject: [PATCH] try reintegrating backbone --- frontend/src/Metamaps/Views/ChatView.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/Metamaps/Views/ChatView.js b/frontend/src/Metamaps/Views/ChatView.js index 312be623..a3398ed6 100644 --- a/frontend/src/Metamaps/Views/ChatView.js +++ b/frontend/src/Metamaps/Views/ChatView.js @@ -20,7 +20,7 @@ const ChatView = { const self = ChatView self.room = room self.mapper = mapper - self.messages = messages.models.map(m => m.attributes) + self.messages = messages self.isOpen = false self.alertSound = true // whether to play sounds on arrival of new messages or not @@ -48,7 +48,7 @@ const ChatView = { leaveCall: Realtime.leaveCall, joinCall: Realtime.joinCall, participants: self.participants, - messages: self.messages, + messages: self.messages.models.map(m => m.attributes), unreadMessages: self.unreadMessages, buttonClick: self.buttonClick, videoToggleClick: self.videoToggleClick, @@ -71,6 +71,7 @@ const ChatView = { ChatView.render() }, addParticipant: participant => { + // TODO this should probably be using a Backbone collection???? const p = participant.attributes ? clone(participant.attributes) : participant ChatView.participants.push(p) ChatView.render() @@ -85,6 +86,7 @@ const ChatView = { if (render) ChatView.render() }, addMessage: (message, isInitial, wasMe) => { + const self = ChatView if (!self.isOpen && !isInitial) ChatView.incrementUnread(false) // TODO don't need to render, right? function addZero(i) { @@ -111,6 +113,8 @@ const ChatView = { if (!wasMe && !isInitial && self.alertSound) self.sound.play('receivechat') }, handleInputMessage: text => { + // TODO use backbone + ChatView.addMessage(text, false, false) $(document).trigger(ChatView.events.message + '-' + self.room, [{ message: text }]) }, leaveConversation: () => {