Replace setImmediate with setTimeout (#12614)
This commit is contained in:
committed by
GitHub
parent
21ae29c002
commit
8b4e3e6647
@@ -920,7 +920,7 @@ export function logout(oidcClientStore?: OidcClientStore): void {
|
||||
// logout doesn't work for guest sessions
|
||||
// Also we sometimes want to re-log in a guest session if we abort the login.
|
||||
// defer until next tick because it calls a synchronous dispatch, and we are likely here from a dispatch.
|
||||
setImmediate(() => onLoggedOut());
|
||||
setTimeout(onLoggedOut, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ export class ModalManager extends TypedEventEmitter<ModalManagerEvent, HandlerMa
|
||||
</div>
|
||||
);
|
||||
|
||||
setImmediate(() => ReactDOM.render(dialog, ModalManager.getOrCreateContainer()));
|
||||
setTimeout(() => ReactDOM.render(dialog, ModalManager.getOrCreateContainer()), 0);
|
||||
} else {
|
||||
// This is safe to call repeatedly if we happen to do that
|
||||
ReactDOM.unmountComponentAtNode(ModalManager.getOrCreateContainer());
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> implements
|
||||
|
||||
// We do this to intentionally break out of the current event loop task, allowing
|
||||
// us to instead wait for a more convenient time to run our updates.
|
||||
setImmediate(() => this.onDispatchAsync(payload));
|
||||
setTimeout(() => this.onDispatchAsync(payload));
|
||||
}
|
||||
|
||||
protected async onDispatchAsync(payload: ActionPayload): Promise<void> {
|
||||
|
||||
@@ -62,7 +62,7 @@ export class SpaceFilterCondition extends EventEmitter implements IFilterConditi
|
||||
this.emit(FILTER_CHANGED);
|
||||
// XXX: Room List Store has a bug where updates to the pre-filter during a local echo of a
|
||||
// tags transition seem to be ignored, so refire in the next tick to work around it
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
this.emit(FILTER_CHANGED);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user