Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -14,42 +14,54 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixEvent, EventStatus } from 'matrix-js-sdk/src/models/event';
|
||||
import { Room } from 'matrix-js-sdk/src/models/room';
|
||||
import { MatrixEvent, EventStatus } from "matrix-js-sdk/src/models/event";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { MatrixClientPeg } from './MatrixClientPeg';
|
||||
import dis from './dispatcher/dispatcher';
|
||||
import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||
import dis from "./dispatcher/dispatcher";
|
||||
|
||||
export default class Resend {
|
||||
public static resendUnsentEvents(room: Room): Promise<void[]> {
|
||||
return Promise.all(room.getPendingEvents().filter(function(ev: MatrixEvent) {
|
||||
return ev.status === EventStatus.NOT_SENT;
|
||||
}).map(function(event: MatrixEvent) {
|
||||
return Resend.resend(event);
|
||||
}));
|
||||
return Promise.all(
|
||||
room
|
||||
.getPendingEvents()
|
||||
.filter(function (ev: MatrixEvent) {
|
||||
return ev.status === EventStatus.NOT_SENT;
|
||||
})
|
||||
.map(function (event: MatrixEvent) {
|
||||
return Resend.resend(event);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public static cancelUnsentEvents(room: Room): void {
|
||||
room.getPendingEvents().filter(function(ev: MatrixEvent) {
|
||||
return ev.status === EventStatus.NOT_SENT;
|
||||
}).forEach(function(event: MatrixEvent) {
|
||||
Resend.removeFromQueue(event);
|
||||
});
|
||||
room.getPendingEvents()
|
||||
.filter(function (ev: MatrixEvent) {
|
||||
return ev.status === EventStatus.NOT_SENT;
|
||||
})
|
||||
.forEach(function (event: MatrixEvent) {
|
||||
Resend.removeFromQueue(event);
|
||||
});
|
||||
}
|
||||
|
||||
public static resend(event: MatrixEvent): Promise<void> {
|
||||
const room = MatrixClientPeg.get().getRoom(event.getRoomId());
|
||||
return MatrixClientPeg.get().resendEvent(event, room).then(function(res) {
|
||||
dis.dispatch({
|
||||
action: 'message_sent',
|
||||
event: event,
|
||||
});
|
||||
}, function(err: Error) {
|
||||
// XXX: temporary logging to try to diagnose
|
||||
// https://github.com/vector-im/element-web/issues/3148
|
||||
logger.log('Resend got send failure: ' + err.name + '(' + err + ')');
|
||||
});
|
||||
return MatrixClientPeg.get()
|
||||
.resendEvent(event, room)
|
||||
.then(
|
||||
function (res) {
|
||||
dis.dispatch({
|
||||
action: "message_sent",
|
||||
event: event,
|
||||
});
|
||||
},
|
||||
function (err: Error) {
|
||||
// XXX: temporary logging to try to diagnose
|
||||
// https://github.com/vector-im/element-web/issues/3148
|
||||
logger.log("Resend got send failure: " + err.name + "(" + err + ")");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public static removeFromQueue(event: MatrixEvent): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue