@@ -67,7 +67,7 @@ export const createChatWindow = (core, proc, parent, bus, options) => {
67
67
const messages = ( state , actions ) => state . messages . map ( ( { date, msg} ) => {
68
68
return h ( ChatMessage , {
69
69
date : format ( date , 'longTime' ) ,
70
- self : getUsername ( msg . getAttribute ( 'from' ) ) !== getUsername ( options . user ) ,
70
+ self : getUsername ( msg . getAttribute ( 'from' ) ) !== getUsername ( options . target ) ,
71
71
to : msg . getAttribute ( 'to' ) ,
72
72
from : msg . getAttribute ( 'from' ) ,
73
73
type : msg . getAttribute ( 'type' ) ,
@@ -127,20 +127,19 @@ export const createChatWindow = (core, proc, parent, bus, options) => {
127
127
}
128
128
129
129
const msg = createMessage ( options . self , options . target , value ) ;
130
-
131
- actions . sendMessage ( msg ) ;
130
+ actions . sendMessage ( options . muc ? value : msg ) ;
132
131
actions . addMessage ( { date : new Date ( ) , msg} ) ;
133
132
134
133
setTimeout ( ( ) => ( textarea . value = '' ) , 1 ) ;
135
134
} ,
136
135
setTypeStatus : typing => ( ) => ( { typing} ) ,
137
- sendMessage : msg => ( ) => bus . emit ( 'send-message' , msg ) ,
136
+ sendMessage : msg => ( ) => bus . emit ( 'send-message' , msg , options . target , options . muc ) ,
138
137
addMessage : obj => state => ( { messages : [ ...state . messages , obj ] } )
139
138
} , view , $content ) ;
140
139
141
140
let typeStatusTimeout ;
142
141
143
- win . on ( 'strophejs/message' , msg => {
142
+ const addMessage = msg => {
144
143
a . addMessage ( { date : new Date ( ) , msg} ) ;
145
144
146
145
const container = $content . querySelector ( '.chat-messages' ) ;
@@ -149,7 +148,21 @@ export const createChatWindow = (core, proc, parent, bus, options) => {
149
148
container . scrollTop = container . scrollHeight ;
150
149
} , 1 ) ;
151
150
}
151
+ } ;
152
+
153
+ if ( options . muc ) {
154
+ win . on ( 'destroy' , ( ) => bus . emit ( 'leave-room' , options . target ) ) ;
155
+ }
156
+
157
+ win . on ( 'strophejs/room:message' , addMessage ) ;
158
+ win . on ( 'strophejs/room:presence' , ( ...args ) => {
159
+ console . warn ( 'TODO' , 'strophejs/room:presence' , args ) ;
152
160
} ) ;
161
+ win . on ( 'strophejs/room:roster' , ( ...args ) => {
162
+ console . warn ( 'TODO' , 'strophejs/room:roster' , args ) ;
163
+ } ) ;
164
+
165
+ win . on ( 'strophejs/message' , addMessage ) ;
153
166
154
167
win . on ( 'strophejs/started-typing' , ( ) => {
155
168
clearTimeout ( typeStatusTimeout ) ;
0 commit comments