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
b0a9782d
Commit
b0a9782d
authored
Jan 21, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
emoji: Lazy load the emoji JSON
Only load it once the first chat has been opened.
parent
d5472a8d
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
97 additions
and
201 deletions
+97
-201
spec/bookmarks.js
spec/bookmarks.js
+1
-3
spec/chatbox.js
spec/chatbox.js
+12
-12
spec/controlbox.js
spec/controlbox.js
+1
-1
spec/converse.js
spec/converse.js
+1
-3
spec/emojis.js
spec/emojis.js
+2
-2
spec/http-file-upload.js
spec/http-file-upload.js
+2
-6
spec/messages.js
spec/messages.js
+9
-9
spec/muc.js
spec/muc.js
+11
-11
spec/omemo.js
spec/omemo.js
+1
-1
spec/roomslist.js
spec/roomslist.js
+5
-5
spec/user-details-modal.js
spec/user-details-modal.js
+4
-6
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+1
-3
src/headless/converse-emoji.js
src/headless/converse-emoji.js
+44
-137
src/headless/utils/core.js
src/headless/utils/core.js
+1
-1
tests/mock.js
tests/mock.js
+2
-1
No files found.
spec/bookmarks.js
View file @
b0a9782d
...
...
@@ -16,9 +16,7 @@
describe
(
"
A chat room
"
,
function
()
{
it
(
"
can be bookmarked
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
it
(
"
can be bookmarked
"
,
mock
.
initConverse
([
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
...
...
spec/chatbox.js
View file @
b0a9782d
...
...
@@ -162,7 +162,7 @@
}));
it
(
"
can be trimmed to conserve space
"
,
mock
.
initConverse
([
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
mock
.
initConverse
([
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
spyOn
(
_converse
.
chatboxviews
,
'
trimChats
'
);
...
...
@@ -523,7 +523,7 @@
it
(
"
does not open a new chatbox
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -884,7 +884,7 @@
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
sent_stanzas
=
_converse
.
connection
.
sent_stanzas
;
...
...
@@ -1190,7 +1190,7 @@
it
(
"
is incremented from zero when chatbox was closed after viewing previously received messages and the window is not focused now
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -1271,7 +1271,7 @@
}));
it
(
"
is incremeted when message is received, chatbox is scrolled down and the window is not focused
"
,
mock
.
initConverse
([
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
mock
.
initConverse
([
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -1291,7 +1291,7 @@
it
(
"
is incremeted when message is received, chatbox is scrolled up and the window is not focused
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
@@ -1309,7 +1309,7 @@
it
(
"
is cleared when ChatBoxView was scrolled down and the window become focused
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
@@ -1328,7 +1328,7 @@
it
(
"
is not cleared when ChatBoxView was scrolled up and the windows become focused
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
@@ -1433,7 +1433,7 @@
it
(
"
is cleared when unread messages are viewed which were received in scrolled-up chatbox
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
openControlBox
(
_converse
);
...
...
@@ -1458,7 +1458,7 @@
it
(
"
is not cleared after user clicks on roster view when chatbox is already opened and scrolled up
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
@@ -1485,7 +1485,7 @@
it
(
"
is displayed when scrolled up chatbox is minimized after receiving unread messages
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
@@ -1513,7 +1513,7 @@
it
(
"
is incremented when message is received and windows is not focused
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
spec/controlbox.js
View file @
b0a9782d
...
...
@@ -38,7 +38,7 @@
it
(
"
can be used to add contact and it checks for case-sensivity
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
...
...
spec/converse.js
View file @
b0a9782d
...
...
@@ -214,9 +214,7 @@
describe
(
"
The
\"
contacts
\"
API
"
,
function
()
{
it
(
"
has a method 'get' which returns wrapped contacts
"
,
mock
.
initConverse
(
[
'
emojisInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
mock
.
initConverse
([],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
let
contact
=
await
_converse
.
api
.
contacts
.
get
(
'
non-existing@jabber.org
'
);
...
...
spec/emojis.js
View file @
b0a9782d
...
...
@@ -105,7 +105,7 @@
it
(
"
allows you to search for particular emojis
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
lounge@montague.lit
'
;
...
...
@@ -158,7 +158,7 @@
describe
(
"
A Chat Message
"
,
function
()
{
it
(
"
will display larger if it's only emojis
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{
'
use_system_emojis
'
:
true
},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
use_system_emojis
'
:
true
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
spec/http-file-upload.js
View file @
b0a9782d
...
...
@@ -171,9 +171,7 @@
describe
(
"
A file upload toolbar button
"
,
function
()
{
it
(
"
does not appear in private chats
"
,
mock
.
initConverse
(
[
'
emojisInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
mock
.
initConverse
([],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
3
);
test_utils
.
openControlBox
(
_converse
);
...
...
@@ -461,9 +459,7 @@
}));
it
(
"
shows an error message if the file is too large
"
,
mock
.
initConverse
(
[
'
emojisInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
mock
.
initConverse
([],
{},
async
function
(
done
,
_converse
)
{
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
IQ_ids
=
_converse
.
connection
.
IQ_ids
;
...
...
spec/messages.js
View file @
b0a9782d
...
...
@@ -985,7 +985,7 @@
it
(
"
will render images from their URLs
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -1033,7 +1033,7 @@
it
(
"
will render the message time as configured
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -1059,7 +1059,7 @@
it
(
"
will be correctly identified and rendered as a followup message
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -1381,7 +1381,7 @@
it
(
"
will open a chatbox and be displayed inside it
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
include_nick
=
false
;
...
...
@@ -1427,7 +1427,7 @@
it
(
"
will be trimmed of leading and trailing whitespace
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
,
false
);
...
...
@@ -1519,7 +1519,7 @@
it
(
"
the VCard for that user is fetched and the chatbox updated with the results
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{
'
allow_non_roster_messaging
'
:
true
},
[
'
rosterGroupsFetched
'
],
{
'
allow_non_roster_messaging
'
:
true
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
0
);
...
...
@@ -1635,7 +1635,7 @@
it
(
"
will have the error message displayed after itself
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
...
...
@@ -1847,7 +1847,7 @@
it
(
"
is ignored if it's intended for a different resource and filter_by_resource is set to true
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -2098,7 +2098,7 @@
it
(
"
is not sent when a markable message is received from someone not on the roster
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{
'
allow_non_roster_messaging
'
:
true
},
[
'
rosterGroupsFetched
'
],
{
'
allow_non_roster_messaging
'
:
true
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
0
);
...
...
spec/muc.js
View file @
b0a9782d
...
...
@@ -269,7 +269,7 @@
it
(
"
will be created when muc_instant_rooms is set to true
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
let
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
...
...
@@ -507,7 +507,7 @@
it
(
"
is opened when an xmpp: URI is clicked inside another groupchat
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
...
...
@@ -535,7 +535,7 @@
it
(
"
shows a notification if it's not anonymous
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
coven@chat.shakespeare.lit
'
;
...
...
@@ -579,7 +579,7 @@
it
(
"
shows join/leave messages when users enter or exit a groupchat
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
coven@chat.shakespeare.lit
'
;
...
...
@@ -1648,7 +1648,7 @@
it
(
"
shows users currently present in the groupchat
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge@montague.lit
'
,
'
romeo
'
);
...
...
@@ -2188,7 +2188,7 @@
it
(
"
escapes the subject before rendering it, to avoid JS-injection attacks
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
jdev@conference.jabber.org
'
,
'
jc
'
);
...
...
@@ -2711,7 +2711,7 @@
it
(
"
informs users if they have been kicked out of the groupchat
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
/* <presence
...
...
@@ -3514,7 +3514,7 @@
it
(
"
takes a /kick command to kick a user
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
let
sent_IQ
,
IQ_id
;
...
...
@@ -3956,7 +3956,7 @@
it
(
"
will show an error message if the groupchat requires a password
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
protected
'
;
...
...
@@ -4747,7 +4747,7 @@
it
(
"
can be opened from a link in the
\"
Groupchats
\"
section of the controlbox
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
openControlBox
(
_converse
);
...
...
@@ -4891,7 +4891,7 @@
it
(
"
shows the number of unread mentions received
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{
'
allow_bookmarks
'
:
false
},
[
'
rosterGroupsFetched
'
],
{
'
allow_bookmarks
'
:
false
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
openControlBox
(
_converse
);
...
...
spec/omemo.js
View file @
b0a9782d
...
...
@@ -93,7 +93,7 @@
it
(
"
enables encrypted messages to be sent and received
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
{},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
let
sent_stanza
;
...
...
spec/roomslist.js
View file @
b0a9782d
...
...
@@ -8,7 +8,7 @@
describe
(
"
A list of open groupchats
"
,
function
()
{
it
(
"
is shown in controlbox
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
},
async
function
(
done
,
_converse
)
{
...
...
@@ -50,7 +50,7 @@
it
(
"
uses bookmarks to determine groupchat names
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
async
function
(
done
,
_converse
)
{
...
...
@@ -110,7 +110,7 @@
describe
(
"
A groupchat shown in the groupchats list
"
,
function
()
{
it
(
"
is highlighted if it's currently open
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
view_mode
:
'
fullscreen
'
,
allow_bookmarks
:
false
// Makes testing easier, otherwise we have to mock stanza traffic.
},
async
function
(
done
,
_converse
)
{
...
...
@@ -139,7 +139,7 @@
}));
it
(
"
has an info icon which opens a details modal when clicked
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitialized
'
],
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
...
...
@@ -244,7 +244,7 @@
}));
it
(
"
can be closed
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
[
'
rosterGroupsFetched
'
],
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we have to mock stanza traffic.
},
...
...
spec/user-details-modal.js
View file @
b0a9782d
...
...
@@ -11,9 +11,9 @@
return
describe
(
"
The User Details Modal
"
,
function
()
{
it
(
"
can be used to remove a contact
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
,
'
emojisInitializ
ed
'
],
{},
async
function
(
done
,
_converse
)
{
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetch
ed
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
...
...
@@ -44,9 +44,7 @@
}));
it
(
"
shows an alert when an error happened while removing the contact
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
emojisInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
mock
.
initConverse
([
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
...
...
src/headless/converse-chatboxes.js
View file @
b0a9782d
...
...
@@ -86,9 +86,7 @@ converse.plugins.add('converse-chatboxes', {
},
onConnected
(
reconnecting
)
{
if
(
reconnecting
)
{
return
;
}
if
(
reconnecting
)
{
return
;
}
this
.
browserStorage
=
_converse
.
createStore
(
`converse.chatboxes-
${
_converse
.
bare_jid
}
`
);
this
.
fetch
({
'
add
'
:
true
,
...
...
src/headless/converse-emoji.js
View file @
b0a9782d
...
...
@@ -14,121 +14,19 @@ const { Backbone } = converse.env;
const
u
=
converse
.
env
.
utils
;
const
ASCII_LIST
=
{
'
*
\\
0/*
'
:
'
1f646
'
,
'
*
\\
O/*
'
:
'
1f646
'
,
'
-___-
'
:
'
1f611
'
,
'
:
\'
-)
'
:
'
1f602
'
,
'
\'
:-)
'
:
'
1f605
'
,
'
\'
:-D
'
:
'
1f605
'
,
'
>:-)
'
:
'
1f606
'
,
'
\'
:-(
'
:
'
1f613
'
,
'
>:-(
'
:
'
1f620
'
,
'
:
\'
-(
'
:
'
1f622
'
,
'
O:-)
'
:
'
1f607
'
,
'
0:-3
'
:
'
1f607
'
,
'
0:-)
'
:
'
1f607
'
,
'
0;^)
'
:
'
1f607
'
,
'
O;-)
'
:
'
1f607
'
,
'
0;-)
'
:
'
1f607
'
,
'
O:-3
'
:
'
1f607
'
,
'
-__-
'
:
'
1f611
'
,
'
:-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'
1f61b
'
,
'
:b
'
:
'
1f61b
'
,
'
:O
'
:
'
1f62e
'
,
'
:X
'
:
'
1f636
'
,
'
:#
'
:
'
1f636
'
,
'
=X
'
:
'
1f636
'
,
'
=#
'
:
'
1f636
'
,
'
:)
'
:
'
1f642
'
,
'
=]
'
:
'
1f642
'
,
'
=)
'
:
'
1f642
'
,
'
:]
'
:
'
1f642
'
};
...
...
@@ -202,6 +100,7 @@ converse.plugins.add('converse-emoji', {
}
});
_converse
.
emojis
=
{};
_converse
.
api
.
promises
.
add
(
'
emojisInitialized
'
,
false
);
twemoji
.
default
.
base
=
_converse
.
emoji_image_path
;
...
...
@@ -220,8 +119,6 @@ converse.plugins.add('converse-emoji', {
}
});
_converse
.
emojis
=
{};
function
getTonedEmojis
()
{
if
(
!
_converse
.
toned_emojis
)
{
_converse
.
toned_emojis
=
_
.
uniq
(
...
...
@@ -366,26 +263,29 @@ converse.plugins.add('converse-emoji', {
});
/************************ END Utils ************************/
const
{
default
:
json
}
=
await
import
(
/*webpackChunkName: "emojis" */
'
./emojis.json
'
);
_converse
.
emojis
.
json
=
json
;
_converse
.
emojis
.
categories
=
Object
.
keys
(
_converse
.
emojis
.
json
);
_converse
.
emojis_map
=
_converse
.
emojis
.
categories
.
reduce
((
result
,
cat
)
=>
Object
.
assign
(
result
,
_converse
.
emojis
.
json
[
cat
]),
{});
_converse
.
emojis_list
=
Object
.
values
(
_converse
.
emojis_map
);
_converse
.
emojis_list
.
sort
((
a
,
b
)
=>
a
.
sn
<
b
.
sn
?
-
1
:
(
a
.
sn
>
b
.
sn
?
1
:
0
));
_converse
.
emoji_shortnames
=
_converse
.
emojis_list
.
map
(
m
=>
m
.
sn
);
const
getShortNames
=
()
=>
_converse
.
emoji_shortnames
.
map
(
s
=>
s
.
replace
(
/
[
+
]
/g
,
"
\\
$&
"
)).
join
(
'
|
'
);
_converse
.
emojis
.
shortnames_regex
=
new
RegExp
(
"
<object[^>]*>.*?<
\
/object>|<span[^>]*>.*?<
\
/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(
"
+
getShortNames
()
+
"
)
"
,
"
gi
"
);
_converse
.
emojis
.
toned
=
getTonedEmojis
();
/**
* Triggered once the JSON file representing emoji data has been
* fetched and its save to start calling emoji utility methods.
* @event _converse#emojisInitialized
*/
_converse
.
api
.
trigger
(
'
emojisInitialized
'
);
async
function
initializeEmojis
()
{
if
(
_converse
.
emojis
.
json
)
{
return
;
}
const
{
default
:
json
}
=
await
import
(
/*webpackChunkName: "emojis" */
'
./emojis.json
'
);
_converse
.
emojis
.
json
=
json
;
_converse
.
emojis
.
categories
=
Object
.
keys
(
_converse
.
emojis
.
json
);
_converse
.
emojis_map
=
_converse
.
emojis
.
categories
.
reduce
((
result
,
cat
)
=>
Object
.
assign
(
result
,
_converse
.
emojis
.
json
[
cat
]),
{});
_converse
.
emojis_list
=
Object
.
values
(
_converse
.
emojis_map
);
_converse
.
emojis_list
.
sort
((
a
,
b
)
=>
a
.
sn
<
b
.
sn
?
-
1
:
(
a
.
sn
>
b
.
sn
?
1
:
0
));
_converse
.
emoji_shortnames
=
_converse
.
emojis_list
.
map
(
m
=>
m
.
sn
);
const
getShortNames
=
()
=>
_converse
.
emoji_shortnames
.
map
(
s
=>
s
.
replace
(
/
[
+
]
/g
,
"
\\
$&
"
)).
join
(
'
|
'
);
_converse
.
emojis
.
shortnames_regex
=
new
RegExp
(
"
<object[^>]*>.*?<
\
/object>|<span[^>]*>.*?<
\
/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(
"
+
getShortNames
()
+
"
)
"
,
"
gi
"
);
_converse
.
emojis
.
toned
=
getTonedEmojis
();
/**
* Triggered once the JSON file representing emoji data has been
* fetched and its save to start calling emoji utility methods.
* @event _converse#emojisInitialized
*/
_converse
.
api
.
trigger
(
'
emojisInitialized
'
);
}
/************************ BEGIN Event Handlers ************************/
...
...
@@ -395,6 +295,13 @@ converse.plugins.add('converse-emoji', {
delete
_converse
.
emojipicker
}
});
_converse
.
api
.
listen
.
on
(
'
chatBoxesInitialized
'
,
()
=>
{
_converse
.
chatboxes
.
on
(
'
add
'
,
chat
=>
(
chat
.
get
(
'
type
'
)
!==
_converse
.
CONTROLBOX_TYPE
)
&&
initializeEmojis
()
);
});
/************************ END Event Handlers ************************/
}
});
src/headless/utils/core.js
View file @
b0a9782d
...
...
@@ -384,7 +384,7 @@ u.getResolveablePromise = function () {
wrapper
.
resolve
=
resolve
;
wrapper
.
reject
=
reject
;
})
_
.
assign
(
promise
,
wrapper
);
Object
.
assign
(
promise
,
wrapper
);
promise
.
then
(
function
(
v
)
{
promise
.
isResolved
=
true
;
...
...
tests/mock.js
View file @
b0a9782d
...
...
@@ -227,8 +227,9 @@
db_request
.
onsuccess
=
function
()
{
const
db
=
db_request
.
result
;
const
bare_jid
=
"
romeo@montague.lit
"
;
let
store
;
try
{
const
store
=
db
.
transaction
([
bare_jid
],
"
readwrite
"
).
objectStore
(
bare_jid
);
store
=
db
.
transaction
([
bare_jid
],
"
readwrite
"
).
objectStore
(
bare_jid
);
}
catch
(
e
)
{
console
.
error
(
e
);
return
promise
.
resolve
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file