s/.done(/.then(/ since modern es6 track unhandled promise exceptions

pull/21833/head
Michael Telatynski 2019-11-12 11:51:23 +00:00
parent 0a21957b2c
commit 09a8fec261
43 changed files with 74 additions and 72 deletions

View File

@ -524,7 +524,7 @@ export function logout() {
console.log("Failed to call logout API: token will not be invalidated"); console.log("Failed to call logout API: token will not be invalidated");
onLoggedOut(); onLoggedOut();
}, },
).done(); ).then();
} }
export function softLogout() { export function softLogout() {
@ -608,7 +608,7 @@ export function onLoggedOut() {
// that can occur when components try to use a null client. // that can occur when components try to use a null client.
dis.dispatch({action: 'on_logged_out'}, true); dis.dispatch({action: 'on_logged_out'}, true);
stopMatrixClient(); stopMatrixClient();
_clearStorage().done(); _clearStorage().then();
} }
/** /**

View File

@ -198,7 +198,7 @@ const Notifier = {
if (enable) { if (enable) {
// Attempt to get permission from user // Attempt to get permission from user
plaf.requestNotificationPermission().done((result) => { plaf.requestNotificationPermission().then((result) => {
if (result !== 'granted') { if (result !== 'granted') {
// The permission request was dismissed or denied // The permission request was dismissed or denied
// TODO: Support alternative branding in messaging // TODO: Support alternative branding in messaging

View File

@ -35,7 +35,7 @@ module.exports = {
}, },
resend: function(event) { resend: function(event) {
const room = MatrixClientPeg.get().getRoom(event.getRoomId()); const room = MatrixClientPeg.get().getRoom(event.getRoomId());
MatrixClientPeg.get().resendEvent(event, room).done(function(res) { MatrixClientPeg.get().resendEvent(event, room).then(function(res) {
dis.dispatch({ dis.dispatch({
action: 'message_sent', action: 'message_sent',
event: event, event: event,

View File

@ -279,7 +279,7 @@ function inviteUser(event, roomId, userId) {
} }
} }
client.invite(roomId, userId).done(function() { client.invite(roomId, userId).then(function() {
sendResponse(event, { sendResponse(event, {
success: true, success: true,
}); });
@ -398,7 +398,7 @@ function setPlumbingState(event, roomId, status) {
sendError(event, _t('You need to be logged in.')); sendError(event, _t('You need to be logged in.'));
return; return;
} }
client.sendStateEvent(roomId, "m.room.plumbing", { status: status }).done(() => { client.sendStateEvent(roomId, "m.room.plumbing", { status: status }).then(() => {
sendResponse(event, { sendResponse(event, {
success: true, success: true,
}); });
@ -414,7 +414,7 @@ function setBotOptions(event, roomId, userId) {
sendError(event, _t('You need to be logged in.')); sendError(event, _t('You need to be logged in.'));
return; return;
} }
client.sendStateEvent(roomId, "m.room.bot.options", event.data.content, "_" + userId).done(() => { client.sendStateEvent(roomId, "m.room.bot.options", event.data.content, "_" + userId).then(() => {
sendResponse(event, { sendResponse(event, {
success: true, success: true,
}); });
@ -444,7 +444,7 @@ function setBotPower(event, roomId, userId, level) {
}, },
); );
client.setPowerLevel(roomId, userId, level, powerEvent).done(() => { client.setPowerLevel(roomId, userId, level, powerEvent).then(() => {
sendResponse(event, { sendResponse(event, {
success: true, success: true,
}); });

View File

@ -639,7 +639,7 @@ export default createReactClass({
title: _t('Error'), title: _t('Error'),
description: _t('Failed to upload image'), description: _t('Failed to upload image'),
}); });
}).done(); }).then();
}, },
_onJoinableChange: function(ev) { _onJoinableChange: function(ev) {
@ -678,7 +678,7 @@ export default createReactClass({
this.setState({ this.setState({
avatarChanged: false, avatarChanged: false,
}); });
}).done(); }).then();
}, },
_saveGroup: async function() { _saveGroup: async function() {

View File

@ -121,7 +121,7 @@ export default createReactClass({
this.setState({ this.setState({
errorText: msg, errorText: msg,
}); });
}).done(); }).then();
this._intervalId = null; this._intervalId = null;
if (this.props.poll) { if (this.props.poll) {

View File

@ -541,7 +541,7 @@ export default createReactClass({
const Loader = sdk.getComponent("elements.Spinner"); const Loader = sdk.getComponent("elements.Spinner");
const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner'); const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner');
MatrixClientPeg.get().leave(payload.room_id).done(() => { MatrixClientPeg.get().leave(payload.room_id).then(() => {
modal.close(); modal.close();
if (this.state.currentRoomId === payload.room_id) { if (this.state.currentRoomId === payload.room_id) {
dis.dispatch({action: 'view_next_room'}); dis.dispatch({action: 'view_next_room'});
@ -862,7 +862,7 @@ export default createReactClass({
waitFor = this.firstSyncPromise.promise; waitFor = this.firstSyncPromise.promise;
} }
waitFor.done(() => { waitFor.then(() => {
let presentedId = roomInfo.room_alias || roomInfo.room_id; let presentedId = roomInfo.room_alias || roomInfo.room_id;
const room = MatrixClientPeg.get().getRoom(roomInfo.room_id); const room = MatrixClientPeg.get().getRoom(roomInfo.room_id);
if (room) { if (room) {
@ -974,7 +974,7 @@ export default createReactClass({
const [shouldCreate, createOpts] = await modal.finished; const [shouldCreate, createOpts] = await modal.finished;
if (shouldCreate) { if (shouldCreate) {
createRoom({createOpts}).done(); createRoom({createOpts}).then();
} }
}, },
@ -1750,7 +1750,7 @@ export default createReactClass({
return; return;
} }
cli.sendEvent(roomId, event.getType(), event.getContent()).done(() => { cli.sendEvent(roomId, event.getType(), event.getContent()).then(() => {
dis.dispatch({action: 'message_sent'}); dis.dispatch({action: 'message_sent'});
}, (err) => { }, (err) => {
dis.dispatch({action: 'message_send_failed'}); dis.dispatch({action: 'message_send_failed'});

View File

@ -47,7 +47,7 @@ export default createReactClass({
}, },
_fetch: function() { _fetch: function() {
this.context.matrixClient.getJoinedGroups().done((result) => { this.context.matrixClient.getJoinedGroups().then((result) => {
this.setState({groups: result.groups, error: null}); this.setState({groups: result.groups, error: null});
}, (err) => { }, (err) => {
if (err.errcode === 'M_GUEST_ACCESS_FORBIDDEN') { if (err.errcode === 'M_GUEST_ACCESS_FORBIDDEN') {

View File

@ -89,7 +89,7 @@ module.exports = createReactClass({
this.setState({protocolsLoading: false}); this.setState({protocolsLoading: false});
return; return;
} }
MatrixClientPeg.get().getThirdpartyProtocols().done((response) => { MatrixClientPeg.get().getThirdpartyProtocols().then((response) => {
this.protocols = response; this.protocols = response;
this.setState({protocolsLoading: false}); this.setState({protocolsLoading: false});
}, (err) => { }, (err) => {
@ -135,7 +135,7 @@ module.exports = createReactClass({
publicRooms: [], publicRooms: [],
loading: true, loading: true,
}); });
this.getMoreRooms().done(); this.getMoreRooms().then();
}, },
getMoreRooms: function() { getMoreRooms: function() {
@ -246,7 +246,7 @@ module.exports = createReactClass({
if (!alias) return; if (!alias) return;
step = _t('delete the alias.'); step = _t('delete the alias.');
return MatrixClientPeg.get().deleteAlias(alias); return MatrixClientPeg.get().deleteAlias(alias);
}).done(() => { }).then(() => {
modal.close(); modal.close();
this.refreshRoomList(); this.refreshRoomList();
}, (err) => { }, (err) => {
@ -348,7 +348,7 @@ module.exports = createReactClass({
}); });
return; return;
} }
MatrixClientPeg.get().getThirdpartyLocation(protocolName, fields).done((resp) => { MatrixClientPeg.get().getThirdpartyLocation(protocolName, fields).then((resp) => {
if (resp.length > 0 && resp[0].alias) { if (resp.length > 0 && resp[0].alias) {
this.showRoomAlias(resp[0].alias, true); this.showRoomAlias(resp[0].alias, true);
} else { } else {

View File

@ -1101,7 +1101,7 @@ module.exports = createReactClass({
} }
ContentMessages.sharedInstance().sendStickerContentToRoom(url, this.state.room.roomId, info, text, MatrixClientPeg.get()) ContentMessages.sharedInstance().sendStickerContentToRoom(url, this.state.room.roomId, info, text, MatrixClientPeg.get())
.done(undefined, (error) => { .then(undefined, (error) => {
if (error.name === "UnknownDeviceError") { if (error.name === "UnknownDeviceError") {
// Let the staus bar handle this // Let the staus bar handle this
return; return;
@ -1145,7 +1145,7 @@ module.exports = createReactClass({
filter: filter, filter: filter,
term: term, term: term,
}); });
this._handleSearchResult(searchPromise).done(); this._handleSearchResult(searchPromise).then();
}, },
_handleSearchResult: function(searchPromise) { _handleSearchResult: function(searchPromise) {
@ -1316,7 +1316,7 @@ module.exports = createReactClass({
}, },
onForgetClick: function() { onForgetClick: function() {
MatrixClientPeg.get().forget(this.state.room.roomId).done(function() { MatrixClientPeg.get().forget(this.state.room.roomId).then(function() {
dis.dispatch({ action: 'view_next_room' }); dis.dispatch({ action: 'view_next_room' });
}, function(err) { }, function(err) {
const errCode = err.errcode || _t("unknown error code"); const errCode = err.errcode || _t("unknown error code");
@ -1333,7 +1333,7 @@ module.exports = createReactClass({
this.setState({ this.setState({
rejecting: true, rejecting: true,
}); });
MatrixClientPeg.get().leave(this.state.roomId).done(function() { MatrixClientPeg.get().leave(this.state.roomId).then(function() {
dis.dispatch({ action: 'view_next_room' }); dis.dispatch({ action: 'view_next_room' });
self.setState({ self.setState({
rejecting: false, rejecting: false,

View File

@ -462,7 +462,7 @@ const TimelinePanel = createReactClass({
// timeline window. // timeline window.
// //
// see https://github.com/vector-im/vector-web/issues/1035 // see https://github.com/vector-im/vector-web/issues/1035
this._timelineWindow.paginate(EventTimeline.FORWARDS, 1, false).done(() => { this._timelineWindow.paginate(EventTimeline.FORWARDS, 1, false).then(() => {
if (this.unmounted) { return; } if (this.unmounted) { return; }
const { events, liveEvents } = this._getEvents(); const { events, liveEvents } = this._getEvents();
@ -1088,7 +1088,7 @@ const TimelinePanel = createReactClass({
prom = prom.then(onLoaded, onError); prom = prom.then(onLoaded, onError);
} }
prom.done(); prom.then();
}, },
// handle the completion of a timeline load or localEchoUpdate, by // handle the completion of a timeline load or localEchoUpdate, by

View File

@ -105,7 +105,7 @@ module.exports = createReactClass({
phase: PHASE_SENDING_EMAIL, phase: PHASE_SENDING_EMAIL,
}); });
this.reset = new PasswordReset(this.props.serverConfig.hsUrl, this.props.serverConfig.isUrl); this.reset = new PasswordReset(this.props.serverConfig.hsUrl, this.props.serverConfig.isUrl);
this.reset.resetPassword(email, password).done(() => { this.reset.resetPassword(email, password).then(() => {
this.setState({ this.setState({
phase: PHASE_EMAIL_SENT, phase: PHASE_EMAIL_SENT,
}); });

View File

@ -253,7 +253,7 @@ module.exports = createReactClass({
this.setState({ this.setState({
busy: false, busy: false,
}); });
}).done(); }).then();
}, },
onUsernameChanged: function(username) { onUsernameChanged: function(username) {
@ -424,7 +424,7 @@ module.exports = createReactClass({
this.setState({ this.setState({
busy: false, busy: false,
}); });
}).done(); }).then();
}, },
_isSupportedFlow: function(flow) { _isSupportedFlow: function(flow) {

View File

@ -43,7 +43,7 @@ module.exports = createReactClass({
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
this.setState({busy: true}); this.setState({busy: true});
const self = this; const self = this;
cli.getProfileInfo(cli.credentials.userId).done(function(result) { cli.getProfileInfo(cli.credentials.userId).then(function(result) {
self.setState({ self.setState({
avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(result.avatar_url), avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(result.avatar_url),
busy: false, busy: false,

View File

@ -371,7 +371,7 @@ module.exports = createReactClass({
if (pushers[i].kind === 'email') { if (pushers[i].kind === 'email') {
const emailPusher = pushers[i]; const emailPusher = pushers[i];
emailPusher.data = { brand: this.props.brand }; emailPusher.data = { brand: this.props.brand };
matrixClient.setPusher(emailPusher).done(() => { matrixClient.setPusher(emailPusher).then(() => {
console.log("Set email branding to " + this.props.brand); console.log("Set email branding to " + this.props.brand);
}, (error) => { }, (error) => {
console.error("Couldn't set email branding: " + error); console.error("Couldn't set email branding: " + error);

View File

@ -441,7 +441,7 @@ export const MsisdnAuthEntry = createReactClass({
this.props.fail(e); this.props.fail(e);
}).finally(() => { }).finally(() => {
this.setState({requestingToken: false}); this.setState({requestingToken: false});
}).done(); }).then();
}, },
/* /*

View File

@ -161,7 +161,7 @@ module.exports = createReactClass({
_onClickForget: function() { _onClickForget: function() {
// FIXME: duplicated with RoomSettings (and dead code in RoomView) // FIXME: duplicated with RoomSettings (and dead code in RoomView)
MatrixClientPeg.get().forget(this.props.room.roomId).done(() => { MatrixClientPeg.get().forget(this.props.room.roomId).then(() => {
// Switch to another room view if we're currently viewing the // Switch to another room view if we're currently viewing the
// historical room // historical room
if (RoomViewStore.getRoomId() === this.props.room.roomId) { if (RoomViewStore.getRoomId() === this.props.room.roomId) {
@ -191,7 +191,7 @@ module.exports = createReactClass({
this.setState({ this.setState({
roomNotifState: newState, roomNotifState: newState,
}); });
RoomNotifs.setRoomNotifsState(roomId, newState).done(() => { RoomNotifs.setRoomNotifsState(roomId, newState).then(() => {
// delay slightly so that the user can see their state change // delay slightly so that the user can see their state change
// before closing the menu // before closing the menu
return sleep(500).then(() => { return sleep(500).then(() => {

View File

@ -267,7 +267,7 @@ module.exports = createReactClass({
this.setState({ this.setState({
searchError: err.errcode ? err.message : _t('Something went wrong!'), searchError: err.errcode ? err.message : _t('Something went wrong!'),
}); });
}).done(() => { }).then(() => {
this.setState({ this.setState({
busy: false, busy: false,
}); });
@ -380,7 +380,7 @@ module.exports = createReactClass({
// Do a local search immediately // Do a local search immediately
this._doLocalSearch(query); this._doLocalSearch(query);
} }
}).done(() => { }).then(() => {
this.setState({ this.setState({
busy: false, busy: false,
}); });

View File

@ -93,7 +93,7 @@ export default createReactClass({
this.setState({createError: e}); this.setState({createError: e});
}).finally(() => { }).finally(() => {
this.setState({creating: false}); this.setState({creating: false});
}).done(); }).then();
}, },
_onCancel: function() { _onCancel: function() {

View File

@ -78,7 +78,7 @@ export default createReactClass({
true, true,
); );
} }
}).done(); }).then();
}, },
componentWillUnmount: function() { componentWillUnmount: function() {

View File

@ -62,7 +62,7 @@ export default createReactClass({
return; return;
} }
this._addThreepid = new AddThreepid(); this._addThreepid = new AddThreepid();
this._addThreepid.addEmailAddress(emailAddress).done(() => { this._addThreepid.addEmailAddress(emailAddress).then(() => {
Modal.createTrackedDialog('Verification Pending', '', QuestionDialog, { Modal.createTrackedDialog('Verification Pending', '', QuestionDialog, {
title: _t("Verification Pending"), title: _t("Verification Pending"),
description: _t( description: _t(
@ -96,7 +96,7 @@ export default createReactClass({
}, },
verifyEmailAddress: function() { verifyEmailAddress: function() {
this._addThreepid.checkEmailLinkClicked().done(() => { this._addThreepid.checkEmailLinkClicked().then(() => {
this.props.onFinished(true); this.props.onFinished(true);
}, (err) => { }, (err) => {
this.setState({emailBusy: false}); this.setState({emailBusy: false});

View File

@ -205,7 +205,7 @@ export default class AppTile extends React.Component {
if (!this._scalarClient) { if (!this._scalarClient) {
this._scalarClient = defaultManager.getScalarClient(); this._scalarClient = defaultManager.getScalarClient();
} }
this._scalarClient.getScalarToken().done((token) => { this._scalarClient.getScalarToken().then((token) => {
// Append scalar_token as a query param if not already present // Append scalar_token as a query param if not already present
this._scalarClient.scalarToken = token; this._scalarClient.scalarToken = token;
const u = url.parse(this._addWurlParams(this.props.url)); const u = url.parse(this._addWurlParams(this.props.url));

View File

@ -51,7 +51,7 @@ export default class EditableTextContainer extends React.Component {
this.setState({busy: true}); this.setState({busy: true});
this.props.getInitialValue().done( this.props.getInitialValue().then(
(result) => { (result) => {
if (this._unmounted) { return; } if (this._unmounted) { return; }
this.setState({ this.setState({
@ -83,7 +83,7 @@ export default class EditableTextContainer extends React.Component {
errorString: null, errorString: null,
}); });
this.props.onSubmit(value).done( this.props.onSubmit(value).then(
() => { () => {
if (this._unmounted) { return; } if (this._unmounted) { return; }
this.setState({ this.setState({

View File

@ -54,7 +54,7 @@ export default class ErrorBoundary extends React.PureComponent {
if (!PlatformPeg.get()) return; if (!PlatformPeg.get()) return;
MatrixClientPeg.get().stopClient(); MatrixClientPeg.get().stopClient();
MatrixClientPeg.get().store.deleteAllData().done(() => { MatrixClientPeg.get().store.deleteAllData().then(() => {
PlatformPeg.get().reload(); PlatformPeg.get().reload();
}); });
}; };

View File

@ -84,7 +84,7 @@ export default class ImageView extends React.Component {
title: _t('Error'), title: _t('Error'),
description: _t('You cannot delete this image. (%(code)s)', {code: code}), description: _t('You cannot delete this image. (%(code)s)', {code: code}),
}); });
}).done(); }).then();
}, },
}); });
}; };

View File

@ -49,7 +49,7 @@ export default class LanguageDropdown extends React.Component {
this.setState({langs}); this.setState({langs});
}).catch(() => { }).catch(() => {
this.setState({langs: ['en']}); this.setState({langs: ['en']});
}).done(); }).then();
if (!this.props.value) { if (!this.props.value) {
// If no value is given, we start with the first // If no value is given, we start with the first

View File

@ -36,7 +36,7 @@ export default createReactClass({
}, },
componentWillMount: function() { componentWillMount: function() {
this.context.matrixClient.getJoinedGroups().done((result) => { this.context.matrixClient.getJoinedGroups().then((result) => {
this.setState({groups: result.groups || [], error: null}); this.setState({groups: result.groups || [], error: null});
}, (err) => { }, (err) => {
console.error(err); console.error(err);

View File

@ -55,7 +55,7 @@ export default class MAudioBody extends React.Component {
decryptFile(content.file).then(function(blob) { decryptFile(content.file).then(function(blob) {
decryptedBlob = blob; decryptedBlob = blob;
return URL.createObjectURL(decryptedBlob); return URL.createObjectURL(decryptedBlob);
}).done((url) => { }).then((url) => {
this.setState({ this.setState({
decryptedUrl: url, decryptedUrl: url,
decryptedBlob: decryptedBlob, decryptedBlob: decryptedBlob,

View File

@ -289,7 +289,7 @@ export default class MImageBody extends React.Component {
this.setState({ this.setState({
error: err, error: err,
}); });
}).done(); }).then();
} }
// Remember that the user wanted to show this particular image // Remember that the user wanted to show this particular image

View File

@ -115,7 +115,7 @@ module.exports = createReactClass({
this.setState({ this.setState({
error: err, error: err,
}); });
}).done(); }).then();
} }
}, },

View File

@ -870,7 +870,7 @@ const UserInfo = withLegacyMatrixClient(({matrixClient: cli, user, groupId, room
}, },
).finally(() => { ).finally(() => {
stopUpdating(); stopUpdating();
}).done(); }).then();
}; };
const roomId = user.roomId; const roomId = user.roomId;

View File

@ -53,7 +53,7 @@ module.exports = createReactClass({
); );
}, (error)=>{ }, (error)=>{
console.error("Failed to get URL preview: " + error); console.error("Failed to get URL preview: " + error);
}).done(); }).then();
}, },
componentDidMount: function() { componentDidMount: function() {

View File

@ -248,7 +248,7 @@ module.exports = createReactClass({
return client.getStoredDevicesForUser(member.userId); return client.getStoredDevicesForUser(member.userId);
}).finally(function() { }).finally(function() {
self._cancelDeviceList = null; self._cancelDeviceList = null;
}).done(function(devices) { }).then(function(devices) {
if (cancelled) { if (cancelled) {
// we got cancelled - presumably a different user now // we got cancelled - presumably a different user now
return; return;
@ -572,7 +572,7 @@ module.exports = createReactClass({
}, },
).finally(()=>{ ).finally(()=>{
this.setState({ updating: this.state.updating - 1 }); this.setState({ updating: this.state.updating - 1 });
}).done(); }).then();
}, },
onPowerChange: async function(powerLevel) { onPowerChange: async function(powerLevel) {
@ -629,7 +629,7 @@ module.exports = createReactClass({
this.setState({ updating: this.state.updating + 1 }); this.setState({ updating: this.state.updating + 1 });
createRoom({dmUserId: this.props.member.userId}).finally(() => { createRoom({dmUserId: this.props.member.userId}).finally(() => {
this.setState({ updating: this.state.updating - 1 }); this.setState({ updating: this.state.updating - 1 });
}).done(); }).then();
}, },
onLeaveClick: function() { onLeaveClick: function() {

View File

@ -112,7 +112,7 @@ module.exports = createReactClass({
} }
}); });
httpPromise.done(function() { httpPromise.then(function() {
self.setState({ self.setState({
phase: self.Phases.Display, phase: self.Phases.Display,
avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(newUrl), avatarUrl: MatrixClientPeg.get().mxcUrlToHttp(newUrl),

View File

@ -174,7 +174,7 @@ module.exports = createReactClass({
newPassword: "", newPassword: "",
newPasswordConfirm: "", newPasswordConfirm: "",
}); });
}).done(); }).then();
}, },
_optionallySetEmail: function() { _optionallySetEmail: function() {

View File

@ -52,7 +52,7 @@ export default class DevicesPanel extends React.Component {
} }
_loadDevices() { _loadDevices() {
MatrixClientPeg.get().getDevices().done( MatrixClientPeg.get().getDevices().then(
(resp) => { (resp) => {
if (this._unmounted) { return; } if (this._unmounted) { return; }
this.setState({devices: resp.devices || []}); this.setState({devices: resp.devices || []});

View File

@ -97,7 +97,7 @@ module.exports = createReactClass({
phase: this.phases.LOADING, phase: this.phases.LOADING,
}); });
MatrixClientPeg.get().setPushRuleEnabled('global', self.state.masterPushRule.kind, self.state.masterPushRule.rule_id, !checked).done(function() { MatrixClientPeg.get().setPushRuleEnabled('global', self.state.masterPushRule.kind, self.state.masterPushRule.rule_id, !checked).then(function() {
self._refreshFromServer(); self._refreshFromServer();
}); });
}, },
@ -170,7 +170,7 @@ module.exports = createReactClass({
emailPusher.kind = null; emailPusher.kind = null;
emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher); emailPusherPromise = MatrixClientPeg.get().setPusher(emailPusher);
} }
emailPusherPromise.done(() => { emailPusherPromise.then(() => {
this._refreshFromServer(); this._refreshFromServer();
}, (error) => { }, (error) => {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
@ -274,7 +274,7 @@ module.exports = createReactClass({
} }
} }
Promise.all(deferreds).done(function() { Promise.all(deferreds).then(function() {
self._refreshFromServer(); self._refreshFromServer();
}, function(error) { }, function(error) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
@ -343,7 +343,7 @@ module.exports = createReactClass({
} }
} }
Promise.all(deferreds).done(function(resps) { Promise.all(deferreds).then(function(resps) {
self._refreshFromServer(); self._refreshFromServer();
}, function(error) { }, function(error) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
@ -398,7 +398,7 @@ module.exports = createReactClass({
}; };
// Then, add the new ones // Then, add the new ones
Promise.all(removeDeferreds).done(function(resps) { Promise.all(removeDeferreds).then(function(resps) {
const deferreds = []; const deferreds = [];
let pushRuleVectorStateKind = self.state.vectorContentRules.vectorState; let pushRuleVectorStateKind = self.state.vectorContentRules.vectorState;
@ -434,7 +434,7 @@ module.exports = createReactClass({
} }
} }
Promise.all(deferreds).done(function(resps) { Promise.all(deferreds).then(function(resps) {
self._refreshFromServer(); self._refreshFromServer();
}, onError); }, onError);
}, onError); }, onError);
@ -650,7 +650,7 @@ module.exports = createReactClass({
externalContentRules: self.state.externalContentRules, externalContentRules: self.state.externalContentRules,
externalPushRules: self.state.externalPushRules, externalPushRules: self.state.externalPushRules,
}); });
}).done(); }).then();
MatrixClientPeg.get().getThreePids().then((r) => this.setState({threepids: r.threepids})); MatrixClientPeg.get().getThreePids().then((r) => this.setState({threepids: r.threepids}));
}, },

View File

@ -75,7 +75,7 @@ export default class HelpUserSettingsTab extends React.Component {
// stopping in the middle of the logs. // stopping in the middle of the logs.
console.log("Clear cache & reload clicked"); console.log("Clear cache & reload clicked");
MatrixClientPeg.get().stopClient(); MatrixClientPeg.get().stopClient();
MatrixClientPeg.get().store.deleteAllData().done(() => { MatrixClientPeg.get().store.deleteAllData().then(() => {
PlatformPeg.get().reload(); PlatformPeg.get().reload();
}); });
}; };

View File

@ -186,7 +186,7 @@ class RoomViewStore extends Store {
roomLoading: true, roomLoading: true,
roomLoadError: null, roomLoadError: null,
}); });
MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).done( MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).then(
(result) => { (result) => {
dis.dispatch({ dis.dispatch({
action: 'view_room', action: 'view_room',
@ -223,7 +223,7 @@ class RoomViewStore extends Store {
}); });
MatrixClientPeg.get().joinRoom( MatrixClientPeg.get().joinRoom(
this._state.roomAlias || this._state.roomId, payload.opts, this._state.roomAlias || this._state.roomId, payload.opts,
).done(() => { ).then(() => {
// We don't actually need to do anything here: we do *not* // We don't actually need to do anything here: we do *not*
// clear the 'joining' flag because the Room object and/or // clear the 'joining' flag because the Room object and/or
// our 'joined' member event may not have come down the sync // our 'joined' member event may not have come down the sync

View File

@ -26,6 +26,7 @@ import sdk from 'matrix-react-sdk';
import MatrixClientPeg from '../../../../src/MatrixClientPeg'; import MatrixClientPeg from '../../../../src/MatrixClientPeg';
import * as test_utils from '../../../test-utils'; import * as test_utils from '../../../test-utils';
import {sleep} from "../../../../src/utils/promise";
const InteractiveAuthDialog = sdk.getComponent( const InteractiveAuthDialog = sdk.getComponent(
'views.dialogs.InteractiveAuthDialog', 'views.dialogs.InteractiveAuthDialog',
@ -107,7 +108,7 @@ describe('InteractiveAuthDialog', function() {
}, },
})).toBe(true); })).toBe(true);
// let the request complete // let the request complete
return Promise.delay(1); return sleep(1);
}).then(() => { }).then(() => {
expect(onFinished.callCount).toEqual(1); expect(onFinished.callCount).toEqual(1);
expect(onFinished.calledWithExactly(true, {a: 1})).toBe(true); expect(onFinished.calledWithExactly(true, {a: 1})).toBe(true);

View File

@ -91,7 +91,7 @@ describe('MemberEventListSummary', function() {
testUtils.beforeEach(this); testUtils.beforeEach(this);
sandbox = testUtils.stubClient(); sandbox = testUtils.stubClient();
languageHandler.setLanguage('en').done(done); languageHandler.setLanguage('en').then(done);
languageHandler.setMissingEntryGenerator(function(key) { languageHandler.setMissingEntryGenerator(function(key) {
return key.split('|', 2)[1]; return key.split('|', 2)[1];
}); });

View File

@ -8,6 +8,7 @@ import * as testUtils from '../../../test-utils';
import sdk from 'matrix-react-sdk'; import sdk from 'matrix-react-sdk';
const MessageComposerInput = sdk.getComponent('views.rooms.MessageComposerInput'); const MessageComposerInput = sdk.getComponent('views.rooms.MessageComposerInput');
import MatrixClientPeg from '../../../../src/MatrixClientPeg'; import MatrixClientPeg from '../../../../src/MatrixClientPeg';
import {sleep} from "../../../../src/utils/promise";
function addTextToDraft(text) { function addTextToDraft(text) {
const components = document.getElementsByClassName('public-DraftEditor-content'); const components = document.getElementsByClassName('public-DraftEditor-content');
@ -49,7 +50,7 @@ xdescribe('MessageComposerInput', () => {
// warnings // warnings
// (please can we make the components not setState() after // (please can we make the components not setState() after
// they are unmounted?) // they are unmounted?)
Promise.delay(10).done(() => { sleep(10).then(() => {
if (parentDiv) { if (parentDiv) {
ReactDOM.unmountComponentAtNode(parentDiv); ReactDOM.unmountComponentAtNode(parentDiv);
parentDiv.remove(); parentDiv.remove();

View File

@ -11,7 +11,7 @@ describe('languageHandler', function() {
testUtils.beforeEach(this); testUtils.beforeEach(this);
sandbox = testUtils.stubClient(); sandbox = testUtils.stubClient();
languageHandler.setLanguage('en').done(done); languageHandler.setLanguage('en').then(done);
}); });
afterEach(function() { afterEach(function() {