Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

get rid of bluebird #3593

Merged
merged 5 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
],
"transform-class-properties",
"transform-object-rest-spread",
"transform-async-to-bluebird",
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
"transform-runtime",
"add-module-exports",
"syntax-dynamic-import"
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"dependencies": {
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-runtime": "^6.26.0",
"bluebird": "^3.5.0",
"blueimp-canvas-to-blob": "^3.5.0",
"browser-encrypt-attachment": "^0.3.0",
"browser-request": "^0.3.3",
Expand Down Expand Up @@ -120,7 +119,6 @@
"babel-eslint": "^10.0.1",
"babel-loader": "^7.1.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-async-to-bluebird": "^1.1.1",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
Expand Down
1 change: 0 additions & 1 deletion src/ContentMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.

'use strict';

import Promise from 'bluebird';
import extend from './extend';
import dis from './dispatcher';
import MatrixClientPeg from './MatrixClientPeg';
Expand Down
5 changes: 2 additions & 3 deletions src/Lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import Promise from 'bluebird';
import Matrix from 'matrix-js-sdk';

import MatrixClientPeg from './MatrixClientPeg';
Expand Down Expand Up @@ -525,7 +524,7 @@ export function logout() {
console.log("Failed to call logout API: token will not be invalidated");
onLoggedOut();
},
).done();
);
}

export function softLogout() {
Expand Down Expand Up @@ -614,7 +613,7 @@ export function onLoggedOut() {
// that can occur when components try to use a null client.
dis.dispatch({action: 'on_logged_out'}, true);
stopMatrixClient();
_clearStorage().done();
_clearStorage();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Analytics from './Analytics';
import sdk from './index';
import dis from './dispatcher';
import { _t } from './languageHandler';
import Promise from "bluebird";
import {defer} from "./utils/promise";

const DIALOG_CONTAINER_ID = "mx_Dialog_Container";
Expand Down
2 changes: 1 addition & 1 deletion src/Notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const Notifier = {

if (enable) {
// Attempt to get permission from user
plaf.requestNotificationPermission().done((result) => {
plaf.requestNotificationPermission().then((result) => {
if (result !== 'granted') {
// The permission request was dismissed or denied
// TODO: Support alternative branding in messaging
Expand Down
2 changes: 1 addition & 1 deletion src/Resend.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
},
resend: function(event) {
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({
action: 'message_sent',
event: event,
Expand Down
1 change: 0 additions & 1 deletion src/RoomNotifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.

import MatrixClientPeg from './MatrixClientPeg';
import PushProcessor from 'matrix-js-sdk/lib/pushprocessor';
import Promise from 'bluebird';

export const ALL_MESSAGES_LOUD = 'all_messages_loud';
export const ALL_MESSAGES = 'all_messages';
Expand Down
1 change: 0 additions & 1 deletion src/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
*/

import MatrixClientPeg from './MatrixClientPeg';
import Promise from 'bluebird';

/**
* Given a room object, return the alias we should use for it,
Expand Down
1 change: 0 additions & 1 deletion src/ScalarAuthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
*/

import url from 'url';
import Promise from 'bluebird';
import SettingsStore from "./settings/SettingsStore";
import { Service, startTermsFlow, TermsNotSignedError } from './Terms';
const request = require('browser-request');
Expand Down
8 changes: 4 additions & 4 deletions src/ScalarMessaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function inviteUser(event, roomId, userId) {
}
}

client.invite(roomId, userId).done(function() {
client.invite(roomId, userId).then(function() {
sendResponse(event, {
success: true,
});
Expand Down Expand Up @@ -398,7 +398,7 @@ function setPlumbingState(event, roomId, status) {
sendError(event, _t('You need to be logged in.'));
return;
}
client.sendStateEvent(roomId, "m.room.plumbing", { status: status }).done(() => {
client.sendStateEvent(roomId, "m.room.plumbing", { status: status }).then(() => {
sendResponse(event, {
success: true,
});
Expand All @@ -414,7 +414,7 @@ function setBotOptions(event, roomId, userId) {
sendError(event, _t('You need to be logged in.'));
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, {
success: true,
});
Expand Down Expand Up @@ -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, {
success: true,
});
Expand Down
1 change: 0 additions & 1 deletion src/SlashCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { linkifyAndSanitizeHtml } from './HtmlUtils';
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
import WidgetUtils from "./utils/WidgetUtils";
import {textToHtmlRainbow} from "./utils/colour";
import Promise from "bluebird";
import { getAddressType } from './UserAddress';
import { abbreviateUrl } from './utils/UrlUtils';
import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from './utils/IdentityServerUtils';
Expand Down
1 change: 0 additions & 1 deletion src/Terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import Promise from 'bluebird';
import classNames from 'classnames';

import MatrixClientPeg from './MatrixClientPeg';
Expand Down
2 changes: 0 additions & 2 deletions src/ToWidgetPostMessageApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import Promise from "bluebird";

// const OUTBOUND_API_NAME = 'toWidget';

// Initiate requests using the "toWidget" postMessage API and handle responses
Expand Down
1 change: 0 additions & 1 deletion src/VectorConferenceHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import Promise from 'bluebird';
import {createNewMatrixCall, Room} from "matrix-js-sdk";
import CallHandler from './CallHandler';
import MatrixClientPeg from "./MatrixClientPeg";
Expand Down
1 change: 0 additions & 1 deletion src/autocomplete/Autocompleter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import RoomProvider from './RoomProvider';
import UserProvider from './UserProvider';
import EmojiProvider from './EmojiProvider';
import NotifProvider from './NotifProvider';
import Promise from 'bluebird';
import {timeout} from "../utils/promise";

export type SelectionRange = {
Expand Down
5 changes: 2 additions & 3 deletions src/components/structures/GroupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ limitations under the License.
import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import MatrixClientPeg from '../../MatrixClientPeg';
import sdk from '../../index';
import dis from '../../dispatcher';
Expand Down Expand Up @@ -637,7 +636,7 @@ export default createReactClass({
title: _t('Error'),
description: _t('Failed to upload image'),
});
}).done();
});
},

_onJoinableChange: function(ev) {
Expand Down Expand Up @@ -676,7 +675,7 @@ export default createReactClass({
this.setState({
avatarChanged: false,
});
}).done();
});
},

_saveGroup: async function() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/InteractiveAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default createReactClass({
this.setState({
errorText: msg,
});
}).done();
});

this._intervalId = null;
if (this.props.poll) {
Expand Down
14 changes: 4 additions & 10 deletions src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import Promise from 'bluebird';

import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -63,10 +61,6 @@ import { setTheme } from "../../theme";
import { storeRoomAliasInCache } from '../../RoomAliasCache';
import { defer } from "../../utils/promise";

// Disable warnings for now: we use deprecated bluebird functions
// and need to migrate, but they spam the console with warnings.
Promise.config({warnings: false});

/** constants for MatrixChat.state.view */
const VIEWS = {
// a special initial state which is only used at startup, while we are
Expand Down Expand Up @@ -542,7 +536,7 @@ export default createReactClass({
const Loader = sdk.getComponent("elements.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();
if (this.state.currentRoomId === payload.room_id) {
dis.dispatch({action: 'view_next_room'});
Expand Down Expand Up @@ -863,7 +857,7 @@ export default createReactClass({
waitFor = this.firstSyncPromise.promise;
}

waitFor.done(() => {
waitFor.then(() => {
let presentedId = roomInfo.room_alias || roomInfo.room_id;
const room = MatrixClientPeg.get().getRoom(roomInfo.room_id);
if (room) {
Expand Down Expand Up @@ -980,7 +974,7 @@ export default createReactClass({

const [shouldCreate, createOpts] = await modal.finished;
if (shouldCreate) {
createRoom({createOpts}).done();
createRoom({createOpts});
}
},

Expand Down Expand Up @@ -1756,7 +1750,7 @@ export default createReactClass({
return;
}

cli.sendEvent(roomId, event.getType(), event.getContent()).done(() => {
cli.sendEvent(roomId, event.getType(), event.getContent()).then(() => {
dis.dispatch({action: 'message_sent'});
}, (err) => {
dis.dispatch({action: 'message_send_failed'});
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/MyGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default createReactClass({
},

_fetch: function() {
this.context.matrixClient.getJoinedGroups().done((result) => {
this.context.matrixClient.getJoinedGroups().then((result) => {
this.setState({groups: result.groups, error: null});
}, (err) => {
if (err.errcode === 'M_GUEST_ACCESS_FORBIDDEN') {
Expand Down
9 changes: 4 additions & 5 deletions src/components/structures/RoomDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const dis = require('../../dispatcher');

import { linkifyAndSanitizeHtml } from '../../HtmlUtils';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import { _t } from '../../languageHandler';
import { instanceForInstanceId, protocolNameForInstanceId } from '../../utils/DirectoryUtils';
import Analytics from '../../Analytics';
Expand Down Expand Up @@ -89,7 +88,7 @@ module.exports = createReactClass({
this.setState({protocolsLoading: false});
return;
}
MatrixClientPeg.get().getThirdpartyProtocols().done((response) => {
MatrixClientPeg.get().getThirdpartyProtocols().then((response) => {
this.protocols = response;
this.setState({protocolsLoading: false});
}, (err) => {
Expand Down Expand Up @@ -135,7 +134,7 @@ module.exports = createReactClass({
publicRooms: [],
loading: true,
});
this.getMoreRooms().done();
this.getMoreRooms();
},

getMoreRooms: function() {
Expand Down Expand Up @@ -246,7 +245,7 @@ module.exports = createReactClass({
if (!alias) return;
step = _t('delete the alias.');
return MatrixClientPeg.get().deleteAlias(alias);
}).done(() => {
}).then(() => {
modal.close();
this.refreshRoomList();
}, (err) => {
Expand Down Expand Up @@ -348,7 +347,7 @@ module.exports = createReactClass({
});
return;
}
MatrixClientPeg.get().getThirdpartyLocation(protocolName, fields).done((resp) => {
MatrixClientPeg.get().getThirdpartyLocation(protocolName, fields).then((resp) => {
if (resp.length > 0 && resp[0].alias) {
this.showRoomAlias(resp[0].alias, true);
} else {
Expand Down
9 changes: 4 additions & 5 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import React from 'react';
import createReactClass from 'create-react-class';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import classNames from 'classnames';
import {Room} from "matrix-js-sdk";
import { _t } from '../../languageHandler';
Expand Down Expand Up @@ -1101,7 +1100,7 @@ module.exports = createReactClass({
}

ContentMessages.sharedInstance().sendStickerContentToRoom(url, this.state.room.roomId, info, text, MatrixClientPeg.get())
.done(undefined, (error) => {
.then(undefined, (error) => {
if (error.name === "UnknownDeviceError") {
// Let the staus bar handle this
return;
Expand Down Expand Up @@ -1145,7 +1144,7 @@ module.exports = createReactClass({
filter: filter,
term: term,
});
this._handleSearchResult(searchPromise).done();
this._handleSearchResult(searchPromise);
},

_handleSearchResult: function(searchPromise) {
Expand Down Expand Up @@ -1316,7 +1315,7 @@ module.exports = createReactClass({
},

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' });
}, function(err) {
const errCode = err.errcode || _t("unknown error code");
Expand All @@ -1333,7 +1332,7 @@ module.exports = createReactClass({
this.setState({
rejecting: true,
});
MatrixClientPeg.get().leave(this.state.roomId).done(function() {
MatrixClientPeg.get().leave(this.state.roomId).then(function() {
dis.dispatch({ action: 'view_next_room' });
self.setState({
rejecting: false,
Expand Down
1 change: 0 additions & 1 deletion src/components/structures/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
import React from "react";
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import { KeyCode } from '../../Keyboard';
import Timer from '../../utils/Timer';
import AutoHideScrollbar from "./AutoHideScrollbar";
Expand Down
3 changes: 1 addition & 2 deletions src/components/structures/TimelinePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import React from 'react';
import createReactClass from 'create-react-class';
import ReactDOM from "react-dom";
import PropTypes from 'prop-types';
import Promise from 'bluebird';

const Matrix = require("matrix-js-sdk");
const EventTimeline = Matrix.EventTimeline;
Expand Down Expand Up @@ -462,7 +461,7 @@ const TimelinePanel = createReactClass({
// timeline window.
//
// 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; }

const { events, liveEvents } = this._getEvents();
Expand Down
Loading