Commit 80c955f2 authored by JC Brand's avatar JC Brand

Fix "retry" feature for message errors.

By registering a one-time event handler for a unique event name
parent 3f7e5e29
......@@ -3234,7 +3234,8 @@
"dependencies": {
"filesize": {
"version": "6.1.0",
"resolved": false
"resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz",
"integrity": "sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg=="
},
"fs-extra": {
"version": "8.1.0",
......@@ -3268,7 +3269,8 @@
},
"jed": {
"version": "1.1.1",
"resolved": false
"resolved": "https://registry.npmjs.org/jed/-/jed-1.1.1.tgz",
"integrity": "sha1-elSbvZ/+FYWwzQoZHiAwVb7ldLQ="
},
"jsonfile": {
"version": "5.0.0",
......@@ -3289,7 +3291,8 @@
},
"localforage": {
"version": "1.7.3",
"resolved": false,
"resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz",
"integrity": "sha512-1TulyYfc4udS7ECSBT2vwJksWbkwwTX8BzeUIiq8Y07Riy7bDAAnxDaPU/tWyOVmQAcWJIEIFP9lPfBGqVoPgQ==",
"requires": {
"lie": "3.1.1"
}
......@@ -3301,13 +3304,14 @@
},
"pluggable.js": {
"version": "2.0.1",
"resolved": false,
"resolved": "https://registry.npmjs.org/pluggable.js/-/pluggable.js-2.0.1.tgz",
"integrity": "sha512-SBt6v6Tbp20Jf8hU0cpcc/+HBHGMY8/Q+yA6Ih0tBQE8tfdZ6U4PRG0iNvUUjLx/hVyOP53n0UfGBymlfaaXCg==",
"requires": {
"lodash": "^4.17.11"
}
},
"skeletor.js": {
"version": "0.0.1",
"version": "github:skeletorjs/skeletor#bf6d9c86f9fcf224fa9d9af5a25380b77aa4b561",
"from": "github:skeletorjs/skeletor#bf6d9c86f9fcf224fa9d9af5a25380b77aa4b561",
"requires": {
"lodash": "^4.17.14"
......@@ -3315,11 +3319,13 @@
},
"strophe.js": {
"version": "1.3.4",
"resolved": false
"resolved": "https://registry.npmjs.org/strophe.js/-/strophe.js-1.3.4.tgz",
"integrity": "sha512-jSLDG8jolhAwGOSgiJ7DTMSYK3wVoEJHKtpVRyEacQZ6CWA6z2WRPJpcFMjsIweq5aP9/XIvKUQqHBu/ZhvESA=="
},
"twemoji": {
"version": "12.1.5",
"resolved": false,
"resolved": "https://registry.npmjs.org/twemoji/-/twemoji-12.1.5.tgz",
"integrity": "sha512-B0PBVy5xomwb1M/WZxf/IqPZfnoIYy1skXnlHjMwLwTNfZ9ljh8VgWQktAPcJXu8080WoEh6YwQGPVhDVqvrVQ==",
"requires": {
"fs-extra": "^8.0.1",
"jsonfile": "^5.0.0",
......
......@@ -1065,8 +1065,6 @@ describe("Chatboxes", function () {
`</query>`+
`</iq>`);
await u.waitUntil(() => view.el.querySelector('converse-chat-message .spinner'), 1000);
const msg1 = $msg({'id':'aeb212', 'to': contact_jid})
.c('result', {'xmlns': 'urn:xmpp:mam:2', 'queryid': queryid, 'id':'28482-98726-73623'})
.c('forwarded', {'xmlns':'urn:xmpp:forward:0'})
......
......@@ -14,7 +14,6 @@ const tpl_message = (o) => html`
.chatview=${o.chatview}
.hats=${o.hats}
.model=${o.model}
?allow_retry=${o.retry}
?correcting=${o.correcting}
?editable=${o.editable}
?has_mentions=${o.has_mentions}
......@@ -44,6 +43,7 @@ const tpl_message = (o) => html`
progress=${o.progress || 0 }
reason=${o.reason || ''}
received=${o.received || ''}
retry_event_id=${o.retry_event_id || ''}
sender=${o.sender}
spoiler_hint=${o.spoiler_hint || ''}
subject=${o.subject || ''}
......
......@@ -24,16 +24,15 @@ class Message extends CustomElement {
static get properties () {
return {
allow_retry: { type: Boolean },
chatview: { type: Object},
correcting: { type: Boolean },
editable: { type: Boolean },
edited: { type: String },
error: { type: String },
error_text: { type: String },
from: { type: String },
has_mentions: { type: Boolean },
hats: { type: Array },
edited: { type: String },
is_delayed: { type: Boolean },
is_encrypted: { type: Boolean },
is_first_unread: { type: Boolean },
......@@ -54,6 +53,7 @@ class Message extends CustomElement {
reason: { type: String },
received: { type: String },
retractable: { type: Boolean },
retry_event_id: { type: String },
sender: { type: String },
show_spinner: { type: Boolean },
spoiler_hint: { type: String },
......@@ -104,7 +104,7 @@ class Message extends CustomElement {
</div>
${ this.reason ? html`<q class="reason">${this.reason}</q>` : `` }
${ this.error_text ? html`<q class="reason">${this.error_text}</q>` : `` }
${ this.allow_retry ? html`<a class="retry" @click=${this.onRetryClicked}>${i18n_retry}</a>` : '' }
${ this.retry_event_id ? html`<a class="retry" @click=${this.onRetryClicked}>${i18n_retry}</a>` : '' }
</div>
`;
}
......@@ -144,7 +144,7 @@ class Message extends CustomElement {
async onRetryClicked () {
this.show_spinner = true;
await this.model.error.retry();
await api.trigger(this.retry_event_id, {'synchronous': true});
this.model.destroy();
this.parentElement.removeChild(this);
}
......
......@@ -543,7 +543,7 @@ converse.plugins.add('converse-chat', {
const msg = await this.createMessage({
'type': 'error',
'message': error.message,
'retry': true
'retry_event_id': error.retry_event_id
});
msg.error = error;
}
......
......@@ -63,7 +63,8 @@ const MAMEnabledChat = {
result.messages.forEach(m => this.queueMessage(m));
if (result.error) {
result.error.retry = () => this.fetchArchivedMessages(options, page_direction);
const event_id = result.error.retry_event_id = u.getUniqueId();
api.listen.once(event_id, () => this.fetchArchivedMessages(options, page_direction));
this.createMessageFromError(result.error);
}
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment