Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
RocketChat
Rocket.Chat
Commits
c3962ec0
Unverified
Commit
c3962ec0
authored
4 years ago
by
Guilherme Gazzo
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] Jump to message (#20265)
parent
0872682d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/ui-utils/client/lib/RoomHistoryManager.js
+22
-10
22 additions, 10 deletions
app/ui-utils/client/lib/RoomHistoryManager.js
app/ui-utils/client/lib/openRoom.js
+5
-2
5 additions, 2 deletions
app/ui-utils/client/lib/openRoom.js
with
27 additions
and
12 deletions
app/ui-utils/client/lib/RoomHistoryManager.js
+
22
−
10
View file @
c3962ec0
...
...
@@ -33,6 +33,21 @@ export const normalizeThreadMessage = ({ ...message }) => {
}
};
const
waitUntilWrapperExists
=
async
()
=>
document
.
querySelector
(
'
.messages-box .wrapper
'
)
||
new
Promise
((
resolve
)
=>
{
const
observer
=
new
MutationObserver
(
function
(
mutations
,
obs
)
{
const
element
=
document
.
querySelector
(
'
.messages-box .wrapper
'
);
if
(
element
)
{
obs
.
disconnect
();
// stop observing
return
resolve
(
element
);
}
});
observer
.
observe
(
document
,
{
childList
:
true
,
subtree
:
true
,
});
});
export
const
upsertMessage
=
async
({
msg
,
subscription
,
uid
=
Tracker
.
nonreactive
(()
=>
Meteor
.
userId
())
},
collection
=
ChatMessage
)
=>
{
const
userId
=
msg
.
u
&&
msg
.
u
.
_id
;
...
...
@@ -230,29 +245,26 @@ export const RoomHistoryManager = new class {
}
}
getSurroundingMessages
(
message
,
limit
=
defaultLimit
)
{
async
getSurroundingMessages
(
message
,
limit
=
defaultLimit
)
{
if
(
!
message
||
!
message
.
rid
)
{
return
;
}
const
instance
=
Blaze
.
getView
(
$
(
'
.messages-box .wrapper
'
)[
0
]).
templateInstance
();
const
w
=
await
waitUntilWrapperExists
();
const
instance
=
Blaze
.
getView
(
w
).
templateInstance
();
if
(
ChatMessage
.
findOne
({
_id
:
message
.
_id
,
_hidden
:
{
$ne
:
true
}
}))
{
const
wrapper
=
$
(
'
.messages-box .wrapper
'
);
const
msgElement
=
$
(
`#
${
message
.
_id
}
`
,
wrapper
);
const
msgElement
=
$
(
`#
${
message
.
_id
}
`
,
w
);
if
(
msgElement
.
length
===
0
)
{
return
;
}
const
wrapper
=
$
(
'
.messages-box .wrapper
'
);
const
pos
=
(
wrapper
.
scrollTop
()
+
msgElement
.
offset
().
top
)
-
(
wrapper
.
height
()
/
2
);
wrapper
.
animate
({
scrollTop
:
pos
,
},
500
);
msgElement
.
addClass
(
'
highlight
'
);
setTimeout
(
function
()
{
const
messages
=
wrapper
[
0
];
instance
.
atBottom
=
messages
.
scrollTop
>=
(
messages
.
scrollHeight
-
messages
.
clientHeight
);
});
return
setTimeout
(()
=>
msgElement
.
removeClass
(
'
highlight
'
),
500
);
}
...
...
This diff is collapsed.
Click to expand it.
app/ui-utils/client/lib/openRoom.js
+
5
−
2
View file @
c3962ec0
...
...
@@ -79,7 +79,7 @@ export const openRoom = async function(type, name) {
}
if
(
room
.
_id
===
Session
.
get
(
'
openedRoom
'
))
{
if
(
room
.
_id
===
Session
.
get
(
'
openedRoom
'
)
&&
!
FlowRouter
.
getQueryParam
(
'
msg
'
)
)
{
return
;
}
...
...
@@ -125,13 +125,16 @@ export const openRoom = async function(type, name) {
const
messageId
=
FlowRouter
.
getQueryParam
(
'
msg
'
);
const
msg
=
{
_id
:
messageId
,
rid
:
room
.
_id
};
const
message
=
Messages
.
findOne
({
ss
_id
:
msg
.
_id
})
||
(
await
call
(
'
getMessages
'
,
[
msg
.
_id
]))[
0
];
const
message
=
Messages
.
findOne
({
_id
:
msg
.
_id
})
||
(
await
call
(
'
getMessages
'
,
[
msg
.
_id
]))[
0
];
if
(
message
&&
(
message
.
tmid
||
message
.
tcount
))
{
return
FlowRouter
.
setParams
({
tab
:
'
thread
'
,
context
:
message
.
tmid
||
message
.
_id
});
}
RoomHistoryManager
.
getSurroundingMessages
(
msg
);
FlowRouter
.
setQueryParams
({
msg
:
undefined
,
});
}
return
callbacks
.
run
(
'
enter-room
'
,
sub
);
...
...
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