Replace Promise.delay with promise utils sleep
This commit is contained in:
parent
6850c14739
commit
0a21957b2c
4 changed files with 13 additions and 9 deletions
|
@ -38,6 +38,7 @@ import FlairStore from '../../stores/FlairStore';
|
||||||
import { showGroupAddRoomDialog } from '../../GroupAddressPicker';
|
import { showGroupAddRoomDialog } from '../../GroupAddressPicker';
|
||||||
import {makeGroupPermalink, makeUserPermalink} from "../../utils/permalinks/Permalinks";
|
import {makeGroupPermalink, makeUserPermalink} from "../../utils/permalinks/Permalinks";
|
||||||
import {Group} from "matrix-js-sdk";
|
import {Group} from "matrix-js-sdk";
|
||||||
|
import {sleep} from "../../utils/promise";
|
||||||
|
|
||||||
const LONG_DESC_PLACEHOLDER = _td(
|
const LONG_DESC_PLACEHOLDER = _td(
|
||||||
`<h1>HTML for your community's page</h1>
|
`<h1>HTML for your community's page</h1>
|
||||||
|
@ -692,7 +693,7 @@ export default createReactClass({
|
||||||
|
|
||||||
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
||||||
// spinner disappearing after we have fetched new group data.
|
// spinner disappearing after we have fetched new group data.
|
||||||
await Promise.delay(500);
|
await sleep(500);
|
||||||
|
|
||||||
GroupStore.acceptGroupInvite(this.props.groupId).then(() => {
|
GroupStore.acceptGroupInvite(this.props.groupId).then(() => {
|
||||||
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
||||||
|
@ -711,7 +712,7 @@ export default createReactClass({
|
||||||
|
|
||||||
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
||||||
// spinner disappearing after we have fetched new group data.
|
// spinner disappearing after we have fetched new group data.
|
||||||
await Promise.delay(500);
|
await sleep(500);
|
||||||
|
|
||||||
GroupStore.leaveGroup(this.props.groupId).then(() => {
|
GroupStore.leaveGroup(this.props.groupId).then(() => {
|
||||||
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
||||||
|
@ -735,7 +736,7 @@ export default createReactClass({
|
||||||
|
|
||||||
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
||||||
// spinner disappearing after we have fetched new group data.
|
// spinner disappearing after we have fetched new group data.
|
||||||
await Promise.delay(500);
|
await sleep(500);
|
||||||
|
|
||||||
GroupStore.joinGroup(this.props.groupId).then(() => {
|
GroupStore.joinGroup(this.props.groupId).then(() => {
|
||||||
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
||||||
|
@ -787,7 +788,7 @@ export default createReactClass({
|
||||||
|
|
||||||
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
// Wait 500ms to prevent flashing. Do this before sending a request otherwise we risk the
|
||||||
// spinner disappearing after we have fetched new group data.
|
// spinner disappearing after we have fetched new group data.
|
||||||
await Promise.delay(500);
|
await sleep(500);
|
||||||
|
|
||||||
GroupStore.leaveGroup(this.props.groupId).then(() => {
|
GroupStore.leaveGroup(this.props.groupId).then(() => {
|
||||||
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
||||||
|
|
|
@ -32,6 +32,7 @@ import * as RoomNotifs from '../../../RoomNotifs';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import RoomListActions from '../../../actions/RoomListActions';
|
import RoomListActions from '../../../actions/RoomListActions';
|
||||||
import RoomViewStore from '../../../stores/RoomViewStore';
|
import RoomViewStore from '../../../stores/RoomViewStore';
|
||||||
|
import {sleep} from "../../../utils/promise";
|
||||||
|
|
||||||
module.exports = createReactClass({
|
module.exports = createReactClass({
|
||||||
displayName: 'RoomTileContextMenu',
|
displayName: 'RoomTileContextMenu',
|
||||||
|
@ -62,7 +63,7 @@ module.exports = createReactClass({
|
||||||
|
|
||||||
_toggleTag: function(tagNameOn, tagNameOff) {
|
_toggleTag: function(tagNameOn, tagNameOff) {
|
||||||
if (!MatrixClientPeg.get().isGuest()) {
|
if (!MatrixClientPeg.get().isGuest()) {
|
||||||
Promise.delay(500).then(() => {
|
sleep(500).then(() => {
|
||||||
dis.dispatch(RoomListActions.tagRoom(
|
dis.dispatch(RoomListActions.tagRoom(
|
||||||
MatrixClientPeg.get(),
|
MatrixClientPeg.get(),
|
||||||
this.props.room,
|
this.props.room,
|
||||||
|
@ -119,7 +120,7 @@ module.exports = createReactClass({
|
||||||
|
|
||||||
Rooms.guessAndSetDMRoom(
|
Rooms.guessAndSetDMRoom(
|
||||||
this.props.room, newIsDirectMessage,
|
this.props.room, newIsDirectMessage,
|
||||||
).delay(500).finally(() => {
|
).then(sleep(500)).finally(() => {
|
||||||
// Close the context menu
|
// Close the context menu
|
||||||
if (this.props.onFinished) {
|
if (this.props.onFinished) {
|
||||||
this.props.onFinished();
|
this.props.onFinished();
|
||||||
|
@ -193,7 +194,7 @@ module.exports = createReactClass({
|
||||||
RoomNotifs.setRoomNotifsState(roomId, newState).done(() => {
|
RoomNotifs.setRoomNotifsState(roomId, newState).done(() => {
|
||||||
// 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 Promise.delay(500).then(() => {
|
return sleep(500).then(() => {
|
||||||
if (this._unmounted) return;
|
if (this._unmounted) return;
|
||||||
// Close the context menu
|
// Close the context menu
|
||||||
if (this.props.onFinished) {
|
if (this.props.onFinished) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import * as Email from '../../../email';
|
||||||
import IdentityAuthClient from '../../../IdentityAuthClient';
|
import IdentityAuthClient from '../../../IdentityAuthClient';
|
||||||
import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from '../../../utils/IdentityServerUtils';
|
import { getDefaultIdentityServerUrl, useDefaultIdentityServer } from '../../../utils/IdentityServerUtils';
|
||||||
import { abbreviateUrl } from '../../../utils/UrlUtils';
|
import { abbreviateUrl } from '../../../utils/UrlUtils';
|
||||||
|
import {sleep} from "../../../utils/promise";
|
||||||
|
|
||||||
const TRUNCATE_QUERY_LIST = 40;
|
const TRUNCATE_QUERY_LIST = 40;
|
||||||
const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200;
|
const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200;
|
||||||
|
@ -533,7 +534,7 @@ module.exports = createReactClass({
|
||||||
};
|
};
|
||||||
|
|
||||||
// wait a bit to let the user finish typing
|
// wait a bit to let the user finish typing
|
||||||
await Promise.delay(500);
|
await sleep(500);
|
||||||
if (cancelled) return null;
|
if (cancelled) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import Analytics from "../../../../../Analytics";
|
||||||
import Promise from "bluebird";
|
import Promise from "bluebird";
|
||||||
import Modal from "../../../../../Modal";
|
import Modal from "../../../../../Modal";
|
||||||
import sdk from "../../../../..";
|
import sdk from "../../../../..";
|
||||||
|
import {sleep} from "../../../../../utils/promise";
|
||||||
|
|
||||||
export class IgnoredUser extends React.Component {
|
export class IgnoredUser extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -129,7 +130,7 @@ export default class SecurityUserSettingsTab extends React.Component {
|
||||||
if (e.errcode === "M_LIMIT_EXCEEDED") {
|
if (e.errcode === "M_LIMIT_EXCEEDED") {
|
||||||
// Add a delay between each invite change in order to avoid rate
|
// Add a delay between each invite change in order to avoid rate
|
||||||
// limiting by the server.
|
// limiting by the server.
|
||||||
await Promise.delay(e.retry_after_ms || 2500);
|
await sleep(e.retry_after_ms || 2500);
|
||||||
|
|
||||||
// Redo last action
|
// Redo last action
|
||||||
i--;
|
i--;
|
||||||
|
|
Loading…
Reference in a new issue