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
9174be8f
Commit
9174be8f
authored
Dec 09, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Styling: Use only "local" offset for mentions
parent
af2df84f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
src/shared/message/text.js
src/shared/message/text.js
+18
-9
No files found.
src/shared/message/text.js
View file @
9174be8f
...
...
@@ -126,11 +126,12 @@ export class MessageText extends String {
* Look for mentions included as XEP-0372 references and add templates for
* rendering them.
* @param { String } text
* @param { Integer } offset - The index of the passed in text relative to
* the start of the MessageText.
* @param { Integer } local_offset - The index of the passed in text relative to
* the start of this MessageText instance (which is not necessarily the same as the
* offset from the start of the original message stanza's body text).
*/
addMentions
(
text
,
offset
)
{
offset
+=
this
.
offset
;
addMentions
(
text
,
local_
offset
)
{
const
full_offset
=
local_offset
+
this
.
offset
;
if
(
!
this
.
model
.
collection
)
{
// This model doesn't belong to a collection anymore, so it must be
// have been removed in the meantime and can be ignored.
...
...
@@ -139,16 +140,24 @@ export class MessageText extends String {
}
const
nick
=
this
.
model
.
collection
.
chatbox
.
get
(
'
nick
'
);
this
.
model
.
get
(
'
references
'
)?.
forEach
(
ref
=>
{
const
begin
=
Number
(
ref
.
begin
)
-
offset
;
if
(
begin
<
0
||
begin
>=
offset
+
text
.
length
)
{
const
begin
=
Number
(
ref
.
begin
)
-
full_
offset
;
if
(
begin
<
0
||
begin
>=
full_
offset
+
text
.
length
)
{
return
;
}
const
end
=
Number
(
ref
.
end
)
-
offset
;
const
end
=
Number
(
ref
.
end
)
-
full_
offset
;
const
mention
=
text
.
slice
(
begin
,
end
);
if
(
mention
===
nick
)
{
this
.
addTemplateResult
(
begin
+
offset
,
end
+
offset
,
tpl_mention_with_nick
({
mention
}));
this
.
addTemplateResult
(
begin
+
local_offset
,
end
+
local_offset
,
tpl_mention_with_nick
({
mention
})
);
}
else
{
this
.
addTemplateResult
(
begin
+
offset
,
end
+
offset
,
tpl_mention
({
mention
}));
this
.
addTemplateResult
(
begin
+
local_offset
,
end
+
local_offset
,
tpl_mention
({
mention
})
);
}
});
}
...
...
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