You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Add MatrixClient.resendEvent to manually resend an event that was not sent.
Bundle txnId as MatrixEvent._txnId instead of exposing it to every place that happens to need it (since it's so tightly coupled with MatrixEvent)
This commit is contained in:
@ -53,6 +53,24 @@ rl.on('line', function(line) {
|
||||
else if (line === "/members" && viewingRoom) {
|
||||
printMemberList();
|
||||
}
|
||||
else if (line === "/resend" && viewingRoom) {
|
||||
// get the oldest not sent event.
|
||||
var notSentEvent;
|
||||
for (var i = 0; i < viewingRoom.timeline.length; i++) {
|
||||
if (viewingRoom.timeline[i].status == sdk.EventStatus.NOT_SENT) {
|
||||
notSentEvent = viewingRoom.timeline[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (notSentEvent) {
|
||||
matrixClient.resendEvent(notSentEvent, viewingRoom).done(function() {
|
||||
printMessages();
|
||||
rl.prompt();
|
||||
}, function(err) {
|
||||
console.log("/resend Error: %s", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (line.indexOf("/more ") === 0 && viewingRoom) {
|
||||
var amount = parseInt(line.split(" ")[1]) || 20;
|
||||
matrixClient.scrollback(viewingRoom, amount).done(function(room) {
|
||||
@ -66,15 +84,11 @@ rl.on('line', function(line) {
|
||||
printHelp();
|
||||
}
|
||||
else if (viewingRoom) {
|
||||
matrixClient.sendTextMessage(viewingRoom.roomId, line).done(function() {
|
||||
console.log(CLEAR_CONSOLE);
|
||||
matrixClient.sendTextMessage(viewingRoom.roomId, line).finally(function() {
|
||||
printMessages();
|
||||
rl.prompt();
|
||||
}, function(err) {
|
||||
console.log("Error: %s", err);
|
||||
});
|
||||
// print local echo immediately
|
||||
console.log(CLEAR_CONSOLE);
|
||||
printMessages();
|
||||
}
|
||||
rl.prompt();
|
||||
@ -127,11 +141,12 @@ function printHelp() {
|
||||
console.log(" '/exit' Return to the room list index.");
|
||||
console.log(" '/members' Show the room member list.");
|
||||
console.log(" '/more 15' Scrollback 15 events");
|
||||
console.log(" '/resend' Resend the oldest event which failed to send.");
|
||||
}
|
||||
|
||||
function completer(line) {
|
||||
var completions = [
|
||||
"/help", "/join ", "/exit", "/members", "/more "
|
||||
"/help", "/join ", "/exit", "/members", "/more ", "/resend"
|
||||
];
|
||||
var hits = completions.filter(function(c) { return c.indexOf(line) == 0 });
|
||||
// show all completions if none found
|
||||
|
Reference in New Issue
Block a user