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
f8977035
Commit
f8977035
authored
Mar 29, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `emit` to `trigger` for consistency with Backbone.Events
parent
f6335dca
Changes
36
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
318 additions
and
292 deletions
+318
-292
docs/source/developer_api.rst
docs/source/developer_api.rst
+2
-2
docs/source/plugin_development.rst
docs/source/plugin_development.rst
+1
-1
spec/bookmarks.js
spec/bookmarks.js
+2
-2
spec/chatbox.js
spec/chatbox.js
+37
-37
spec/controlbox.js
spec/controlbox.js
+8
-8
spec/converse.js
spec/converse.js
+2
-2
spec/disco.js
spec/disco.js
+4
-4
spec/eventemitter.js
spec/eventemitter.js
+9
-9
spec/http-file-upload.js
spec/http-file-upload.js
+4
-4
spec/messages.js
spec/messages.js
+31
-31
spec/minchats.js
spec/minchats.js
+3
-3
spec/muc.js
spec/muc.js
+15
-15
spec/notification.js
spec/notification.js
+1
-1
spec/omemo.js
spec/omemo.js
+7
-7
spec/ping.js
spec/ping.js
+2
-2
spec/protocol.js
spec/protocol.js
+2
-2
spec/roster.js
spec/roster.js
+3
-3
spec/user-details-modal.js
spec/user-details-modal.js
+2
-2
src/converse-bookmarks.js
src/converse-bookmarks.js
+1
-1
src/converse-chatboxviews.js
src/converse-chatboxviews.js
+1
-1
src/converse-chatview.js
src/converse-chatview.js
+12
-12
src/converse-controlbox.js
src/converse-controlbox.js
+4
-4
src/converse-headline.js
src/converse-headline.js
+3
-3
src/converse-minimize.js
src/converse-minimize.js
+4
-4
src/converse-muc-views.js
src/converse-muc-views.js
+2
-2
src/converse-notification.js
src/converse-notification.js
+1
-1
src/converse-omemo.js
src/converse-omemo.js
+1
-1
src/converse-profile.js
src/converse-profile.js
+1
-1
src/converse-roomslist.js
src/converse-roomslist.js
+1
-1
src/converse-rosterview.js
src/converse-rosterview.js
+1
-1
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+4
-4
src/headless/converse-core.js
src/headless/converse-core.js
+53
-38
src/headless/converse-disco.js
src/headless/converse-disco.js
+5
-5
src/headless/converse-muc.js
src/headless/converse-muc.js
+4
-4
src/headless/converse-roster.js
src/headless/converse-roster.js
+11
-11
src/headless/dist/converse-headless.js
src/headless/dist/converse-headless.js
+74
-63
No files found.
docs/source/developer_api.rst
View file @
f8977035
...
...
@@ -141,7 +141,7 @@ For example:
.. code-block:: javascript
_converse.api.
emit
('foo-completed');
_converse.api.
trigger
('foo-completed');
Additionally, if a promise has been registered under the same name
(via ``_converse.api.promises.add``), then that promise will also be resolved
...
...
@@ -1152,7 +1152,7 @@ For example:
.. code-block:: javascript
_converse.api.
emit
('foo-completed');
_converse.api.
trigger
('foo-completed');
The **settings** grouping
...
...
docs/source/plugin_development.rst
View file @
f8977035
...
...
@@ -446,7 +446,7 @@ generated by `generator-conversejs <https://github.com/jcbrand/generator-convers
* emit an event with the same name as the promise.
* For example:
*
* _converse.api.
emit
('operationCompleted');
* _converse.api.
trigger
('operationCompleted');
*
* Other plugins can then either listen for the event
* `operationCompleted` like so:
...
...
spec/bookmarks.js
View file @
f8977035
...
...
@@ -330,7 +330,7 @@
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
bookmarks
);
// Emit here instead of mocking fetching of bookmarks.
_converse
.
emit
(
'
bookmarksInitialized
'
);
_converse
.
api
.
trigger
(
'
bookmarksInitialized
'
);
/* The stored data is automatically pushed to all of the user's
* connected resources.
...
...
@@ -638,7 +638,7 @@
_converse
.
bookmarksview
=
new
_converse
.
BookmarksView
(
{
'
model
'
:
_converse
.
bookmarks
}
);
_converse
.
emit
(
'
bookmarksInitialized
'
);
_converse
.
api
.
trigger
(
'
bookmarksInitialized
'
);
// Check that it's there
_converse
.
bookmarks
.
create
({
...
...
spec/chatbox.js
View file @
f8977035
This diff is collapsed.
Click to expand it.
spec/controlbox.js
View file @
f8977035
...
...
@@ -23,13 +23,13 @@
expect
(
u
.
isVisible
(
el
)).
toBe
(
false
);
spyOn
(
_converse
.
controlboxtoggle
,
'
onClick
'
).
and
.
callThrough
();
spyOn
(
_converse
.
controlboxtoggle
,
'
showControlBox
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
// Redelegate so that the spies are now registered as the event handlers (specifically for 'onClick')
_converse
.
controlboxtoggle
.
delegateEvents
();
document
.
querySelector
(
'
.toggle-controlbox
'
).
click
();
expect
(
_converse
.
controlboxtoggle
.
onClick
).
toHaveBeenCalled
();
expect
(
_converse
.
controlboxtoggle
.
showControlBox
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
controlBoxOpened
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
controlBoxOpened
'
,
jasmine
.
any
(
Object
));
el
=
document
.
querySelector
(
"
div#controlbox
"
);
expect
(
u
.
isVisible
(
el
)).
toBe
(
true
);
done
();
...
...
@@ -42,7 +42,7 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
test_utils
.
openControlBox
();
// Adding two contacts one with Capital initials and one with small initials of same JID (Case sensitive check)
...
...
@@ -71,7 +71,7 @@
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
all
'
).
openControlBox
();
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
...
...
@@ -140,11 +140,11 @@
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
const
view
=
_converse
.
xmppstatusview
;
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
modal
.
el
.
querySelector
(
'
label[for="radio-busy"]
'
).
click
();
// Change status to "dnd"
modal
.
el
.
querySelector
(
'
[type="submit"]
'
).
click
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
statusChanged
'
,
'
dnd
'
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
statusChanged
'
,
'
dnd
'
);
const
first_child
=
view
.
el
.
querySelector
(
'
.xmpp-status span:first-child
'
);
expect
(
u
.
hasClass
(
'
online
'
,
first_child
)).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
dnd
'
,
first_child
)).
toBe
(
true
);
...
...
@@ -165,13 +165,13 @@
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
const
view
=
_converse
.
xmppstatusview
;
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
msg
=
'
I am happy
'
;
modal
.
el
.
querySelector
(
'
input[name="status_message"]
'
).
value
=
msg
;
modal
.
el
.
querySelector
(
'
[type="submit"]
'
).
click
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
statusMessageChanged
'
,
msg
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
statusMessageChanged
'
,
msg
);
const
first_child
=
view
.
el
.
querySelector
(
'
.xmpp-status span:first-child
'
);
expect
(
u
.
hasClass
(
'
online
'
,
first_child
)).
toBe
(
true
);
expect
(
view
.
el
.
querySelector
(
'
.xmpp-status span:first-child
'
).
textContent
.
trim
()).
toBe
(
msg
);
...
...
spec/converse.js
View file @
f8977035
...
...
@@ -288,7 +288,7 @@
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
...
...
@@ -325,7 +325,7 @@
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
spec/disco.js
View file @
f8977035
...
...
@@ -187,11 +187,11 @@
null
,
[
'
discoInitialized
'
],
{},
function
(
done
,
_converse
)
{
sinon
.
spy
(
_converse
,
'
emit
'
);
sinon
.
spy
(
_converse
.
api
,
"
trigger
"
);
_converse
.
disco_entities
.
get
(
_converse
.
domain
).
features
.
create
({
'
var
'
:
Strophe
.
NS
.
MAM
});
expect
(
_converse
.
emit
.
called
).
toBe
(
true
);
expect
(
_converse
.
emit
.
args
[
0
][
0
]).
toBe
(
'
serviceDiscovered
'
);
expect
(
_converse
.
emit
.
args
[
0
][
1
].
get
(
'
var
'
)).
toBe
(
Strophe
.
NS
.
MAM
);
expect
(
_converse
.
api
.
trigger
.
called
).
toBe
(
true
);
expect
(
_converse
.
api
.
trigger
.
args
[
0
][
0
]).
toBe
(
'
serviceDiscovered
'
);
expect
(
_converse
.
api
.
trigger
.
args
[
0
][
1
].
get
(
'
var
'
)).
toBe
(
Strophe
.
NS
.
MAM
);
done
();
}));
});
...
...
spec/eventemitter.js
View file @
f8977035
...
...
@@ -8,11 +8,11 @@
this
.
callback
=
function
()
{};
spyOn
(
this
,
'
callback
'
);
_converse
.
on
(
'
connected
'
,
this
.
callback
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
).
toHaveBeenCalled
();
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
.
calls
.
count
(),
2
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
.
calls
.
count
(),
3
);
done
();
}));
...
...
@@ -21,11 +21,11 @@
this
.
callback
=
function
()
{};
spyOn
(
this
,
'
callback
'
);
_converse
.
once
(
'
connected
'
,
this
.
callback
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
).
toHaveBeenCalled
();
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
.
calls
.
count
(),
1
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
.
calls
.
count
(),
1
);
done
();
}));
...
...
@@ -41,20 +41,20 @@
_converse
.
on
(
'
connected
'
,
this
.
callback
);
_converse
.
on
(
'
connected
'
,
this
.
anotherCallback
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
).
toHaveBeenCalled
();
expect
(
this
.
anotherCallback
).
toHaveBeenCalled
();
_converse
.
off
(
'
connected
'
,
this
.
callback
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
.
calls
.
count
(),
1
);
expect
(
this
.
anotherCallback
.
calls
.
count
(),
2
);
_converse
.
once
(
'
connected
'
,
this
.
neverCalled
);
_converse
.
off
(
'
connected
'
,
this
.
neverCalled
);
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
this
.
callback
.
calls
.
count
(),
1
);
expect
(
this
.
anotherCallback
.
calls
.
count
(),
3
);
expect
(
this
.
neverCalled
).
not
.
toHaveBeenCalled
();
...
...
spec/http-file-upload.js
View file @
f8977035
...
...
@@ -221,7 +221,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.localhost
'
],
'
items
'
)
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.localhost
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
3
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -263,7 +263,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.montague.tld
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
...
@@ -555,7 +555,7 @@
expect
(
entities
.
get
(
'
localhost
'
).
items
.
get
(
'
upload.localhost
'
).
identities
.
where
({
'
category
'
:
'
store
'
}).
length
).
toBe
(
1
);
const
result
=
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
...
@@ -594,7 +594,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.montague.tld
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
...
spec/messages.js
View file @
f8977035
This diff is collapsed.
Click to expand it.
spec/minchats.js
View file @
f8977035
...
...
@@ -14,7 +14,7 @@
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
test_utils
.
openControlBox
();
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
...
...
@@ -53,7 +53,7 @@
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
test_utils
.
openControlBox
();
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
...
...
@@ -84,7 +84,7 @@
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
test_utils
.
openControlBox
();
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
...
...
spec/muc.js
View file @
f8977035
...
...
@@ -1718,7 +1718,7 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// We need roster contacts, so that we have someone to invite
// Since we don't actually fetch roster contacts, we need to
// cheat here and emit the event.
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
features
=
[
'
http://jabber.org/protocol/muc
'
,
...
...
@@ -1731,7 +1731,7 @@
'
muc_anonymous
'
]
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
,
features
);
spyOn
(
_converse
,
'
emit
'
).
and
.
callThrough
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
spyOn
(
window
,
'
prompt
'
).
and
.
callFake
(()
=>
"
Please join!
"
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
const
chat_area
=
view
.
el
.
querySelector
(
'
.chat-area
'
);
...
...
@@ -1819,7 +1819,7 @@
const
text
=
'
This is a received message
'
;
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
...
...
@@ -1841,7 +1841,7 @@
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg__text
'
).
textContent
).
toBe
(
text
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
done
();
}));
...
...
@@ -1851,7 +1851,7 @@
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
...
...
@@ -1866,7 +1866,7 @@
});
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
messageSend
'
,
text
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
messageSend
'
,
text
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
...
...
@@ -1888,7 +1888,7 @@
expect
(
sizzle
(
'
.chat-msg__text:last
'
).
pop
().
textContent
).
toBe
(
text
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
// We don't emit an event if it's our own message
expect
(
_converse
.
emit
.
calls
.
count
(),
1
);
expect
(
_converse
.
api
.
trigger
.
calls
.
count
(),
1
);
done
();
}));
...
...
@@ -2505,12 +2505,12 @@
spyOn
(
view
,
'
minimize
'
).
and
.
callThrough
();
spyOn
(
view
,
'
maximize
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
el
.
querySelector
(
'
.toggle-chatbox-button
'
).
click
();
expect
(
view
.
minimize
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
u
.
isVisible
(
view
.
el
)).
toBeFalsy
();
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
expect
(
view
.
minimize
).
toHaveBeenCalled
();
...
...
@@ -2518,9 +2518,9 @@
const
trimmedview
=
trimmed_chatboxes
.
get
(
view
.
model
.
get
(
'
id
'
));
trimmedview
.
el
.
querySelector
(
"
a.restore-chat
"
).
click
();
expect
(
view
.
maximize
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
expect
(
_converse
.
emit
.
calls
.
count
(),
3
);
expect
(
_converse
.
api
.
trigger
.
calls
.
count
(),
3
);
done
();
}));
...
...
@@ -2533,13 +2533,13 @@
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
close
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
view
.
model
,
'
leave
'
);
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
el
.
querySelector
(
'
.close-chatbox-button
'
).
click
();
expect
(
view
.
close
).
toHaveBeenCalled
();
expect
(
view
.
model
.
leave
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
done
();
}));
});
...
...
@@ -3422,12 +3422,12 @@
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
'
to
'
:
_converse
.
connection
.
jid
});
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
2
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result_stanza
));
await
test_utils
.
waitUntil
(()
=>
(
view
.
model
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
DISCONNECTED
));
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
done
();
}));
});
...
...
spec/notification.js
View file @
f8977035
...
...
@@ -156,7 +156,7 @@
it
(
"
an HTML5 Notification is received
"
,
mock
.
initConverse
((
done
,
_converse
)
=>
{
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
spyOn
(
_converse
,
'
showContactRequestNotification
'
);
_converse
.
emit
(
'
contactRequest
'
,
{
'
fullname
'
:
'
Peter Parker
'
,
'
jid
'
:
'
peter@parker.com
'
});
_converse
.
api
.
trigger
(
'
contactRequest
'
,
{
'
fullname
'
:
'
Peter Parker
'
,
'
jid
'
:
'
peter@parker.com
'
});
expect
(
_converse
.
areDesktopNotificationsEnabled
).
toHaveBeenCalled
();
expect
(
_converse
.
showContactRequestNotification
).
toHaveBeenCalled
();
done
();
...
...
spec/omemo.js
View file @
f8977035
...
...
@@ -82,7 +82,7 @@
const
message
=
'
This message will be encrypted
'
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
payload
=
await
view
.
model
.
encryptMessage
(
message
);
...
...
@@ -99,7 +99,7 @@
let
sent_stanza
;
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
...
@@ -513,7 +513,7 @@
_converse
.
NUM_PREKEYS
=
5
;
// Restrict to 5, otherwise the resulting stanza is too large to easily test
let
view
,
sent_stanza
;
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
...
...
@@ -934,7 +934,7 @@
_converse
.
NUM_PREKEYS
=
2
;
// Restrict to 2, otherwise the resulting stanza is too large to easily test
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
stanza
=
$iq
({
...
...
@@ -1011,7 +1011,7 @@
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
...
...
@@ -1358,11 +1358,11 @@
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
// We simply emit, to avoid doing all the setup work
_converse
.
emit
(
'
OMEMOInitialized
'
);
_converse
.
api
.
trigger
(
'
OMEMOInitialized
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
...
...
spec/ping.js
View file @
f8977035
...
...
@@ -13,7 +13,7 @@
spyOn
(
_converse
,
'
registerPingHandler
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
registerPongHandler
'
).
and
.
callThrough
();
_converse
.
emit
(
'
connected
'
);
_converse
.
api
.
trigger
(
'
connected
'
);
expect
(
_converse
.
registerPingHandler
).
toHaveBeenCalled
();
expect
(
_converse
.
registerPongHandler
).
toHaveBeenCalled
();
done
();
...
...
@@ -26,7 +26,7 @@
spyOn
(
_converse
,
'
registerPingHandler
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
registerPongHandler
'
).
and
.
callThrough
();
_converse
.
emit
(
'
reconnected
'
);
_converse
.
api
.
trigger
(
'
reconnected
'
);
expect
(
_converse
.
registerPingHandler
).
toHaveBeenCalled
();
expect
(
_converse
.
registerPongHandler
).
toHaveBeenCalled
();
done
();
...
...
spec/protocol.js
View file @
f8977035
...
...
@@ -517,7 +517,7 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
spyOn
(
_converse
,
"
emit
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
test_utils
.
openControlBox
(
_converse
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Create some contacts so that we can test positioning
/* <presence
...
...
@@ -538,7 +538,7 @@
var
$contacts
=
$header
.
parent
().
find
(
'
li:visible
'
);
return
$contacts
.
length
;
},
600
).
then
(
function
()
{
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
contactRequest
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
contactRequest
'
,
jasmine
.
any
(
Object
));
var
$header
=
$
(
'
a:contains("Contact requests")
'
);
expect
(
$header
.
length
).
toBe
(
1
);
expect
(
$header
.
is
(
"
:visible
"
)).
toBeTruthy
();
...
...
spec/roster.js
View file @
f8977035
...
...
@@ -36,10 +36,10 @@
async
function
(
done
,
_converse
)
{
const
IQs
=
_converse
.
connection
.
IQ_stanzas
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterGroupsFetched
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterGroupsFetched
'
));
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
());
expect
(
_converse
.
emit
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
)).
toBeFalsy
();
expect
(
_converse
.
api
.
trigger
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
)).
toBeFalsy
();
expect
(
node
.
toLocaleString
()).
toBe
(
`<iq id="
${
node
.
nodeTree
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
...
...
@@ -54,7 +54,7 @@
}).
c
(
'
item
'
,
{
'
jid
'
:
'
nurse@example.com
'
}).
up
()
.
c
(
'
item
'
,
{
'
jid
'
:
'
romeo@example.com
'
})
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
));
done
();
}));
...
...
spec/user-details-modal.js
View file @
f8977035
...
...
@@ -20,7 +20,7 @@
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
...
@@ -54,7 +54,7 @@
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
...
...
src/converse-bookmarks.js
View file @
f8977035
...
...
@@ -555,7 +555,7 @@ converse.plugins.add('converse-bookmarks', {
* @event _converse#bookmarksInitialized
* @example _converse.api.listen.on('bookmarksInitialized', () => { ... });
*/
_converse
.
api
.
emit
(
'
bookmarksInitialized
'
);
_converse
.
api
.
trigger
(
'
bookmarksInitialized
'
);
}
_converse
.
api
.
listen
.
on
(
'
clearSession
'
,
()
=>
{
...
...
src/converse-chatboxviews.js
View file @
f8977035
...
...
@@ -173,7 +173,7 @@ converse.plugins.add('converse-chatboxviews', {
* @event _converse#chatBoxViewsInitialized
* @example _converse.api.listen.on('chatBoxViewsInitialized', () => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxViewsInitialized
'
);
_converse
.
api
.
trigger
(
'
chatBoxViewsInitialized
'
);
});
_converse
.
api
.
listen
.
on
(
'
clearSession
'
,
()
=>
_converse
.
chatboxviews
.
closeAllChatBoxes
());
...
...
src/converse-chatview.js
View file @
f8977035
...
...
@@ -188,7 +188,7 @@ converse.plugins.add('converse-chatview', {
* @property { string } message - The message text
* @example _converse.api.listen.on('contactStatusMessageChanged', obj => { ... });
*/
_converse
.
api
.
emit
(
'
contactStatusMessageChanged
'
,
{
_converse
.
api
.
trigger
(
'
contactStatusMessageChanged
'
,
{
'
contact
'
:
item
.
attributes
,
'
message
'
:
item
.
get
(
'
status
'
)
});
...
...
@@ -215,7 +215,7 @@ converse.plugins.add('converse-chatview', {
* @type { _converse.ChatBox }
* @example _converse.api.listen.on('userDetailsModalInitialized', chatbox => { ... });
*/
_converse
.
api
.
emit
(
'
userDetailsModalInitialized
'
,
this
.
model
);
_converse
.
api
.
trigger
(
'
userDetailsModalInitialized
'
,
this
.
model
);
},
toHTML
()
{
...
...
@@ -336,14 +336,14 @@ converse.plugins.add('converse-chatview', {
this
.
render
();
this
.
fetchMessages
();
_converse
.
api
.
emit
(
'
chatBoxOpened
'
,
this
);
// TODO: remove
_converse
.
api
.
trigger
(
'
chatBoxOpened
'
,
this
);
// TODO: remove
/**
* Triggered once the _converse.ChatBoxView has been initialized
* @event _converse#chatBoxInitialized
* @type { _converse.ChatBoxView | _converse.HeadlinesBoxView }
* @example _converse.api.listen.on('chatBoxInitialized', view => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxInitialized
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxInitialized
'
,
this
);
},
initDebounced
()
{
...
...
@@ -384,7 +384,7 @@ converse.plugins.add('converse-chatview', {
* @type { _converse.ChatBoxView }
* @example _converse.api.listen.on('renderToolbar', view => { ... });
*/
_converse
.
api
.
emit
(
'
renderToolbar
'
,
this
);
_converse
.
api
.
trigger
(
'
renderToolbar
'
,
this
);
return
this
;
},
...
...
@@ -525,7 +525,7 @@ converse.plugins.add('converse-chatview', {
* @type {_converse.ChatBoxView | _converse.ChatRoomView}
* @example _converse.api.listen.on('afterMessagesFetched', view => { ... });
*/
_converse
.
api
.
emit
(
'
afterMessagesFetched
'
,
this
);
_converse
.
api
.
trigger
(
'
afterMessagesFetched
'
,
this
);
},
fetchMessages
()
{
...
...
@@ -840,7 +840,7 @@ converse.plugins.add('converse-chatview', {
* @property { _converse.ChatBox | _converse.ChatRoom } chatbox - The chat model
* @example _converse.api.listen.on('messageAdded', data => { ... });
*/
_converse
.
api
.
emit
(
'
messageAdded
'
,
{
_converse
.
api
.
trigger
(
'
messageAdded
'
,
{
'
message
'
:
message
,
'
chatbox
'
:
this
.
model
});
...
...
@@ -932,7 +932,7 @@ converse.plugins.add('converse-chatview', {
* @type { _converse.Message }
* @example _converse.api.listen.on('messageSend', data => { ... });
*/
_converse
.
api
.
emit
(
'
messageSend
'
,
message
);
_converse
.
api
.
trigger
(
'
messageSend
'
,
message
);
}
textarea
.
removeAttribute
(
'
disabled
'
);
u
.
removeClass
(
'
disabled
'
,
textarea
);
...
...
@@ -1143,7 +1143,7 @@ converse.plugins.add('converse-chatview', {
* @property { _converse.ChatBox | _converse.ChatRoom } _converse.connection - The XMPP Connection object
* @example _converse.api.listen.on('callButtonClicked', (connection, model) => { ... });
*/
_converse
.
api
.
emit
(
'
callButtonClicked
'
,
{
_converse
.
api
.
trigger
(
'
callButtonClicked
'
,
{
connection
:
_converse
.
connection
,
model
:
this
.
model
});
...
...
@@ -1230,7 +1230,7 @@ converse.plugins.add('converse-chatview', {
* @type { _converse.ChatBoxView | _converse.ChatRoomView }
* @example _converse.api.listen.on('chatBoxClosed', view => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxClosed
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxClosed
'
,
this
);
return
this
;
},
...
...
@@ -1256,7 +1256,7 @@ converse.plugins.add('converse-chatview', {
* @type { _converse.ChatBoxView | _converse.ChatRoomView }
* @example _converse.api.listen.on('chatBoxFocused', view => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxFocused
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxFocused
'
,
this
);
}
return
this
;
},
...
...
@@ -1346,7 +1346,7 @@ converse.plugins.add('converse-chatview', {
* @property { _converse.ChatBox | _converse.ChatRoom } chatbox - The chat model
* @example _converse.api.listen.on('chatBoxScrolledDown', obj => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxScrolledDown
'
,
{
'
chatbox
'
:
this
.
model
});
// TODO: clean up
_converse
.
api
.
trigger
(
'
chatBoxScrolledDown
'
,
{
'
chatbox
'
:
this
.
model
});
// TODO: clean up
},
onWindowStateChanged
(
state
)
{
...
...
src/converse-controlbox.js
View file @
f8977035
...
...
@@ -232,7 +232,7 @@ converse.plugins.add('converse-controlbox', {
* @type { _converse.ControlBoxView }
* @example _converse.api.listen.on('controlboxInitialized', view => { ... });
*/
_converse
.
api
.
emit
(
'
controlboxInitialized
'
,
this
);
_converse
.
api
.
trigger
(
'
controlboxInitialized
'
,
this
);
},
render
()
{
...
...
@@ -339,7 +339,7 @@ converse.plugins.add('converse-controlbox', {
}
else
{
this
.
model
.
trigger
(
'
hide
'
);
}
_converse
.
api
.
emit
(
'
controlBoxClosed
'
,
this
);
_converse
.
api
.
trigger
(
'
controlBoxClosed
'
,
this
);
return
this
;
},
...
...
@@ -356,7 +356,7 @@ converse.plugins.add('converse-controlbox', {
return
;
}
u
.
addClass
(
'
hidden
'
,
this
.
el
);
_converse
.
api
.
emit
(
'
chatBoxClosed
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxClosed
'
,
this
);
if
(
!
_converse
.
connection
.
connected
)
{
_converse
.
controlboxtoggle
.
render
();
}
...
...
@@ -367,7 +367,7 @@ converse.plugins.add('converse-controlbox', {
onControlBoxToggleHidden
()
{
this
.
model
.
set
(
'
closed
'
,
false
);
this
.
el
.
classList
.
remove
(
'
hidden
'
);
_converse
.
api
.
emit
(
'
controlBoxOpened
'
,
this
);
_converse
.
api
.
trigger
(
'
controlBoxOpened
'
,
this
);
},
show
()
{
...
...
src/converse-headline.js
View file @
f8977035
...
...
@@ -81,8 +81,8 @@ converse.plugins.add('converse-headline', {
this
.
model
.
on
(
'
change:minimized
'
,
this
.
onMinimizedChanged
,
this
);
this
.
render
().
insertHeading
().
fetchMessages
().
insertIntoDOM
().
hide
();
_converse
.
api
.
emit
(
'
chatBoxOpened
'
,
this
);
// TODO: remove
_converse
.
api
.
emit
(
'
chatBoxInitialized
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxOpened
'
,
this
);
// TODO: remove
_converse
.
api
.
trigger
(
'
chatBoxInitialized
'
,
this
);
},
render
()
{
...
...
@@ -127,7 +127,7 @@ converse.plugins.add('converse-headline', {
});
const
attrs
=
await
chatbox
.
getMessageAttributesFromStanza
(
message
,
message
);
await
chatbox
.
messages
.
create
(
attrs
);
_converse
.
api
.
emit
(
'
message
'
,
{
'
chatbox
'
:
chatbox
,
'
stanza
'
:
message
});
_converse
.
api
.
trigger
(
'
message
'
,
{
'
chatbox
'
:
chatbox
,
'
stanza
'
:
message
});
}
}
...
...
src/converse-minimize.js
View file @
f8977035
...
...
@@ -137,7 +137,7 @@ converse.plugins.add('converse-minimize', {
* @type { _converse.ChatBoxView }
* @example _converse.api.listen.on('chatBoxMaximized', view => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxMaximized
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxMaximized
'
,
this
);
return
this
;
},
...
...
@@ -158,7 +158,7 @@ converse.plugins.add('converse-minimize', {
* @type { _converse.ChatBoxView }
* @example _converse.api.listen.on('chatBoxMinimized', view => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxMinimized
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxMinimized
'
,
this
);
},
},
...
...
@@ -370,7 +370,7 @@ converse.plugins.add('converse-minimize', {
view
.
close
();
}
else
{
this
.
model
.
destroy
();
_converse
.
api
.
emit
(
'
chatBoxClosed
'
,
this
);
_converse
.
api
.
trigger
(
'
chatBoxClosed
'
,
this
);
}
return
this
;
},
...
...
@@ -405,7 +405,7 @@ converse.plugins.add('converse-minimize', {
* @event _converse#minimizedChatsInitialized
* @example _converse.api.listen.on('minimizedChatsInitialized', () => { ... });
*/
_converse
.
api
.
emit
(
'
minimizedChatsInitialized
'
);
_converse
.
api
.
trigger
(
'
minimizedChatsInitialized
'
);
},
render
()
{
...
...
src/converse-muc-views.js
View file @
f8977035
...
...
@@ -82,7 +82,7 @@ converse.plugins.add('converse-muc-views', {
* @event _converse#roomsPanelRendered
* @example _converse.api.listen.on('roomsPanelRendered', () => { ... });
*/
_converse
.
api
.
emit
(
'
roomsPanelRendered
'
);
_converse
.
api
.
trigger
(
'
roomsPanelRendered
'
);
},
renderControlBoxPane
()
{
...
...
@@ -580,7 +580,7 @@ converse.plugins.add('converse-muc-views', {
* @type { _converse.ChatRoomView }
* @example _converse.api.listen.on('chatRoomOpened', view => { ... });
*/
_converse
.
api
.
emit
(
'
chatRoomOpened
'
,
this
);
_converse
.
api
.
trigger
(
'
chatRoomOpened
'
,
this
);
},
render
()
{
...
...
src/converse-notification.js
View file @
f8977035
...
...
@@ -267,7 +267,7 @@ converse.plugins.add('converse-notification', {
* @type { XMLElement }
* @example _converse.api.listen.on('messageNotification', stanza => { ... });
*/
_converse
.
api
.
emit
(
'
messageNotification
'
,
message
);
_converse
.
api
.
trigger
(
'
messageNotification
'
,
message
);
_converse
.
playSoundNotification
();
_converse
.
showMessageNotification
(
message
);
};
...
...
src/converse-omemo.js
View file @
f8977035
...
...
@@ -1137,7 +1137,7 @@ converse.plugins.add('converse-omemo', {
* @event _converse#OMEMOInitialized
* @example _converse.api.listen.on('OMEMOInitialized', () => { ... });
*/
_converse
.
api
.
emit
(
'
OMEMOInitialized
'
);
_converse
.
api
.
trigger
(
'
OMEMOInitialized
'
);
}
async
function
onOccupantAdded
(
chatroom
,
occupant
)
{
...
...
src/converse-profile.js
View file @
f8977035
...
...
@@ -54,7 +54,7 @@ converse.plugins.add('converse-profile', {
* @type { _converse.XMPPStatus }
* @example _converse.api.listen.on('profileModalInitialized', status => { ... });
*/
_converse
.
api
.
emit
(
'
profileModalInitialized
'
,
this
.
model
);
_converse
.
api
.
trigger
(
'
profileModalInitialized
'
,
this
.
model
);
},
toHTML
()
{
...
...
src/converse-roomslist.js
View file @
f8977035
...
...
@@ -182,7 +182,7 @@ converse.plugins.add('converse-roomslist', {
* @event _converse#roomsListInitialized
* @example _converse.api.listen.on('roomsListInitialized', status => { ... });
*/
_converse
.
api
.
emit
(
'
roomsListInitialized
'
);
_converse
.
api
.
trigger
(
'
roomsListInitialized
'
);
},
render
()
{
...
...
src/converse-rosterview.js
View file @
f8977035
...
...
@@ -831,7 +831,7 @@ converse.plugins.add('converse-rosterview', {
* @event _converse#rosterViewInitialized
* @example _converse.api.listen.on('rosterViewInitialized', () => { ... });
*/
_converse
.
api
.
emit
(
'
rosterViewInitialized
'
);
_converse
.
api
.
trigger
(
'
rosterViewInitialized
'
);
},
render
()
{
...
...
src/headless/converse-chatboxes.js
View file @
f8977035
...
...
@@ -768,7 +768,7 @@ converse.plugins.add('converse-chatboxes', {
* @example _converse.api.listen.on('chatBoxesInitialized', () => { ... });
* @example _converse.api.waitUntil('chatBoxesInitialized').then(() => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxesInitialized
'
);
_converse
.
api
.
trigger
(
'
chatBoxesInitialized
'
);
},
registerMessageHandler
()
{
...
...
@@ -816,7 +816,7 @@ converse.plugins.add('converse-chatboxes', {
* @example _converse.api.listen.on('message', obj => { ... });
* @example _converse.api.waitUntil('chatBoxesFetched').then(() => { ... });
*/
_converse
.
api
.
emit
(
'
chatBoxesFetched
'
);
_converse
.
api
.
trigger
(
'
chatBoxesFetched
'
);
},
onConnected
()
{
...
...
@@ -977,7 +977,7 @@ converse.plugins.add('converse-chatboxes', {
* @property { XMLElement } stanza
* @example _converse.api.listen.on('message', obj => { ... });
*/
_converse
.
api
.
emit
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
chatbox
});
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
chatbox
});
},
getChatBox
(
jid
,
attrs
=
{},
create
)
{
...
...
@@ -1034,7 +1034,7 @@ converse.plugins.add('converse-chatboxes', {
* @example _converse.api.listen.on('privateChatsAutoJoined', () => { ... });
* @example _converse.api.waitUntil('privateChatsAutoJoined').then(() => { ... });
*/
_converse
.
api
.
emit
(
'
privateChatsAutoJoined
'
);
_converse
.
api
.
trigger
(
'
privateChatsAutoJoined
'
);
}
...
...
src/headless/converse-core.js
View file @
f8977035
This diff is collapsed.
Click to expand it.
src/headless/converse-disco.js
View file @
f8977035
...
...
@@ -101,7 +101,7 @@ converse.plugins.add('converse-disco', {
* @type { Backbone.Model }
* @example _converse.api.listen.on('featuresDiscovered', feature => { ... });
*/
_converse
.
api
.
emit
(
'
serviceDiscovered
'
,
feature
);
_converse
.
api
.
trigger
(
'
serviceDiscovered
'
,
feature
);
},
onFieldAdded
(
field
)
{
...
...
@@ -112,7 +112,7 @@ converse.plugins.add('converse-disco', {
* @event _converse#discoExtensionFieldDiscovered
* @example _converse.api.listen.on('discoExtensionFieldDiscovered', () => { ... });
*/
_converse
.
api
.
emit
(
'
discoExtensionFieldDiscovered
'
,
field
);
_converse
.
api
.
trigger
(
'
discoExtensionFieldDiscovered
'
,
field
);
},
fetchFeatures
()
{
...
...
@@ -246,7 +246,7 @@ converse.plugins.add('converse-disco', {
* @event _converse#addClientFeatures
* @example _converse.api.listen.on('addClientFeatures', () => { ... });
*/
_converse
.
api
.
emit
(
'
addClientFeatures
'
);
_converse
.
api
.
trigger
(
'
addClientFeatures
'
);
return
this
;
}
...
...
@@ -276,7 +276,7 @@ converse.plugins.add('converse-disco', {
* @event _converse#streamFeaturesAdded
* @example _converse.api.listen.on('streamFeaturesAdded', () => { ... });
*/
_converse
.
api
.
emit
(
'
streamFeaturesAdded
'
);
_converse
.
api
.
trigger
(
'
streamFeaturesAdded
'
);
}
async
function
initializeDisco
()
{
...
...
@@ -301,7 +301,7 @@ converse.plugins.add('converse-disco', {
* @event _converse#discoInitialized
* @example _converse.api.listen.on('discoInitialized', () => { ... });
*/
_converse
.
api
.
emit
(
'
discoInitialized
'
);
_converse
.
api
.
trigger
(
'
discoInitialized
'
);
}
_converse
.
api
.
listen
.
on
(
'
sessionInitialized
'
,
initStreamFeatures
);
...
...
src/headless/converse-muc.js
View file @
f8977035
...
...
@@ -521,7 +521,7 @@ converse.plugins.add('converse-muc', {
* @property { string } reason - The original reason for the invitation
* @example _converse.api.listen.on('chatBoxMaximized', view => { ... });
*/
_converse
.
api
.
emit
(
'
roomInviteSent
'
,
{
_converse
.
api
.
trigger
(
'
roomInviteSent
'
,
{
'
room
'
:
this
,
'
recipient
'
:
recipient
,
'
reason
'
:
reason
...
...
@@ -1059,7 +1059,7 @@ converse.plugins.add('converse-muc', {
this
.
handleMessageCorrection
(
stanza
)
||
this
.
isReceipt
(
stanza
)
||
this
.
isChatMarker
(
stanza
))
{
return
_converse
.
api
.
emit
(
'
message
'
,
{
'
stanza
'
:
original_stanza
});
return
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
});
}
const
attrs
=
await
this
.
getMessageAttributesFromStanza
(
stanza
,
original_stanza
);
if
(
attrs
.
nick
&&
...
...
@@ -1073,7 +1073,7 @@ converse.plugins.add('converse-muc', {
msg
.
save
({
'
received
'
:
moment
().
format
()});
}
}
_converse
.
api
.
emit
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
this
});
_converse
.
api
.
trigger
(
'
message
'
,
{
'
stanza
'
:
original_stanza
,
'
chatbox
'
:
this
});
},
onPresence
(
pres
)
{
...
...
@@ -1411,7 +1411,7 @@ converse.plugins.add('converse-muc', {
* @example _converse.api.listen.on('roomsAutoJoined', () => { ... });
* @example _converse.api.waitUntil('roomsAutoJoined').then(() => { ... });
*/
_converse
.
api
.
emit
(
'
roomsAutoJoined
'
);
_converse
.
api
.
trigger
(
'
roomsAutoJoined
'
);
}
function
disconnectChatRooms
()
{
...
...
src/headless/converse-roster.js
View file @
f8977035
...
...
@@ -71,7 +71,7 @@ converse.plugins.add('converse-roster', {
* @example _converse.api.listen.on('rosterInitialized', () => { ... });
* @example _converse.api.waitUntil('rosterInitialized').then(() => { ... });
*/
_converse
.
api
.
emit
(
'
rosterInitialized
'
);
_converse
.
api
.
trigger
(
'
rosterInitialized
'
);
};
...
...
@@ -94,7 +94,7 @@ converse.plugins.add('converse-roster', {
* @event _converse#rosterContactsFetched
* @example _converse.api.listen.on('rosterContactsFetched', () => { ... });
*/
_converse
.
api
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
}
catch
(
reason
)
{
_converse
.
log
(
reason
,
Strophe
.
LogLevel
.
ERROR
);
}
finally
{
...
...
@@ -110,9 +110,9 @@ converse.plugins.add('converse-roster', {
* @event _converse#rosterGroupsFetched
* @example _converse.api.listen.on('rosterGroupsFetched', () => { ... });
*/
_converse
.
api
.
emit
(
'
rosterGroupsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterGroupsFetched
'
);
await
_converse
.
roster
.
fetchRosterContacts
();
_converse
.
api
.
emit
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
}
catch
(
reason
)
{
_converse
.
log
(
reason
,
Strophe
.
LogLevel
.
ERROR
);
}
finally
{
...
...
@@ -251,7 +251,7 @@ converse.plugins.add('converse-roster', {
* @type { _converse.RosterContact }
* @example _converse.api.listen.on('contactPresenceChanged', contact => { ... });
*/
this
.
presence
.
on
(
'
change:show
'
,
()
=>
_converse
.
api
.
emit
(
'
contactPresenceChanged
'
,
this
));
this
.
presence
.
on
(
'
change:show
'
,
()
=>
_converse
.
api
.
trigger
(
'
contactPresenceChanged
'
,
this
));
this
.
presence
.
on
(
'
change:show
'
,
()
=>
this
.
trigger
(
'
presenceChanged
'
));
},
...
...
@@ -439,7 +439,7 @@ converse.plugins.add('converse-roster', {
* @example _converse.api.listen.on('cachedRoster', (items) => { ... });
* @example _converse.api.waitUntil('cachedRoster').then(items => { ... });
*/
_converse
.
api
.
emit
(
'
cachedRoster
'
,
collection
);
_converse
.
api
.
trigger
(
'
cachedRoster
'
,
collection
);
}
},
...
...
@@ -590,7 +590,7 @@ converse.plugins.add('converse-roster', {
* @type { XMLElement }
* @example _converse.api.listen.on('rosterPush', iq => { ... });
*/
_converse
.
api
.
emit
(
'
rosterPush
'
,
iq
);
_converse
.
api
.
trigger
(
'
rosterPush
'
,
iq
);
return
;
},
...
...
@@ -640,7 +640,7 @@ converse.plugins.add('converse-roster', {
* @example _converse.api.listen.on('roster', iq => { ... });
* @example _converse.api.waitUntil('roster').then(iq => { ... });
*/
_converse
.
api
.
emit
(
'
roster
'
,
iq
);
_converse
.
api
.
trigger
(
'
roster
'
,
iq
);
},
updateContact
(
item
)
{
...
...
@@ -700,7 +700,7 @@ converse.plugins.add('converse-roster', {
* @type { _converse.RosterContact }
* @example _converse.api.listen.on('contactRequest', contact => { ... });
*/
_converse
.
api
.
emit
(
'
contactRequest
'
,
this
.
create
(
user_data
));
_converse
.
api
.
trigger
(
'
contactRequest
'
,
this
.
create
(
user_data
));
},
handleIncomingSubscription
(
presence
)
{
...
...
@@ -921,7 +921,7 @@ converse.plugins.add('converse-roster', {
* @type { bool }
* @example _converse.api.listen.on('presencesInitialized', reconnecting => { ... });
*/
_converse
.
api
.
emit
(
'
presencesInitialized
'
,
reconnecting
);
_converse
.
api
.
trigger
(
'
presencesInitialized
'
,
reconnecting
);
});
_converse
.
api
.
listen
.
on
(
'
presencesInitialized
'
,
(
reconnecting
)
=>
{
...
...
@@ -933,7 +933,7 @@ converse.plugins.add('converse-roster', {
* @event _converse#rosterReadyAfterReconnection
* @example _converse.api.listen.on('rosterReadyAfterReconnection', () => { ... });
*/
_converse
.
api
.
emit
(
'
rosterReadyAfterReconnection
'
);
_converse
.
api
.
trigger
(
'
rosterReadyAfterReconnection
'
);
}
else
{
_converse
.
registerIntervalHandler
();
_converse
.
initRoster
();
...
...
src/headless/dist/converse-headless.js
View file @
f8977035
This diff is collapsed.
Click to expand it.
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