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
21a46a15
Commit
21a46a15
authored
Dec 25, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. `markScrolled` wasn't debounced for MUC.
parent
308cbf5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
31 deletions
+51
-31
src/converse-chatview.js
src/converse-chatview.js
+37
-25
src/converse-muc.js
src/converse-muc.js
+2
-0
src/utils.js
src/utils.js
+12
-6
No files found.
src/converse-chatview.js
View file @
21a46a15
...
...
@@ -265,7 +265,7 @@
},
initialize
()
{
this
.
markScrolled
=
_
.
debounce
(
this
.
markScrolled
,
100
);
this
.
markScrolled
=
_
.
debounce
(
this
.
_
markScrolled
,
100
);
this
.
createEmojiPicker
();
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
...
...
@@ -434,9 +434,13 @@
Element
.
prototype
.
getAttribute
,
'
data-isodate
'
)
msg_dates
.
push
(
cutoff
.
format
());
if
(
_
.
isObject
(
cutoff
))
{
cutoff
=
cutoff
.
format
();
}
msg_dates
.
push
(
cutoff
);
msg_dates
.
sort
();
return
msg_dates
[
msg_dates
.
indexOf
(
cutoff
)
-
1
];
const
idx
=
msg_dates
.
indexOf
(
cutoff
);
return
msg_dates
[
idx
===
0
?
idx
:
idx
-
1
];
},
showMessage
(
attrs
)
{
...
...
@@ -455,7 +459,8 @@
first_msg_el
=
this
.
content
.
firstElementChild
,
first_msg_date
=
first_msg_el
?
first_msg_el
.
getAttribute
(
'
data-isodate
'
)
:
null
,
append_element
=
_
.
bind
(
this
.
content
.
insertAdjacentElement
,
this
.
content
,
'
beforeend
'
),
append_html
=
_
.
bind
(
this
.
content
.
insertAdjacentHTML
,
this
.
content
,
'
beforeend
'
);
append_html
=
_
.
bind
(
this
.
content
.
insertAdjacentHTML
,
this
.
content
,
'
beforeend
'
),
prepend_element
=
_
.
bind
(
this
.
content
.
insertAdjacentElement
,
this
.
content
,
'
afterbegin
'
);
if
(
!
first_msg_date
)
{
// This is the first received message, so we insert a
...
...
@@ -483,7 +488,6 @@
// We need to prepend the message immediately before the
// first message (so that it'll still be after the day
// indicator).
const
prepend_element
=
_
.
bind
(
this
.
content
.
insertAdjacentElement
,
this
.
content
,
'
afterbegin
'
);
this
.
insertMessage
(
attrs
,
prepend_element
);
if
(
current_msg_date
.
isBefore
(
first_msg_date
,
'
day
'
))
{
// This message is also on a different day, so
...
...
@@ -495,8 +499,12 @@
const
previous_msg_date
=
this
.
getLastMessageDate
(
current_msg_date
);
const
previous_msg_el
=
this
.
content
.
querySelector
(
`.message[data-isodate="
${
previous_msg_date
}
"]`
);
this
.
insertMessage
(
attrs
,
_
.
bind
(
previous_msg_el
.
insertAdjacentElement
,
previous_msg_el
,
'
afterend
'
));
if
(
_
.
isNull
(
previous_msg_el
))
{
this
.
insertMessage
(
attrs
,
prepend_element
);
}
else
{
this
.
insertMessage
(
attrs
,
_
.
bind
(
previous_msg_el
.
insertAdjacentElement
,
previous_msg_el
,
'
afterend
'
));
}
},
getExtraMessageTemplateAttributes
()
{
...
...
@@ -617,15 +625,15 @@
handleTextMessage
(
message
)
{
this
.
showMessage
(
_
.
clone
(
message
.
attributes
));
if
(
u
.
isNewMessage
(
message
)
&&
message
.
get
(
'
sender
'
)
===
'
me
'
)
{
// We remove the "scrolled" flag so that the chat area
// gets scrolled down. We always want to scroll down
// when the user writes a message as opposed to when a
// message is received.
this
.
model
.
set
(
'
scrolled
'
,
false
);
}
else
{
if
(
u
.
isNewMessage
(
message
)
&&
this
.
model
.
get
(
'
scrolled
'
,
true
))
{
this
.
$el
.
find
(
'
.new-msgs-indicator
'
).
removeClass
(
'
hidden
'
);
if
(
u
.
isNewMessage
(
message
))
{
if
(
message
.
get
(
'
sender
'
)
===
'
me
'
)
{
// We remove the "scrolled" flag so that the chat area
// gets scrolled down. We always want to scroll down
// when the user writes a message as opposed to when a
// message is received.
this
.
model
.
set
(
'
scrolled
'
,
false
);
}
else
if
(
this
.
model
.
get
(
'
scrolled
'
,
true
))
{
this
.
showNewMessagesIndicator
(
);
}
}
if
(
this
.
shouldShowOnTextMessage
())
{
...
...
@@ -991,6 +999,10 @@
return
this
;
},
showNewMessagesIndicator
()
{
u
.
showElement
(
this
.
el
.
querySelector
(
'
.new-msgs-indicator
'
));
},
hideNewMessagesIndicator
()
{
const
new_msgs_indicator
=
this
.
el
.
querySelector
(
'
.new-msgs-indicator
'
);
if
(
!
_
.
isNull
(
new_msgs_indicator
))
{
...
...
@@ -998,7 +1010,7 @@
}
},
markScrolled
:
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
...
...
@@ -1042,14 +1054,6 @@
}
},
onScrolledDown
()
{
this
.
hideNewMessagesIndicator
();
if
(
_converse
.
windowState
!==
'
hidden
'
)
{
this
.
model
.
clearUnreadMsgCounter
();
}
_converse
.
emit
(
'
chatBoxScrolledDown
'
,
{
'
chatbox
'
:
this
.
model
});
},
scrollDown
()
{
if
(
_
.
isUndefined
(
this
.
debouncedScrollDown
))
{
/* We wrap the method in a debouncer and set it on the
...
...
@@ -1062,6 +1066,14 @@
return
this
;
},
onScrolledDown
()
{
this
.
hideNewMessagesIndicator
();
if
(
_converse
.
windowState
!==
'
hidden
'
)
{
this
.
model
.
clearUnreadMsgCounter
();
}
_converse
.
emit
(
'
chatBoxScrolledDown
'
,
{
'
chatbox
'
:
this
.
model
});
},
onWindowStateChanged
(
state
)
{
if
(
this
.
model
.
get
(
'
num_unread
'
,
0
)
&&
!
this
.
model
.
newMessageWillBeHidden
())
{
this
.
model
.
clearUnreadMsgCounter
();
...
...
src/converse-muc.js
View file @
21a46a15
...
...
@@ -439,6 +439,8 @@
},
initialize
()
{
this
.
markScrolled
=
_
.
debounce
(
this
.
_markScrolled
,
100
);
this
.
model
.
messages
.
on
(
'
add
'
,
this
.
onMessageAdded
,
this
);
this
.
model
.
on
(
'
show
'
,
this
.
show
,
this
);
this
.
model
.
on
(
'
destroy
'
,
this
.
hide
,
this
);
...
...
src/utils.js
View file @
21a46a15
...
...
@@ -87,23 +87,29 @@
var
u
=
{};
u
.
removeClass
=
function
(
klass
,
el
)
{
if
(
!
_
.
isNil
(
el
))
{
el
.
classList
.
remove
(
klass
);
}
return
el
;
}
u
.
removeElement
=
function
(
el
)
{
if
(
!
_
.
isNil
(
el
)
&&
!
_
.
isNil
(
el
.
parentNode
))
{
el
.
parentNode
.
removeChild
(
el
);
}
}
u
.
showElement
=
function
(
el
)
{
if
(
!
_
.
isNil
(
el
))
{
el
.
classList
.
remove
(
'
collapsed
'
);
el
.
classList
.
remove
(
'
hidden
'
);
}
}
u
.
showElement
=
_
.
flow
(
_
.
partial
(
u
.
removeClass
,
'
collapsed
'
),
_
.
partial
(
u
.
removeClass
,
'
hidden
'
)
)
u
.
hideElement
=
function
(
el
)
{
if
(
!
_
.
isNil
(
el
))
{
el
.
classList
.
add
(
'
hidden
'
);
}
return
el
;
}
u
.
nextUntil
=
function
(
el
,
selector
,
include_self
=
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