Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
6c99c51c
Commit
6c99c51c
authored
Jun 03, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New API method `converse.rooms.close()`.
parent
f60a0512
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
155 additions
and
98 deletions
+155
-98
docs/CHANGES.md
docs/CHANGES.md
+1
-0
docs/source/development.rst
docs/source/development.rst
+6
-0
spec/chatroom.js
spec/chatroom.js
+131
-0
spec/converse.js
spec/converse.js
+0
-97
src/converse-muc.js
src/converse-muc.js
+17
-1
No files found.
docs/CHANGES.md
View file @
6c99c51c
...
...
@@ -10,6 +10,7 @@
-
Add processing hints to chat state notifications [jcbrand]
-
Don't use sound and desktop notifications for OTR messages (when setting up the session) [jcbrand]
-
New config option
[
default_state
](
https://conversejs.org/docs/html/configuration.html#default_state
)
[
jcbrand
]
-
New API method
`converse.rooms.close()`
-
#553 Add processing hints to OTR messages [jcbrand]
-
#650 Don't ignore incoming messages with same JID as current user (might be MAM archived) [jcbrand]
...
...
docs/source/development.rst
View file @
6c99c51c
...
...
@@ -678,6 +678,12 @@ To setup a custom nickname when joining the room, provide the optional nick argu
converse.rooms.open('group@muc.example.com', 'mycustomnick')
close
~~~~~
Lets you close open chat rooms. You can call this method without any arguments
to close all open chat rooms, or you can specify a single JID or an array of
JIDs.
The "settings" grouping
-----------------------
...
...
spec/chatroom.js
View file @
6c99c51c
...
...
@@ -23,6 +23,137 @@
});
});
describe
(
"
The
\"
rooms
\"
API
"
,
function
()
{
beforeEach
(
function
()
{
test_utils
.
closeAllChatBoxes
();
test_utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
test_utils
.
createContacts
(
'
current
'
);
});
it
(
"
has a method 'close' which closes rooms by JID or all rooms when called with no arguments
"
,
function
()
{
runs
(
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
'
leisure
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
'
news
'
,
'
localhost
'
,
'
dummy
'
);
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
100
'
);
runs
(
function
()
{
converse_api
.
rooms
.
close
(
'
lounge@localhost
'
);
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
converse_api
.
rooms
.
close
([
'
leisure@localhost
'
,
'
news@localhost
'
]);
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
news@localhost
'
)).
toBeUndefined
();
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
'
leisure
'
,
'
localhost
'
,
'
dummy
'
);
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
).
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
100
'
);
runs
(
function
()
{
converse_api
.
rooms
.
close
();
expect
(
converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
)).
toBeUndefined
();
expect
(
converse
.
chatboxviews
.
get
(
'
leisure@localhost
'
)).
toBeUndefined
();
});
});
it
(
"
has a method 'get' which returns a wrapped chat room (if it exists)
"
,
function
()
{
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
jid
=
'
lounge@localhost
'
;
var
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
// Test with mixed case
test_utils
.
openChatRoom
(
'
Leisure
'
,
'
localhost
'
,
'
dummy
'
);
var
jid
=
'
Leisure@localhost
'
;
var
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
var
jid
=
'
leisure@localhost
'
;
var
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leiSure@localhost
'
;
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
// Non-existing room
jid
=
'
lounge2@localhost
'
;
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
typeof
room
===
'
undefined
'
).
toBeTruthy
();
});
});
it
(
"
has a method 'open' which opens and returns a wrapped chat box
"
,
function
()
{
var
chatroomview
;
var
jid
=
'
lounge@localhost
'
;
var
room
=
converse_api
.
rooms
.
open
(
jid
);
runs
(
function
()
{
// Test on chat room that doesn't exist.
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
// Test again, now that the room exists.
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
// Test with mixed case in JID
jid
=
'
Leisure@localhost
'
;
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leisure@localhost
'
;
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leiSure@localhost
'
;
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
});
});
});
describe
(
"
A Chat Room
"
,
function
()
{
beforeEach
(
function
()
{
runs
(
function
()
{
...
...
spec/converse.js
View file @
6c99c51c
...
...
@@ -313,103 +313,6 @@
});
},
converse
));
describe
(
"
The
\"
rooms
\"
API
"
,
function
()
{
beforeEach
(
function
()
{
test_utils
.
closeAllChatBoxes
();
test_utils
.
clearBrowserStorage
();
converse
.
rosterview
.
model
.
reset
();
test_utils
.
createContacts
(
'
current
'
);
});
it
(
"
has a method 'get' which returns a wrapped chat room (if it exists)
"
,
function
()
{
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
jid
=
'
lounge@localhost
'
;
var
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
// Test with mixed case
test_utils
.
openChatRoom
(
'
Leisure
'
,
'
localhost
'
,
'
dummy
'
);
var
jid
=
'
Leisure@localhost
'
;
var
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
var
jid
=
'
leisure@localhost
'
;
var
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
var
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leiSure@localhost
'
;
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
// Non-existing room
jid
=
'
lounge2@localhost
'
;
room
=
converse_api
.
rooms
.
get
(
jid
);
expect
(
typeof
room
===
'
undefined
'
).
toBeTruthy
();
});
});
it
(
"
has a method 'open' which opens and returns a wrapped chat box
"
,
function
()
{
var
chatroomview
;
var
jid
=
'
lounge@localhost
'
;
var
room
=
converse_api
.
rooms
.
open
(
jid
);
runs
(
function
()
{
// Test on chat room that doesn't exist.
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
// Test again, now that the room exists.
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
expect
(
room
.
is_chatroom
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
);
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
});
waits
(
'
300
'
);
// ChatBox.show() is debounced for 250ms
runs
(
function
()
{
// Test with mixed case in JID
jid
=
'
Leisure@localhost
'
;
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leisure@localhost
'
;
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
jid
=
'
leiSure@localhost
'
;
room
=
converse_api
.
rooms
.
open
(
jid
);
expect
(
room
instanceof
Object
).
toBeTruthy
();
chatroomview
=
converse
.
chatboxviews
.
get
(
jid
.
toLowerCase
());
expect
(
chatroomview
.
$el
.
is
(
'
:visible
'
)).
toBeTruthy
();
chatroomview
.
close
();
});
});
});
describe
(
"
The
\"
settings
\"
API
"
,
$
.
proxy
(
function
()
{
beforeEach
(
$
.
proxy
(
function
()
{
test_utils
.
closeAllChatBoxes
();
...
...
src/converse-muc.js
View file @
6c99c51c
...
...
@@ -1363,6 +1363,23 @@
*/
_
.
extend
(
converse_api
,
{
'
rooms
'
:
{
'
close
'
:
function
(
jids
)
{
if
(
typeof
jids
===
"
undefined
"
)
{
converse
.
chatboxviews
.
each
(
function
(
view
)
{
if
(
view
.
is_chatroom
&&
view
.
model
)
{
view
.
close
();
}
});
}
else
if
(
typeof
jids
===
"
string
"
)
{
var
view
=
converse
.
chatboxviews
.
get
(
jids
);
if
(
view
)
{
view
.
close
();
}
}
else
{
_
.
map
(
jids
,
function
(
jid
)
{
var
view
=
converse
.
chatboxviews
.
get
(
jid
);
if
(
view
)
{
view
.
close
();
}
});
}
},
'
open
'
:
function
(
jids
,
nick
)
{
if
(
!
nick
)
{
nick
=
Strophe
.
getNodeFromJid
(
converse
.
bare_jid
);
...
...
@@ -1373,7 +1390,6 @@
var
_transform
=
function
(
jid
)
{
jid
=
jid
.
toLowerCase
();
var
chatroom
=
converse
.
chatboxes
.
get
(
jid
);
converse
.
log
(
'
jid
'
);
if
(
!
chatroom
)
{
chatroom
=
converse
.
chatboxviews
.
showChat
({
'
id
'
:
jid
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment