1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-30 04:23:07 +03:00

Mark events which fail to send.

This commit is contained in:
Kegan Dougal
2015-06-18 09:32:04 +01:00
parent d74a71cc2d
commit d151ac49f2
6 changed files with 18 additions and 8 deletions

View File

@ -11,5 +11,7 @@ New properties:
New features:
* Local echo. When you send an event using the SDK it will immediately be
added to the timeline with the event.status of `'sending'`. When the event is
finally sent, this status will be removed.
added to the timeline with the event.status of `EventStatus.SENDING`. When
the event is finally sent, this status will be removed.
* Not sent status. When an event fails to send using the SDK, it will have the
`event.status` of `EventStatus.NOT_SENT`.

View File

@ -48,11 +48,11 @@ events for incoming data and state changes. Aside from wrapping the HTTP API, it
that have just been sent will appear in the timeline as 'sending', until it
completes. This is beneficial because it prevents there being a gap between
hitting the send button and having the "remote echo" arrive.
- Mark messages which failed to send as not sent.
Later versions of the SDK will:
- Automatically retry requests to send messages due to network errors.
- Automatically retry requests to send messages due to rate limiting errors.
- Mark events' sent status (e.g. 'not sent').
- Handle queueing of messages.
- Handle pagination.
- Expose a `RoomSummary` which would be suitable for a recents page.

View File

@ -153,9 +153,12 @@ function printLine(event) {
if (event.getSender() === myUserId) {
name = "Me";
separator = ">>>";
if (event.status === "sending") {
if (event.status === sdk.EventStatus.SENDING) {
separator = "...";
}
else if (event.status === sdk.EventStatus.NOT_SENT) {
separator = " x ";
}
}
var body = "";

View File

@ -274,6 +274,10 @@ MatrixClient.prototype.sendEvent = function(roomId, eventType, content, txnId,
localEvent.status = null;
}
}
}, function(err) {
if (localEvent) {
localEvent.status = EventStatus.NOT_SENT;
}
});
};

View File

@ -2,6 +2,8 @@
/** The {@link module:models/event.MatrixEvent|MatrixEvent} class. */
module.exports.MatrixEvent = require("./models/event").MatrixEvent;
/** The {@link module:models/event.EventStatus|EventStatus} enum. */
module.exports.EventStatus = require("./models/event").EventStatus;
/** The {@link module:store/memory.MatrixInMemoryStore|MatrixInMemoryStore} class. */
module.exports.MatrixInMemoryStore = require("./store/memory").MatrixInMemoryStore;
/** The {@link module:http-api.MatrixHttpApi|MatrixHttpApi} class. */

View File

@ -12,11 +12,10 @@
* @enum {string}
*/
module.exports.EventStatus = {
UNKNOWN: "unknown",
SENT: "sent",
/** The event was not sent and will no longer be retried. */
NOT_SENT: "not_sent",
SENDING: "sending",
INCOMING: "incoming"
/** The event is in the process of being sent. */
SENDING: "sending"
};
/**