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
22573cf7
Commit
22573cf7
authored
Jul 09, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1637 aned #2130
parent
1269cb72
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
51 deletions
+24
-51
src/converse-chatview.js
src/converse-chatview.js
+9
-5
src/converse-mam-views.js
src/converse-mam-views.js
+15
-46
No files found.
src/converse-chatview.js
View file @
22573cf7
...
@@ -240,11 +240,7 @@ converse.plugins.add('converse-chatview', {
...
@@ -240,11 +240,7 @@ converse.plugins.add('converse-chatview', {
render
()
{
render
()
{
const
result
=
tpl_chatbox
(
const
result
=
tpl_chatbox
(
Object
.
assign
(
Object
.
assign
(
this
.
model
.
toJSON
(),
{
'
markScrolled
'
:
()
=>
this
.
markScrolled
()})
this
.
model
.
toJSON
(),
{
'
markScrolled
'
:
()
=>
this
.
markScrolled
()
}
)
);
);
render
(
result
,
this
.
el
);
render
(
result
,
this
.
el
);
this
.
content
=
this
.
el
.
querySelector
(
'
.chat-content
'
);
this
.
content
=
this
.
el
.
querySelector
(
'
.chat-content
'
);
...
@@ -1099,6 +1095,14 @@ converse.plugins.add('converse-chatview', {
...
@@ -1099,6 +1095,14 @@ converse.plugins.add('converse-chatview', {
if
(
is_at_bottom
)
{
if
(
is_at_bottom
)
{
scrolled
=
false
;
scrolled
=
false
;
this
.
onScrolledDown
();
this
.
onScrolledDown
();
}
else
if
(
this
.
content
.
scrollTop
===
0
)
{
/**
* Triggered once the chat's message area has been scrolled to the top
* @event _converse#chatBoxScrolledUp
* @property { _converse.ChatBoxView | _converse.ChatRoomView } view
* @example _converse.api.listen.on('chatBoxScrolledUp', obj => { ... });
*/
api
.
trigger
(
'
chatBoxScrolledUp
'
,
this
);
}
}
u
.
safeSave
(
this
.
model
,
{
u
.
safeSave
(
this
.
model
,
{
'
scrolled
'
:
scrolled
,
'
scrolled
'
:
scrolled
,
...
...
src/converse-mam-views.js
View file @
22573cf7
...
@@ -5,60 +5,29 @@
...
@@ -5,60 +5,29 @@
* @copyright 2020, the Converse.js contributors
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @license Mozilla Public License (MPLv2)
*/
*/
import
{
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
import
{
debounce
}
from
'
lodash-es
'
converse
.
plugins
.
add
(
'
converse-mam-views
'
,
{
converse
.
plugins
.
add
(
'
converse-mam-views
'
,
{
dependencies
:
[
'
converse-mam
'
,
'
converse-chatview
'
,
'
converse-muc-views
'
],
dependencies
:
[
'
converse-mam
'
,
'
converse-chatview
'
,
'
converse-muc-views
'
],
overrides
:
{
initialize
()
{
// Overrides mentioned here will be picked up by converse.js's
api
.
listen
.
on
(
'
chatBoxScrolledUp
'
,
async
view
=>
{
// plugin architecture they will replace existing methods on the
if
(
view
.
model
.
messages
.
length
)
{
// relevant objects or classes.
const
oldest_message
=
view
.
model
.
getOldestMessage
();
//
if
(
oldest_message
)
{
// New functions which don't exist yet can also be added.
const
by_jid
=
view
.
model
.
get
(
'
jid
'
);
const
stanza_id
=
oldest_message
&&
oldest_message
.
get
(
`stanza_id
${
by_jid
}
`
);
ChatBoxView
:
{
view
.
addSpinner
();
render
()
{
if
(
stanza_id
)
{
const
result
=
this
.
__super__
.
render
.
apply
(
this
,
arguments
);
await
view
.
model
.
fetchArchivedMessages
({
'
before
'
:
stanza_id
});
if
(
!
this
.
disable_mam
)
{
}
else
{
this
.
content
.
addEventListener
(
'
scroll
'
,
debounce
(
this
.
onScroll
.
bind
(
this
),
100
));
await
view
.
model
.
fetchArchivedMessages
({
'
end
'
:
oldest_message
.
get
(
'
time
'
)});
}
return
result
;
},
async
onScroll
()
{
if
(
this
.
content
.
scrollTop
===
0
&&
this
.
model
.
messages
.
length
)
{
const
oldest_message
=
this
.
model
.
getOldestMessage
();
if
(
oldest_message
)
{
const
by_jid
=
this
.
model
.
get
(
'
jid
'
);
const
stanza_id
=
oldest_message
&&
oldest_message
.
get
(
`stanza_id
${
by_jid
}
`
);
this
.
addSpinner
();
if
(
stanza_id
)
{
await
this
.
model
.
fetchArchivedMessages
({
'
before
'
:
stanza_id
});
}
else
{
await
this
.
model
.
fetchArchivedMessages
({
'
end
'
:
oldest_message
.
get
(
'
time
'
)
});
}
this
.
clearSpinner
();
}
}
view
.
clearSpinner
();
}
}
}
}
},
});
ChatRoomView
:
{
renderChatArea
()
{
const
result
=
this
.
__super__
.
renderChatArea
.
apply
(
this
,
arguments
);
if
(
!
this
.
disable_mam
)
{
this
.
content
.
addEventListener
(
'
scroll
'
,
debounce
(
this
.
onScroll
.
bind
(
this
),
100
));
}
return
result
;
}
}
}
}
});
});
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