@@ -113,13 +113,42 @@ const createApplication = (core, proc) => {
113113 id,
114114 self : connection . jid ,
115115 title : username ,
116- user : from
116+ target : from
117117 } ) ;
118118 }
119119
120120 return chatWindow ;
121121 } ;
122122
123+ const findOrCreateMucWindow = name => {
124+ let chatWindow = findChatWindow ( name ) ;
125+ if ( ! chatWindow ) {
126+ const id = 'StropheJSChatWindow_' + name ;
127+
128+ chatWindow = createChatWindow ( core , proc , win , bus , {
129+ id,
130+ self : connection . jid ,
131+ title : name ,
132+ target : name ,
133+ muc : true
134+ } ) ;
135+ }
136+ } ;
137+
138+ const createJoinRoomDialog = ( ) => {
139+ core . make ( 'osjs/dialog' , 'prompt' , {
140+ title : 'Room name' ,
141+ message : 'Enter room name' ,
142+ parent : win ,
143+ value : `conference@${ proc . settings . username . split ( '@' ) [ 1 ] } `
144+ } , ( btn , value ) => {
145+ if ( btn === 'ok' && value ) {
146+ connection . muc . join ( value ) ;
147+ findOrCreateMucWindow ( value ) ;
148+ }
149+ } ) ;
150+ } ;
151+
123152 const onReceiveMessage = msg => {
124153 const from = msg . getAttribute ( 'from' ) ;
125154 const isTyping = msg . getElementsByTagName ( 'cha:composing' ) . length > 0 ;
@@ -166,6 +195,7 @@ const createApplication = (core, proc) => {
166195 }
167196 } ;
168197
198+ bus . on ( 'open-room-join-dialog' , ( ) => createJoinRoomDialog ( ) ) ;
169199 bus . on ( 'open-connection-window' , ( ) => createConnectionWindow ( core , proc , win , bus ) ) ;
170200 bus . on ( 'open-chat-window' , from => findOrCreateChatWindow ( from ) . focus ( ) ) ;
171201 bus . on ( 'send-message' , msg => connection . send ( msg ) ) ;
0 commit comments