Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
solid-xmpp-chat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Components
solid-xmpp-chat
Commits
4532b809
Commit
4532b809
authored
4 years ago
by
ubermanu
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: add a plugin to force loading of history when scrolling up
parent
9afc272c
No related branches found
No related tags found
2 merge requests
!103
Update master with beta
,
!100
#216 chat history loss
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/sib-history-scroll.js
+68
-0
68 additions, 0 deletions
src/plugins/sib-history-scroll.js
src/solid-xmpp-chat.js
+12
-1
12 additions, 1 deletion
src/solid-xmpp-chat.js
with
80 additions
and
1 deletion
src/plugins/sib-history-scroll.js
0 → 100644
+
68
−
0
View file @
4532b809
converse
.
plugins
.
add
(
'
sib-history-scroll
'
,
{
overrides
:
{
ChatRoomView
:
{
events
:
{
'
wheel .chat-content__messages
'
:
'
onScrolledUp
'
,
},
},
ChatBoxView
:
{
events
:
{
'
wheel .chat-content__messages
'
:
'
onScrolledUp
'
,
},
/**
* Fetch the old messages if there is no scroll available.
* @param {WheelEvent} ev
*/
onScrolledUp
(
ev
)
{
const
scrollable
=
this
.
msgs_container
.
clientHeight
<
this
.
msgs_container
.
scrollHeight
if
(
ev
.
deltaY
<
0
&&
!
scrollable
)
{
const
_converse
=
this
.
__super__
.
_converse
;
_converse
.
api
.
trigger
(
'
chatBoxScrolledUp
'
,
this
);
converse
.
env
.
utils
.
safeSave
(
this
.
model
,
{
scrolled
:
true
,
scrollTop
:
0
,
});
}
},
/**
* Fix the scroll event when contained in the <solid-xmpp-chat> element.
* Replace the ev.target with the first element in composed path.
*
* @param {Event} ev
* @private
*/
_markScrolled
:
function
(
ev
)
{
const
_converse
=
this
.
__super__
.
_converse
;
let
scrolled
=
true
;
let
scrollTop
=
null
;
const
is_at_bottom
=
this
.
msgs_container
.
scrollTop
+
this
.
msgs_container
.
clientHeight
>=
this
.
msgs_container
.
scrollHeight
;
// TODO: use composed path
const
target
=
ev
.
target
||
ev
.
path
[
0
];
if
(
is_at_bottom
)
{
scrolled
=
false
;
this
.
onScrolledDown
();
}
else
if
(
this
.
msgs_container
.
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 => { ... });
*/
_converse
.
api
.
trigger
(
'
chatBoxScrolledUp
'
,
this
);
}
else
{
scrollTop
=
target
?.
scrollTop
;
}
converse
.
env
.
utils
.
safeSave
(
this
.
model
,
{
scrolled
,
scrollTop
});
}
}
}
});
This diff is collapsed.
Click to expand it.
src/solid-xmpp-chat.js
+
12
−
1
View file @
4532b809
import
'
./conversejs/converse.min.js
'
;
import
'
./conversejs/converse.min.js
'
;
import
'
./conversejs/emojis.js
'
;
import
'
./conversejs/emojis.js
'
;
import
'
./plugins/converse-rai.js
'
;
import
'
./plugins/converse-rai.js
'
;
import
'
./plugins/sib-history-scroll.js
'
import
{
Sib
,
store
,
StoreMixin
}
from
'
https://cdn.skypack.dev/@startinblox/core@0.15
'
;
import
{
Sib
,
store
,
StoreMixin
}
from
'
https://cdn.skypack.dev/@startinblox/core@0.15
'
;
import
ComponentPath
from
'
./path.js
'
;
import
ComponentPath
from
'
./path.js
'
;
...
@@ -426,7 +427,17 @@ export const SolidXMPPChat = {
...
@@ -426,7 +427,17 @@ export const SolidXMPPChat = {
fileupload
:
true
,
// Not working in current Converse
fileupload
:
true
,
// Not working in current Converse
toggle_occupants
:
false
toggle_occupants
:
false
},
},
'
whitelisted_plugins
'
:
[
'
rai
'
,
'
conversejs-sib-disconnected
'
,
'
conversejs-sib-connected
'
,
'
conversejs-sib-focused
'
,
'
conversejs-changechat
'
,
'
conversejs-rai
'
,
'
custom-hats
'
,
'
remove-notifications
'
],
'
whitelisted_plugins
'
:
[
'
rai
'
,
'
sib-history-scroll
'
,
'
conversejs-sib-disconnected
'
,
'
conversejs-sib-connected
'
,
'
conversejs-sib-focused
'
,
'
conversejs-changechat
'
,
'
conversejs-rai
'
,
'
custom-hats
'
,
'
remove-notifications
'
,
],
});
});
converse_sib
.
loaded_deferred
.
resolve
();
converse_sib
.
loaded_deferred
.
resolve
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment