try reintegrating backbone
This commit is contained in:
parent
b1bfa757cb
commit
b6d8a2f568
1 changed files with 6 additions and 2 deletions
|
@ -20,7 +20,7 @@ const ChatView = {
|
||||||
const self = ChatView
|
const self = ChatView
|
||||||
self.room = room
|
self.room = room
|
||||||
self.mapper = mapper
|
self.mapper = mapper
|
||||||
self.messages = messages.models.map(m => m.attributes)
|
self.messages = messages
|
||||||
|
|
||||||
self.isOpen = false
|
self.isOpen = false
|
||||||
self.alertSound = true // whether to play sounds on arrival of new messages or not
|
self.alertSound = true // whether to play sounds on arrival of new messages or not
|
||||||
|
@ -48,7 +48,7 @@ const ChatView = {
|
||||||
leaveCall: Realtime.leaveCall,
|
leaveCall: Realtime.leaveCall,
|
||||||
joinCall: Realtime.joinCall,
|
joinCall: Realtime.joinCall,
|
||||||
participants: self.participants,
|
participants: self.participants,
|
||||||
messages: self.messages,
|
messages: self.messages.models.map(m => m.attributes),
|
||||||
unreadMessages: self.unreadMessages,
|
unreadMessages: self.unreadMessages,
|
||||||
buttonClick: self.buttonClick,
|
buttonClick: self.buttonClick,
|
||||||
videoToggleClick: self.videoToggleClick,
|
videoToggleClick: self.videoToggleClick,
|
||||||
|
@ -71,6 +71,7 @@ const ChatView = {
|
||||||
ChatView.render()
|
ChatView.render()
|
||||||
},
|
},
|
||||||
addParticipant: participant => {
|
addParticipant: participant => {
|
||||||
|
// TODO this should probably be using a Backbone collection????
|
||||||
const p = participant.attributes ? clone(participant.attributes) : participant
|
const p = participant.attributes ? clone(participant.attributes) : participant
|
||||||
ChatView.participants.push(p)
|
ChatView.participants.push(p)
|
||||||
ChatView.render()
|
ChatView.render()
|
||||||
|
@ -85,6 +86,7 @@ const ChatView = {
|
||||||
if (render) ChatView.render()
|
if (render) ChatView.render()
|
||||||
},
|
},
|
||||||
addMessage: (message, isInitial, wasMe) => {
|
addMessage: (message, isInitial, wasMe) => {
|
||||||
|
const self = ChatView
|
||||||
if (!self.isOpen && !isInitial) ChatView.incrementUnread(false) // TODO don't need to render, right?
|
if (!self.isOpen && !isInitial) ChatView.incrementUnread(false) // TODO don't need to render, right?
|
||||||
|
|
||||||
function addZero(i) {
|
function addZero(i) {
|
||||||
|
@ -111,6 +113,8 @@ const ChatView = {
|
||||||
if (!wasMe && !isInitial && self.alertSound) self.sound.play('receivechat')
|
if (!wasMe && !isInitial && self.alertSound) self.sound.play('receivechat')
|
||||||
},
|
},
|
||||||
handleInputMessage: text => {
|
handleInputMessage: text => {
|
||||||
|
// TODO use backbone
|
||||||
|
ChatView.addMessage(text, false, false)
|
||||||
$(document).trigger(ChatView.events.message + '-' + self.room, [{ message: text }])
|
$(document).trigger(ChatView.events.message + '-' + self.room, [{ message: text }])
|
||||||
},
|
},
|
||||||
leaveConversation: () => {
|
leaveConversation: () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue