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
eed936ff
Commit
eed936ff
authored
Aug 09, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying to fix timing/heisenbugs on Travis
parent
5a67d985
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
45 deletions
+46
-45
spec/chatbox.js
spec/chatbox.js
+39
-41
src/converse-chatview.js
src/converse-chatview.js
+7
-4
No files found.
spec/chatbox.js
View file @
eed936ff
...
...
@@ -409,21 +409,21 @@
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
test_utils
.
waitUntil
(
function
()
{
return
!
view
.
el
.
querySelector
(
'
.toggle-smiley .toolbar-menu
'
).
offsetHeight
;
},
300
)
.
then
(
function
()
{
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
expect
(
view
.
toggleEmojiMenu
).
toHaveBeenCalled
();
view
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
})
);
test_utils
.
waitUntil
(
function
()
{
var
$picker
=
view
.
$el
.
find
(
'
.toggle-smiley .emoji-picker-container
'
);
return
$picker
.
is
(
'
:visible
'
);
},
300
).
then
(
function
()
{
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
children
(
'
li
'
).
last
().
click
();
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
();
done
(
);
}
);
}
);
});
},
300
)
.
then
(
function
()
{
$toolbar
.
children
(
'
li.toggle-smiley
'
).
click
();
expect
(
view
.
toggleEmojiMenu
).
toHaveBeenCalled
(
);
test_utils
.
waitUntil
(
function
()
{
var
$picker
=
view
.
$el
.
find
(
'
.toggle-smiley .emoji-picker-container
'
);
return
$picker
.
is
(
'
:visible
'
);
},
300
)
.
then
(
function
()
{
view
.
$el
.
find
(
'
.toggle-smiley ul
'
).
children
(
'
li
'
).
last
().
click
();
expect
(
view
.
$el
.
find
(
'
textarea.chat-textarea
'
).
val
()).
toBe
(
'
:grinning:
'
);
expect
(
view
.
insertEmoji
).
toHaveBeenCalled
(
);
done
(
);
});
});
});
}));
it
(
"
contains a button for starting an encrypted chat session
"
,
...
...
@@ -744,23 +744,22 @@
});
it
(
"
will cause the chat area to be scrolled down only if it was at the bottom already
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
var
message
=
'
This message is received while the chat area is scrolled up
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
var
chatboxview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
spyOn
(
chatboxview
,
'
scrollDown
'
).
and
.
callThrough
();
var
$chat_content
=
chatboxview
.
$el
.
find
(
'
.chat-content
'
);
/* Create enough messages so that there's a
* scrollbar.
*/
// Create enough messages so that there's a scrollbar.
var
message
=
'
This message is received while the chat area is scrolled up
'
;
for
(
var
i
=
0
;
i
<
20
;
i
++
)
{
_converse
.
chatboxes
.
onMessage
(
$msg
({
from
:
sender_jid
,
...
...
@@ -773,11 +772,11 @@
test_utils
.
waitUntil
(
function
()
{
return
chatboxview
.
$content
.
scrollTop
();
},
3
00
)
},
5
00
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
!
chatboxview
.
model
.
get
(
'
auto_scrolled
'
);
},
3
00
);
},
5
00
);
}).
then
(
function
()
{
chatboxview
.
$content
.
scrollTop
(
0
);
return
test_utils
.
waitUntil
(
function
()
{
...
...
@@ -798,7 +797,7 @@
expect
(
msg_txt
).
toEqual
(
message
);
return
test_utils
.
waitUntil
(
function
()
{
return
chatboxview
.
$
(
'
.new-msgs-indicator
'
).
is
(
'
:visible
'
);
},
3
00
);
},
5
00
);
}).
then
(
function
()
{
expect
(
chatboxview
.
model
.
get
(
'
scrolled
'
)).
toBe
(
true
);
expect
(
chatboxview
.
$content
.
scrollTop
()).
toBe
(
0
);
...
...
@@ -807,15 +806,14 @@
chatboxview
.
$content
.
scrollTop
(
chatboxview
.
$content
[
0
].
scrollHeight
);
return
test_utils
.
waitUntil
(
function
()
{
return
!
chatboxview
.
$
(
'
.new-msgs-indicator
'
).
is
(
'
:visible
'
);
},
3
00
);
},
5
00
);
}).
then
(
done
);
}));
it
(
"
is ignored if it's intended for a different resource and filter_by_resource is set to true
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
...
...
@@ -1461,7 +1459,7 @@
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
rosterview
.
$el
.
find
(
'
dt
'
).
length
;
},
3
00
).
then
(
function
()
{
},
5
00
).
then
(
function
()
{
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
var
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
view
.
model
.
minimize
();
...
...
@@ -1470,7 +1468,7 @@
view
.
model
.
maximize
();
return
test_utils
.
waitUntil
(
function
()
{
return
view
.
model
.
get
(
'
chat_state
'
)
===
'
active
'
;
},
3
00
);
},
5
00
);
}).
then
(
function
()
{
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
...
...
@@ -1491,9 +1489,9 @@
describe
(
"
A composing notification
"
,
function
()
{
it
(
"
is sent as soon as the user starts typing a message which is not a command
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
...
...
@@ -1748,9 +1746,9 @@
describe
(
"
An inactive notifciation
"
,
function
()
{
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
view
,
contact_jid
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
...
...
@@ -1777,11 +1775,11 @@
return
true
;
}
return
false
;
},
25
0
);
},
30
0
);
}).
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
view
.
model
.
get
(
'
chat_state
'
)
===
'
inactive
'
;
},
25
0
);
},
30
0
);
}).
then
(
function
()
{
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
...
...
src/converse-chatview.js
View file @
eed936ff
...
...
@@ -137,7 +137,7 @@
initialize
()
{
this
.
model
.
on
(
'
change:current_skintone
'
,
this
.
render
,
this
);
this
.
model
.
on
(
'
change:current_category
'
,
this
.
render
,
this
);
this
.
setScrollPosition
=
_
.
debounce
(
this
.
setScrollPosition
,
50
)
.
bind
(
this
)
;
this
.
setScrollPosition
=
_
.
debounce
(
this
.
setScrollPosition
,
50
);
},
render
()
{
...
...
@@ -153,7 +153,7 @@
));
this
.
el
.
innerHTML
=
emojis_html
;
_
.
forEach
(
this
.
el
.
querySelectorAll
(
'
.emoji-picker
'
),
(
el
)
=>
{
el
.
addEventListener
(
'
scroll
'
,
this
.
setScrollPosition
);
el
.
addEventListener
(
'
scroll
'
,
this
.
setScrollPosition
.
bind
(
this
)
);
});
this
.
restoreScrollPosition
();
return
this
;
...
...
@@ -234,6 +234,8 @@
},
initialize
()
{
this
.
markScrolled
=
_
.
debounce
(
this
.
markScrolled
,
100
);
this
.
createEmojiPicker
();
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
...
...
@@ -955,7 +957,7 @@
}
},
markScrolled
:
_
.
debounce
(
function
(
ev
)
{
markScrolled
:
function
(
ev
)
{
/* Called when the chat content is scrolled up or down.
* We want to record when the user has scrolled away from
* the bottom, so that we don't automatically scroll away
...
...
@@ -974,12 +976,13 @@
const
is_at_bottom
=
(
this
.
$content
.
scrollTop
()
+
this
.
$content
.
innerHeight
())
>=
this
.
$content
[
0
].
scrollHeight
-
10
;
if
(
is_at_bottom
)
{
scrolled
=
false
;
this
.
onScrolledDown
();
}
utils
.
safeSave
(
this
.
model
,
{
'
scrolled
'
:
scrolled
});
},
150
),
},
viewUnreadMessages
()
{
this
.
model
.
save
(
'
scrolled
'
,
false
);
...
...
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