38 lines
698 B
CoffeeScript
38 lines
698 B
CoffeeScript
$ = jQuery
|
|
context = window
|
|
logger = context.JK.logger
|
|
|
|
@ChatStore = Reflux.createStore(
|
|
{
|
|
listenables: @ChatActions
|
|
|
|
msgs: {}
|
|
|
|
init: ->
|
|
# Register with the app store to get @app
|
|
this.listenTo(context.AppStore, this.onAppInit)
|
|
|
|
onAppInit: (@app) ->
|
|
|
|
onMsgReceived: (msg) ->
|
|
logger.debug("ChatStore.msgReceived", msg)
|
|
|
|
channelMsgs = @msgs[msg.channel]
|
|
|
|
if !channelMsgs?
|
|
channelMsgs = []
|
|
@msgs[msg.channel] = channelMsgs
|
|
|
|
channelMsgs.push(msg)
|
|
@changed()
|
|
|
|
onSendMsg: (msg) ->
|
|
logger.debug("ChatStore.sendMsg", msg)
|
|
|
|
window.JK.JamServer.sendChatMessage(msg)
|
|
|
|
changed: () ->
|
|
@trigger(msgs)
|
|
}
|
|
)
|