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
ebd17979
Commit
ebd17979
authored
Mar 07, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call `save` only once when updating a cached message
parent
b51d98d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
24 deletions
+43
-24
dist/converse.js
dist/converse.js
+25
-13
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+9
-0
src/headless/converse-mam.js
src/headless/converse-mam.js
+5
-4
src/headless/converse-muc.js
src/headless/converse-muc.js
+4
-7
No files found.
dist/converse.js
View file @
ebd17979
...
...
@@ -61911,7 +61911,20 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
return this.vcard.get('fullname') || this.get('jid');
},
updateMessage(message, stanza) {// Overridden in converse-muc and converse-mam
getUpdatedMessageAttributes(message, stanza) {
// Overridden in converse-muc and converse-mam
return {};
},
updateMessage(message, stanza) {
// Overridden in converse-muc and converse-mam
const attrs = this.getUpdatedMessageAttributes(message, stanza);
if (attrs) {
message.save(attrs, {
'patch': true
});
}
},
handleMessageCorrection(stanza) {
...
...
@@ -65754,14 +65767,16 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-mam
return message;
},
updateMessage
(message, stanza) {
this.__super__.updateMessage
.apply(this, arguments);
getUpdatedMessageAttributes
(message, stanza) {
const attrs = this.__super__.getUpdatedMessageAttributes
.apply(this, arguments);
if (message && !message.get('is_archived')) {
message.save(_.extend(
{
return _.extend(attrs,
{
'is_archived': this.isArchived(stanza)
}, this.getStanzaIDs(stanza))
)
;
}, this.getStanzaIDs(stanza));
}
return attrs;
}
},
...
...
@@ -67388,17 +67403,14 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
return is_csn && (attrs.is_delayed || own_message);
},
updateMessage(message, stanza) {
/* Make sure that the already cached message is updated with
* the stanza ID.
*/
_converse.ChatBox.prototype.updateMessage.call(this, message, stanza);
getUpdatedMessageAttributes(message, stanza) {
// Overridden in converse-muc and converse-mam
const attrs = _converse.ChatBox.prototype.getUpdatedMessageAttributes.call(this, message, stanza);
const from = stanza.getAttribute('from');
const own_message = Strophe.getResourceFromJid(from) == this.get('nick');
if (own_message) {
const attrs = {};
const stanza_id = sizzle(`stanza-id[xmlns="${Strophe.NS.SID}"]`, stanza).pop();
const by_jid = stanza_id ? stanza_id.getAttribute('by') : undefined;
...
...
@@ -67410,9 +67422,9 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
if (!message.get('received')) {
attrs.received = moment().format();
}
message.save(attrs);
}
return attrs;
},
async onMessage(stanza) {
src/headless/converse-chatboxes.js
View file @
ebd17979
...
...
@@ -290,8 +290,17 @@ converse.plugins.add('converse-chatboxes', {
return
this
.
vcard
.
get
(
'
fullname
'
)
||
this
.
get
(
'
jid
'
);
},
getUpdatedMessageAttributes
(
message
,
stanza
)
{
// Overridden in converse-muc and converse-mam
return
{};
},
updateMessage
(
message
,
stanza
)
{
// Overridden in converse-muc and converse-mam
const
attrs
=
this
.
getUpdatedMessageAttributes
(
message
,
stanza
);
if
(
attrs
)
{
message
.
save
(
attrs
,
{
'
patch
'
:
true
});
}
},
handleMessageCorrection
(
stanza
)
{
...
...
src/headless/converse-mam.js
View file @
ebd17979
...
...
@@ -142,13 +142,14 @@ converse.plugins.add('converse-mam', {
},
updateMessage
(
message
,
stanza
)
{
this
.
__super__
.
updateMessage
.
apply
(
this
,
arguments
);
getUpdatedMessageAttributes
(
message
,
stanza
)
{
const
attrs
=
this
.
__super__
.
getUpdatedMessageAttributes
.
apply
(
this
,
arguments
);
if
(
message
&&
!
message
.
get
(
'
is_archived
'
))
{
message
.
save
(
_
.
extend
(
{
return
_
.
extend
(
attrs
,
{
'
is_archived
'
:
this
.
isArchived
(
stanza
)
},
this
.
getStanzaIDs
(
stanza
))
);
},
this
.
getStanzaIDs
(
stanza
))
}
return
attrs
;
}
},
...
...
src/headless/converse-muc.js
View file @
ebd17979
...
...
@@ -1000,15 +1000,12 @@ converse.plugins.add('converse-muc', {
return
is_csn
&&
(
attrs
.
is_delayed
||
own_message
);
},
updateMessage
(
message
,
stanza
)
{
/* Make sure that the already cached message is updated with
* the stanza ID.
*/
_converse
.
ChatBox
.
prototype
.
updateMessage
.
call
(
this
,
message
,
stanza
);
getUpdatedMessageAttributes
(
message
,
stanza
)
{
// Overridden in converse-muc and converse-mam
const
attrs
=
_converse
.
ChatBox
.
prototype
.
getUpdatedMessageAttributes
.
call
(
this
,
message
,
stanza
);
const
from
=
stanza
.
getAttribute
(
'
from
'
);
const
own_message
=
Strophe
.
getResourceFromJid
(
from
)
==
this
.
get
(
'
nick
'
);
if
(
own_message
)
{
const
attrs
=
{};
const
stanza_id
=
sizzle
(
`stanza-id[xmlns="
${
Strophe
.
NS
.
SID
}
"]`
,
stanza
).
pop
();
const
by_jid
=
stanza_id
?
stanza_id
.
getAttribute
(
'
by
'
)
:
undefined
;
if
(
by_jid
)
{
...
...
@@ -1018,8 +1015,8 @@ converse.plugins.add('converse-muc', {
if
(
!
message
.
get
(
'
received
'
))
{
attrs
.
received
=
moment
().
format
();
}
message
.
save
(
attrs
);
}
return
attrs
;
},
async
onMessage
(
stanza
)
{
...
...
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