Replace setImmediate with setTimeout (#12614)
This commit is contained in:
parent
21ae29c002
commit
8b4e3e6647
21 changed files with 46 additions and 39 deletions
|
@ -170,7 +170,7 @@ export default class ContextMenu extends React.PureComponent<React.PropsWithChil
|
|||
|
||||
// XXX: This isn't pretty but the only way to allow opening a different context menu on right click whilst
|
||||
// a context menu and its click-guard are up without completely rewriting how the context menus work.
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
const clickEvent = new MouseEvent("contextmenu", {
|
||||
clientX: x,
|
||||
clientY: y,
|
||||
|
@ -180,7 +180,7 @@ export default class ContextMenu extends React.PureComponent<React.PropsWithChil
|
|||
relatedTarget: null,
|
||||
});
|
||||
document.elementFromPoint(x, y)?.dispatchEvent(clickEvent);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
|
|||
this.mouseHeld = false;
|
||||
// Delaying this to the next event loop tick is necessary for click
|
||||
// event cancellation to work
|
||||
setImmediate(() => (this.moving = false));
|
||||
setTimeout(() => (this.moving = false));
|
||||
this.snap(true);
|
||||
};
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ const BulkRedactDialog: React.FC<Props> = (props) => {
|
|||
primaryButtonClass="danger"
|
||||
primaryDisabled={count === 0}
|
||||
onPrimaryButtonClick={() => {
|
||||
setImmediate(redact);
|
||||
setTimeout(redact, 0);
|
||||
onFinished(true);
|
||||
}}
|
||||
onCancel={() => onFinished(false)}
|
||||
|
|
|
@ -354,7 +354,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
|
|||
placeholder={_t("forward|filter_placeholder")}
|
||||
onSearch={(query: string): void => {
|
||||
setQuery(query);
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
const ref = context.state.refs[0];
|
||||
if (ref) {
|
||||
context.dispatch({
|
||||
|
|
|
@ -505,7 +505,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
_setQuery(newQuery);
|
||||
};
|
||||
useEffect(() => {
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
const ref = rovingContext.state.refs[0];
|
||||
if (ref) {
|
||||
rovingContext.dispatch({
|
||||
|
|
|
@ -126,7 +126,7 @@ const NewRoomIntro: React.FC = () => {
|
|||
true,
|
||||
);
|
||||
// focus the topic field to help the user find it as it'll gain an outline
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
window.document.getElementById("profileTopic")?.focus();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -289,7 +289,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
if (payload.action === Action.ViewRoom && payload.show_room_tile && this.state.rooms) {
|
||||
// XXX: we have to do this a tick later because we have incorrect intermediate props during a room change
|
||||
// where we lose the room we are changing from temporarily and then it comes back in an update right after.
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
const roomIndex = this.state.rooms.findIndex((r) => r.roomId === payload.room_id);
|
||||
|
||||
if (!this.state.isExpanded && roomIndex > -1) {
|
||||
|
@ -300,7 +300,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
this.layout.visibleTiles = this.layout.tilesWithPadding(roomIndex + 1, MAX_PADDING_HEIGHT);
|
||||
this.forceUpdate(); // because the layout doesn't trigger a re-render
|
||||
}
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -457,9 +457,9 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
this.toggleCollapsed();
|
||||
// if the bottom list is collapsed then scroll it in so it doesn't expand off screen
|
||||
if (!isExpanded && isStickyBottom) {
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
sublist.scrollIntoView({ behavior: "smooth" });
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -195,7 +195,7 @@ export class RoomTile extends React.PureComponent<ClassProps, State> {
|
|||
payload.room_id === this.props.room.roomId &&
|
||||
payload.show_room_tile
|
||||
) {
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
this.scrollIntoView();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue