Apply corrections identified by SonarQube (#8457)
This commit is contained in:
parent
99cb83a9df
commit
964c60d086
73 changed files with 211 additions and 232 deletions
|
@ -157,12 +157,14 @@ export default class ContextMenu extends React.PureComponent<IProps, IState> {
|
|||
// 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(() => {
|
||||
const clickEvent = document.createEvent('MouseEvents');
|
||||
clickEvent.initMouseEvent(
|
||||
'contextmenu', true, true, window, 0,
|
||||
0, 0, x, y, false, false,
|
||||
false, false, 0, null,
|
||||
);
|
||||
const clickEvent = new MouseEvent("contextmenu", {
|
||||
clientX: x,
|
||||
clientY: y,
|
||||
screenX: 0,
|
||||
screenY: 0,
|
||||
button: 0, // Left
|
||||
relatedTarget: null,
|
||||
});
|
||||
document.elementFromPoint(x, y).dispatchEvent(clickEvent);
|
||||
});
|
||||
}
|
||||
|
@ -417,8 +419,8 @@ export type ToRightOf = {
|
|||
|
||||
// Placement method for <ContextMenu /> to position context menu to right of elementRect with chevronOffset
|
||||
export const toRightOf = (elementRect: Pick<DOMRect, "right" | "top" | "height">, chevronOffset = 12): ToRightOf => {
|
||||
const left = elementRect.right + window.pageXOffset + 3;
|
||||
let top = elementRect.top + (elementRect.height / 2) + window.pageYOffset;
|
||||
const left = elementRect.right + window.scrollX + 3;
|
||||
let top = elementRect.top + (elementRect.height / 2) + window.scrollY;
|
||||
top -= chevronOffset + 8; // where 8 is half the height of the chevron
|
||||
return { left, top, chevronOffset };
|
||||
};
|
||||
|
@ -436,9 +438,9 @@ export const aboveLeftOf = (
|
|||
): AboveLeftOf => {
|
||||
const menuOptions: IPosition & { chevronFace: ChevronFace } = { chevronFace };
|
||||
|
||||
const buttonRight = elementRect.right + window.pageXOffset;
|
||||
const buttonBottom = elementRect.bottom + window.pageYOffset;
|
||||
const buttonTop = elementRect.top + window.pageYOffset;
|
||||
const buttonRight = elementRect.right + window.scrollX;
|
||||
const buttonBottom = elementRect.bottom + window.scrollY;
|
||||
const buttonTop = elementRect.top + window.scrollY;
|
||||
// Align the right edge of the menu to the right edge of the button
|
||||
menuOptions.right = UIStore.instance.windowWidth - buttonRight;
|
||||
// Align the menu vertically on whichever side of the button has more space available.
|
||||
|
@ -460,9 +462,9 @@ export const aboveRightOf = (
|
|||
): AboveLeftOf => {
|
||||
const menuOptions: IPosition & { chevronFace: ChevronFace } = { chevronFace };
|
||||
|
||||
const buttonLeft = elementRect.left + window.pageXOffset;
|
||||
const buttonBottom = elementRect.bottom + window.pageYOffset;
|
||||
const buttonTop = elementRect.top + window.pageYOffset;
|
||||
const buttonLeft = elementRect.left + window.scrollX;
|
||||
const buttonBottom = elementRect.bottom + window.scrollY;
|
||||
const buttonTop = elementRect.top + window.scrollY;
|
||||
// Align the left edge of the menu to the left edge of the button
|
||||
menuOptions.left = buttonLeft;
|
||||
// Align the menu vertically on whichever side of the button has more space available.
|
||||
|
@ -484,9 +486,9 @@ export const alwaysAboveLeftOf = (
|
|||
) => {
|
||||
const menuOptions: IPosition & { chevronFace: ChevronFace } = { chevronFace };
|
||||
|
||||
const buttonRight = elementRect.right + window.pageXOffset;
|
||||
const buttonBottom = elementRect.bottom + window.pageYOffset;
|
||||
const buttonTop = elementRect.top + window.pageYOffset;
|
||||
const buttonRight = elementRect.right + window.scrollX;
|
||||
const buttonBottom = elementRect.bottom + window.scrollY;
|
||||
const buttonTop = elementRect.top + window.scrollY;
|
||||
// Align the right edge of the menu to the right edge of the button
|
||||
menuOptions.right = UIStore.instance.windowWidth - buttonRight;
|
||||
// Align the menu vertically on whichever side of the button has more space available.
|
||||
|
@ -508,8 +510,8 @@ export const alwaysAboveRightOf = (
|
|||
) => {
|
||||
const menuOptions: IPosition & { chevronFace: ChevronFace } = { chevronFace };
|
||||
|
||||
const buttonLeft = elementRect.left + window.pageXOffset;
|
||||
const buttonTop = elementRect.top + window.pageYOffset;
|
||||
const buttonLeft = elementRect.left + window.scrollX;
|
||||
const buttonTop = elementRect.top + window.scrollY;
|
||||
// Align the left edge of the menu to the left edge of the button
|
||||
menuOptions.left = buttonLeft;
|
||||
// Align the menu vertically above the menu
|
||||
|
|
|
@ -26,7 +26,7 @@ import dis from "../../dispatcher/dispatcher";
|
|||
import Modal from "../../Modal";
|
||||
import { _t } from '../../languageHandler';
|
||||
import SdkConfig from '../../SdkConfig';
|
||||
import { instanceForInstanceId, protocolNameForInstanceId } from '../../utils/DirectoryUtils';
|
||||
import { instanceForInstanceId, protocolNameForInstanceId, ALL_ROOMS, Protocols } from '../../utils/DirectoryUtils';
|
||||
import Analytics from '../../Analytics';
|
||||
import NetworkDropdown from "../views/directory/NetworkDropdown";
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
|
@ -43,7 +43,6 @@ import PosthogTrackers from "../../PosthogTrackers";
|
|||
import { PublicRoomTile } from "../views/rooms/PublicRoomTile";
|
||||
import { getFieldsForThirdPartyLocation, joinRoomByAlias, showRoom } from "../../utils/rooms";
|
||||
import { GenericError } from "../../utils/error";
|
||||
import { ALL_ROOMS, Protocols } from "../../utils/DirectoryUtils";
|
||||
|
||||
const LAST_SERVER_KEY = "mx_last_room_directory_server";
|
||||
const LAST_INSTANCE_KEY = "mx_last_room_directory_instance";
|
||||
|
|
|
@ -28,7 +28,7 @@ import { NameFilterCondition } from "../../stores/room-list/filters/NameFilterCo
|
|||
import { getKeyBindingsManager } from "../../KeyBindingsManager";
|
||||
import SpaceStore from "../../stores/spaces/SpaceStore";
|
||||
import { UPDATE_SELECTED_SPACE } from "../../stores/spaces";
|
||||
import { isMac, Key } from "../../Keyboard";
|
||||
import { IS_MAC, Key } from "../../Keyboard";
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
import Modal from "../../Modal";
|
||||
import SpotlightDialog from "../views/dialogs/SpotlightDialog";
|
||||
|
@ -206,7 +206,7 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
|
|||
);
|
||||
|
||||
let shortcutPrompt = <div className="mx_RoomSearch_shortcutPrompt">
|
||||
{ isMac ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K" }
|
||||
{ IS_MAC ? "⌘ K" : _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " K" }
|
||||
</div>;
|
||||
|
||||
if (this.props.isMinimized) {
|
||||
|
|
|
@ -36,7 +36,6 @@ import classNames from "classnames";
|
|||
import { sortBy, uniqBy } from "lodash";
|
||||
import { GuestAccess, HistoryVisibility } from "matrix-js-sdk/src/@types/partials";
|
||||
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import { _t } from "../../languageHandler";
|
||||
import AccessibleButton, { ButtonEvent } from "../views/elements/AccessibleButton";
|
||||
|
@ -330,13 +329,13 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
|||
// fail earlier so they don't have to click back to the directory.
|
||||
if (cli.isGuest()) {
|
||||
if (!room.world_readable && !room.guest_can_join) {
|
||||
dis.dispatch({ action: "require_registration" });
|
||||
defaultDispatcher.dispatch({ action: "require_registration" });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const roomAlias = getDisplayAliasForRoom(room) || undefined;
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
should_peek: true,
|
||||
room_alias: roomAlias,
|
||||
|
@ -356,7 +355,7 @@ export const joinRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
|||
// Don't let the user view a room they won't be able to either peek or join:
|
||||
// fail earlier so they don't have to click back to the directory.
|
||||
if (cli.isGuest()) {
|
||||
dis.dispatch({ action: "require_registration" });
|
||||
defaultDispatcher.dispatch({ action: "require_registration" });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -365,7 +364,7 @@ export const joinRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
|||
});
|
||||
|
||||
prom.then(() => {
|
||||
dis.dispatch<JoinRoomReadyPayload>({
|
||||
defaultDispatcher.dispatch<JoinRoomReadyPayload>({
|
||||
action: Action.JoinRoomReady,
|
||||
roomId,
|
||||
metricsTrigger: "SpaceHierarchy",
|
||||
|
@ -569,7 +568,7 @@ const ManageButtons = ({ hierarchy, selected, setSelected, setError }: IManageBu
|
|||
const selectedRelations = Array.from(selected.keys()).flatMap(parentId => {
|
||||
return [
|
||||
...selected.get(parentId).values(),
|
||||
].map(childId => [parentId, childId]) as [string, string][];
|
||||
].map(childId => [parentId, childId]);
|
||||
});
|
||||
|
||||
const selectionAllSuggested = selectedRelations.every(([parentId, childId]) => {
|
||||
|
|
|
@ -36,7 +36,6 @@ import { useTypedEventEmitter } from "../../hooks/useEventEmitter";
|
|||
import withValidation from "../views/elements/Validation";
|
||||
import * as Email from "../../email";
|
||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import ResizeNotifier from "../../utils/ResizeNotifier";
|
||||
import MainSplit from './MainSplit';
|
||||
|
@ -204,7 +203,7 @@ const SpacePreview = ({ space, onJoinButtonClicked, onRejectButtonClicked }: ISp
|
|||
<AccessibleButton
|
||||
kind="danger_outline"
|
||||
onClick={() => {
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: "leave_room",
|
||||
room_id: space.roomId,
|
||||
});
|
||||
|
@ -316,8 +315,8 @@ const SpaceLandingAddButton = ({ space }) => {
|
|||
if (menuDisplayed) {
|
||||
const rect = handle.current.getBoundingClientRect();
|
||||
contextMenu = <IconizedContextMenu
|
||||
left={rect.left + window.pageXOffset + 0}
|
||||
top={rect.bottom + window.pageYOffset + 8}
|
||||
left={rect.left + window.scrollX + 0}
|
||||
top={rect.bottom + window.scrollY + 8}
|
||||
chevronFace={ChevronFace.None}
|
||||
onFinished={closeMenu}
|
||||
className="mx_RoomTile_contextMenu"
|
||||
|
|
|
@ -20,7 +20,6 @@ import classNames from "classnames";
|
|||
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import { _t } from "../../languageHandler";
|
||||
|
@ -323,7 +322,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||
const cli = MatrixClientPeg.get();
|
||||
if (!cli || !cli.isCryptoEnabled() || !(await cli.exportRoomKeys())?.length) {
|
||||
// log out without user prompt if they have no local megolm sessions
|
||||
dis.dispatch({ action: 'logout' });
|
||||
defaultDispatcher.dispatch({ action: 'logout' });
|
||||
} else {
|
||||
Modal.createTrackedDialog('Logout from LeftPanel', '', LogoutDialog);
|
||||
}
|
||||
|
@ -332,12 +331,12 @@ export default class UserMenu extends React.Component<IProps, IState> {
|
|||
};
|
||||
|
||||
private onSignInClick = () => {
|
||||
dis.dispatch({ action: 'start_login' });
|
||||
defaultDispatcher.dispatch({ action: 'start_login' });
|
||||
this.setState({ contextMenuPosition: null }); // also close the menu
|
||||
};
|
||||
|
||||
private onRegisterClick = () => {
|
||||
dis.dispatch({ action: 'start_registration' });
|
||||
defaultDispatcher.dispatch({ action: 'start_registration' });
|
||||
this.setState({ contextMenuPosition: null }); // also close the menu
|
||||
};
|
||||
|
||||
|
|
|
@ -37,12 +37,11 @@ import { Action } from "../../../dispatcher/actions";
|
|||
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
|
||||
import { ButtonEvent } from '../elements/AccessibleButton';
|
||||
import { copyPlaintext, getSelectedText } from '../../../utils/strings';
|
||||
import ContextMenu, { toRightOf } from '../../structures/ContextMenu';
|
||||
import ContextMenu, { toRightOf, IPosition, ChevronFace } from '../../structures/ContextMenu';
|
||||
import ReactionPicker from '../emojipicker/ReactionPicker';
|
||||
import ViewSource from '../../structures/ViewSource';
|
||||
import { createRedactEventDialog } from '../dialogs/ConfirmRedactDialog';
|
||||
import ShareDialog from '../dialogs/ShareDialog';
|
||||
import { IPosition, ChevronFace } from '../../structures/ContextMenu';
|
||||
import RoomContext, { TimelineRenderingType } from '../../../contexts/RoomContext';
|
||||
import { ComposerInsertPayload } from "../../../dispatcher/payloads/ComposerInsertPayload";
|
||||
import EndPollDialog from '../dialogs/EndPollDialog';
|
||||
|
|
|
@ -37,8 +37,8 @@ interface IProps {
|
|||
|
||||
const contextMenuBelow = (elementRect: DOMRect) => {
|
||||
// align the context menu's icons with the icon which opened the context menu
|
||||
const left = elementRect.left + window.pageXOffset + elementRect.width;
|
||||
const top = elementRect.bottom + window.pageYOffset;
|
||||
const left = elementRect.left + window.scrollX + elementRect.width;
|
||||
const top = elementRect.bottom + window.scrollY;
|
||||
const chevronFace = ChevronFace.None;
|
||||
return { left, top, chevronFace };
|
||||
};
|
||||
|
|
|
@ -200,7 +200,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
}, {
|
||||
key: "number",
|
||||
test: ({ value }) => {
|
||||
const parsedSize = parseInt(value as string, 10);
|
||||
const parsedSize = parseInt(value, 10);
|
||||
return validateNumberInRange(1, 2000)(parsedSize);
|
||||
},
|
||||
invalid: () => {
|
||||
|
@ -238,7 +238,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
}, {
|
||||
key: "number",
|
||||
test: ({ value }) => {
|
||||
const parsedSize = parseInt(value as string, 10);
|
||||
const parsedSize = parseInt(value, 10);
|
||||
return validateNumberInRange(1, 10 ** 8)(parsedSize);
|
||||
},
|
||||
invalid: () => {
|
||||
|
|
|
@ -138,7 +138,8 @@ export default class MessageEditHistoryDialog extends React.PureComponent<IProps
|
|||
isBaseEvent={isBaseEvent}
|
||||
mxEvent={e}
|
||||
isTwelveHour={this.state.isTwelveHour}
|
||||
/>));
|
||||
/>
|
||||
));
|
||||
lastEvent = e;
|
||||
});
|
||||
return nodes;
|
||||
|
|
|
@ -367,16 +367,16 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", onFinished }) =>
|
|||
);
|
||||
}
|
||||
|
||||
const otherResult = (result as IResult);
|
||||
// IResult case
|
||||
return (
|
||||
<Option
|
||||
id={`mx_SpotlightDialog_button_result_${otherResult.name}`}
|
||||
key={otherResult.name}
|
||||
onClick={otherResult.onClick}
|
||||
id={`mx_SpotlightDialog_button_result_${result.name}`}
|
||||
key={result.name}
|
||||
onClick={result.onClick}
|
||||
>
|
||||
{ otherResult.avatar }
|
||||
{ otherResult.name }
|
||||
{ otherResult.description }
|
||||
{ result.avatar }
|
||||
{ result.name }
|
||||
{ result.description }
|
||||
</Option>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -93,7 +93,7 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
|
||||
private doBootstrapUIAuth = async (makeRequest: (authData: any) => void): Promise<void> => {
|
||||
if (this.state.canUploadKeysWithPasswordOnly && this.state.accountPassword) {
|
||||
await makeRequest({
|
||||
makeRequest({
|
||||
type: 'm.login.password',
|
||||
identifier: {
|
||||
type: 'm.id.user',
|
||||
|
@ -106,7 +106,7 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
|
|||
});
|
||||
} else if (this.props.tokenLogin) {
|
||||
// We are hoping the grace period is active
|
||||
await makeRequest({});
|
||||
makeRequest({});
|
||||
} else {
|
||||
const dialogAesthetics = {
|
||||
[SSOAuthEntry.PHASE_PREAUTH]: {
|
||||
|
|
|
@ -19,7 +19,7 @@ import React, { useEffect, useState } from "react";
|
|||
import { MatrixError } from "matrix-js-sdk/src/http-api";
|
||||
|
||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||
import { instanceForInstanceId } from '../../../utils/DirectoryUtils';
|
||||
import { instanceForInstanceId, ALL_ROOMS, Protocols } from '../../../utils/DirectoryUtils';
|
||||
import ContextMenu, {
|
||||
ChevronFace,
|
||||
ContextMenuButton,
|
||||
|
@ -41,7 +41,6 @@ import UIStore from "../../../stores/UIStore";
|
|||
import { compare } from "../../../utils/strings";
|
||||
import { SnakedObject } from "../../../utils/SnakedObject";
|
||||
import { IConfigOptions } from "../../../IConfigOptions";
|
||||
import { ALL_ROOMS, Protocols } from "../../../utils/DirectoryUtils";
|
||||
|
||||
const SETTING_NAME = "room_directory_servers";
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ export default class IRCTimelineProfileResizer extends React.Component<IProps, I
|
|||
|
||||
componentDidMount() {
|
||||
this.setState({
|
||||
IRCLayoutRoot: document.querySelector(".mx_IRCLayout") as HTMLElement,
|
||||
IRCLayoutRoot: document.querySelector(".mx_IRCLayout"),
|
||||
}, () => this.updateCSSWidth(this.state.width));
|
||||
}
|
||||
|
||||
|
|
|
@ -352,10 +352,10 @@ export default class InteractiveTooltip extends React.Component<IProps, IState>
|
|||
const targetRect = this.target.getBoundingClientRect();
|
||||
|
||||
if (this.props.direction === Direction.Left) {
|
||||
const targetLeft = targetRect.left + window.pageXOffset;
|
||||
const targetLeft = targetRect.left + window.scrollX;
|
||||
return !contentRect || (targetLeft - contentRect.width > MIN_SAFE_DISTANCE_TO_WINDOW_EDGE);
|
||||
} else {
|
||||
const targetRight = targetRect.right + window.pageXOffset;
|
||||
const targetRight = targetRect.right + window.scrollX;
|
||||
const spaceOnRight = UIStore.instance.windowWidth - targetRight;
|
||||
return contentRect && (spaceOnRight - contentRect.width < MIN_SAFE_DISTANCE_TO_WINDOW_EDGE);
|
||||
}
|
||||
|
@ -366,10 +366,10 @@ export default class InteractiveTooltip extends React.Component<IProps, IState>
|
|||
const targetRect = this.target.getBoundingClientRect();
|
||||
|
||||
if (this.props.direction === Direction.Top) {
|
||||
const targetTop = targetRect.top + window.pageYOffset;
|
||||
const targetTop = targetRect.top + window.scrollY;
|
||||
return !contentRect || (targetTop - contentRect.height > MIN_SAFE_DISTANCE_TO_WINDOW_EDGE);
|
||||
} else {
|
||||
const targetBottom = targetRect.bottom + window.pageYOffset;
|
||||
const targetBottom = targetRect.bottom + window.scrollY;
|
||||
const spaceBelow = UIStore.instance.windowHeight - targetBottom;
|
||||
return contentRect && (spaceBelow - contentRect.height < MIN_SAFE_DISTANCE_TO_WINDOW_EDGE);
|
||||
}
|
||||
|
@ -429,10 +429,10 @@ export default class InteractiveTooltip extends React.Component<IProps, IState>
|
|||
const targetRect = this.target.getBoundingClientRect();
|
||||
|
||||
// The window X and Y offsets are to adjust position when zoomed in to page
|
||||
const targetLeft = targetRect.left + window.pageXOffset;
|
||||
const targetRight = targetRect.right + window.pageXOffset;
|
||||
const targetBottom = targetRect.bottom + window.pageYOffset;
|
||||
const targetTop = targetRect.top + window.pageYOffset;
|
||||
const targetLeft = targetRect.left + window.scrollX;
|
||||
const targetRight = targetRect.right + window.scrollX;
|
||||
const targetBottom = targetRect.bottom + window.scrollY;
|
||||
const targetTop = targetRect.top + window.scrollY;
|
||||
|
||||
// Place the tooltip above the target by default. If we find that the
|
||||
// tooltip content would extend past the safe area towards the window
|
||||
|
|
|
@ -116,12 +116,12 @@ export default class Tooltip extends React.Component<ITooltipProps> {
|
|||
? Math.min(parentBox.width, this.props.maxParentWidth)
|
||||
: parentBox.width
|
||||
);
|
||||
const baseTop = (parentBox.top - 2 + this.props.yOffset) + window.pageYOffset;
|
||||
const baseTop = (parentBox.top - 2 + this.props.yOffset) + window.scrollY;
|
||||
const top = baseTop + offset;
|
||||
const right = width - parentBox.left - window.pageXOffset;
|
||||
const left = parentBox.right + window.pageXOffset;
|
||||
const right = width - parentBox.left - window.scrollX;
|
||||
const left = parentBox.right + window.scrollX;
|
||||
const horizontalCenter = (
|
||||
parentBox.left - window.pageXOffset + (parentWidth / 2)
|
||||
parentBox.left - window.scrollX + (parentWidth / 2)
|
||||
);
|
||||
switch (this.props.alignment) {
|
||||
case Alignment.Natural:
|
||||
|
@ -154,7 +154,7 @@ export default class Tooltip extends React.Component<ITooltipProps> {
|
|||
break;
|
||||
case Alignment.TopRight:
|
||||
style.top = baseTop - 5;
|
||||
style.right = width - parentBox.right - window.pageXOffset;
|
||||
style.right = width - parentBox.right - window.scrollX;
|
||||
style.transform = "translate(5px, -100%)";
|
||||
break;
|
||||
case Alignment.TopCenter:
|
||||
|
|
|
@ -52,7 +52,7 @@ class Category extends React.PureComponent<IProps> {
|
|||
const { onClick, onMouseEnter, onMouseLeave, selectedEmojis, emojis } = this.props;
|
||||
const emojisForRow = emojis.slice(rowIndex * 8, (rowIndex + 1) * 8);
|
||||
return (<div key={rowIndex}>{
|
||||
emojisForRow.map(emoji => ((
|
||||
emojisForRow.map(emoji => (
|
||||
<Emoji
|
||||
key={emoji.hexcode}
|
||||
emoji={emoji}
|
||||
|
@ -61,7 +61,7 @@ class Category extends React.PureComponent<IProps> {
|
|||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
/>
|
||||
)))
|
||||
))
|
||||
}</div>);
|
||||
};
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
>
|
||||
{ this.categories.map(category => {
|
||||
const emojis = this.memoizedDataByCategory[category.id];
|
||||
const categoryElement = ((
|
||||
const categoryElement = (
|
||||
<Category
|
||||
key={category.id}
|
||||
id={category.id}
|
||||
|
@ -263,7 +263,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
|
|||
onMouseLeave={this.onHoverEmojiEnd}
|
||||
selectedEmojis={this.props.selectedEmojis}
|
||||
/>
|
||||
));
|
||||
);
|
||||
const height = EmojiPicker.categoryHeightForEmojiCount(emojis.length);
|
||||
heightBefore += height;
|
||||
return categoryElement;
|
||||
|
|
|
@ -72,7 +72,7 @@ class QuickReactions extends React.Component<IProps, IState> {
|
|||
}
|
||||
</h2>
|
||||
<ul className="mx_EmojiPicker_list" aria-label={_t("Quick Reactions")}>
|
||||
{ QUICK_REACTIONS.map(emoji => ((
|
||||
{ QUICK_REACTIONS.map(emoji => (
|
||||
<Emoji
|
||||
key={emoji.hexcode}
|
||||
emoji={emoji}
|
||||
|
@ -81,7 +81,7 @@ class QuickReactions extends React.Component<IProps, IState> {
|
|||
onMouseLeave={this.onMouseLeave}
|
||||
selectedEmojis={this.props.selectedEmojis}
|
||||
/>
|
||||
))) }
|
||||
)) }
|
||||
</ul>
|
||||
</section>
|
||||
);
|
||||
|
|
|
@ -21,11 +21,10 @@ import { IEventRelation } from 'matrix-js-sdk/src/models/event';
|
|||
import MatrixClientContext from '../../../contexts/MatrixClientContext';
|
||||
import ContextMenu, { AboveLeftOf } from '../../structures/ContextMenu';
|
||||
import LocationPicker, { ILocationPickerProps } from "./LocationPicker";
|
||||
import { shareLiveLocation, shareLocation } from './shareLocation';
|
||||
import { shareLiveLocation, shareLocation, LocationShareType } from './shareLocation';
|
||||
import SettingsStore from '../../../settings/SettingsStore';
|
||||
import ShareDialogButtons from './ShareDialogButtons';
|
||||
import ShareType from './ShareType';
|
||||
import { LocationShareType } from './shareLocation';
|
||||
import { OwnProfileStore } from '../../../stores/OwnProfileStore';
|
||||
import { EnableLiveShare } from './EnableLiveShare';
|
||||
import { useFeatureEnabled } from '../../../hooks/useSettings';
|
||||
|
|
|
@ -32,7 +32,7 @@ import { parseEvent, parsePlainTextMessage } from '../../../editor/deserialize';
|
|||
import { renderModel } from '../../../editor/render';
|
||||
import TypingStore from "../../../stores/TypingStore";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import { Key } from "../../../Keyboard";
|
||||
import { IS_MAC, Key } from "../../../Keyboard";
|
||||
import { EMOTICON_TO_EMOJI } from "../../../emoji";
|
||||
import { CommandCategories, CommandMap, parseCommandString } from "../../../SlashCommands";
|
||||
import Range from "../../../editor/range";
|
||||
|
@ -50,8 +50,6 @@ import { _t } from "../../../languageHandler";
|
|||
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s|:^$');
|
||||
export const REGEX_EMOTICON = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')$');
|
||||
|
||||
const IS_MAC = navigator.platform.indexOf("Mac") !== -1;
|
||||
|
||||
const SURROUND_WITH_CHARACTERS = ["\"", "_", "`", "'", "*", "~", "$"];
|
||||
const SURROUND_WITH_DOUBLE_CHARACTERS = new Map([
|
||||
["(", ")"],
|
||||
|
|
|
@ -28,7 +28,6 @@ import AccessibleButton from "../elements/AccessibleButton";
|
|||
import MiniAvatarUploader, { AVATAR_SIZE } from "../elements/MiniAvatarUploader";
|
||||
import RoomAvatar from "../avatars/RoomAvatar";
|
||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||
import dis from "../../../dispatcher/dispatcher";
|
||||
import { ViewUserPayload } from "../../../dispatcher/payloads/ViewUserPayload";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
||||
|
@ -87,7 +86,7 @@ const NewRoomIntro = () => {
|
|||
const canAddTopic = inRoom && room.currentState.maySendStateEvent(EventType.RoomTopic, cli.getUserId());
|
||||
|
||||
const onTopicClick = () => {
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: "open_room_settings",
|
||||
room_id: roomId,
|
||||
}, true);
|
||||
|
@ -150,7 +149,7 @@ const NewRoomIntro = () => {
|
|||
className="mx_NewRoomIntro_inviteButton"
|
||||
kind="primary_outline"
|
||||
onClick={() => {
|
||||
dis.dispatch({ action: "view_invite", roomId });
|
||||
defaultDispatcher.dispatch({ action: "view_invite", roomId });
|
||||
}}
|
||||
>
|
||||
{ _t("Invite to just this room") }
|
||||
|
@ -162,7 +161,7 @@ const NewRoomIntro = () => {
|
|||
className="mx_NewRoomIntro_inviteButton"
|
||||
kind="primary"
|
||||
onClick={() => {
|
||||
dis.dispatch({ action: "view_invite", roomId });
|
||||
defaultDispatcher.dispatch({ action: "view_invite", roomId });
|
||||
}}
|
||||
>
|
||||
{ _t("Invite to this room") }
|
||||
|
@ -192,7 +191,7 @@ const NewRoomIntro = () => {
|
|||
|
||||
function openRoomSettings(event) {
|
||||
event.preventDefault();
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: "open_room_settings",
|
||||
initial_tab_id: ROOM_SECURITY_TAB,
|
||||
});
|
||||
|
|
|
@ -16,9 +16,8 @@ limitations under the License.
|
|||
|
||||
import React, { ComponentType, createRef, ReactComponentElement, RefObject } from "react";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { RoomType } from "matrix-js-sdk/src/@types/event";
|
||||
import { RoomType, EventType } from "matrix-js-sdk/src/@types/event";
|
||||
import * as fbEmitter from "fbemitter";
|
||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||
|
||||
import { _t, _td } from "../../../languageHandler";
|
||||
import { IState as IRovingTabIndexState, RovingTabIndexProvider } from "../../../accessibility/RovingTabIndex";
|
||||
|
|
|
@ -60,8 +60,8 @@ import { UIComponent } from "../../../settings/UIFeature";
|
|||
|
||||
const contextMenuBelow = (elementRect: DOMRect) => {
|
||||
// align the context menu's icons with the icon which opened the context menu
|
||||
const left = elementRect.left + window.pageXOffset;
|
||||
const top = elementRect.bottom + window.pageYOffset + 12;
|
||||
const left = elementRect.left + window.scrollX;
|
||||
const top = elementRect.bottom + window.scrollY + 12;
|
||||
const chevronFace = ChevronFace.None;
|
||||
return { left, top, chevronFace };
|
||||
};
|
||||
|
|
|
@ -39,7 +39,6 @@ import ContextMenu, {
|
|||
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore";
|
||||
import { ListAlgorithm, SortAlgorithm } from "../../../stores/room-list/algorithms/models";
|
||||
import { DefaultTagID, TagID } from "../../../stores/room-list/models";
|
||||
import dis from "../../../dispatcher/dispatcher";
|
||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import NotificationBadge from "./NotificationBadge";
|
||||
|
@ -426,7 +425,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
if (room) {
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: room.roomId,
|
||||
show_room_tile: true, // to make sure the room gets scrolled into view
|
||||
|
|
|
@ -24,7 +24,6 @@ import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
|||
|
||||
import { RovingTabIndexWrapper } from "../../../accessibility/RovingTabIndex";
|
||||
import AccessibleButton, { ButtonEvent } from "../../views/elements/AccessibleButton";
|
||||
import dis from '../../../dispatcher/dispatcher';
|
||||
import defaultDispatcher from '../../../dispatcher/dispatcher';
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
|
@ -90,8 +89,8 @@ const messagePreviewId = (roomId: string) => `mx_RoomTile_messagePreview_${roomI
|
|||
|
||||
export const contextMenuBelow = (elementRect: PartialDOMRect) => {
|
||||
// align the context menu's icons with the icon which opened the context menu
|
||||
const left = elementRect.left + window.pageXOffset - 9;
|
||||
const top = elementRect.bottom + window.pageYOffset + 17;
|
||||
const left = elementRect.left + window.scrollX - 9;
|
||||
const top = elementRect.bottom + window.scrollY + 17;
|
||||
const chevronFace = ChevronFace.None;
|
||||
return { left, top, chevronFace };
|
||||
};
|
||||
|
@ -260,7 +259,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
|
||||
const action = getKeyBindingsManager().getAccessibilityAction(ev);
|
||||
|
||||
dis.dispatch<ViewRoomPayload>({
|
||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
show_room_tile: true, // make sure the room is visible in the list
|
||||
room_id: this.props.room.roomId,
|
||||
|
@ -321,7 +320,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
const isApplied = RoomListStore.instance.getTagsForRoom(this.props.room).includes(tagId);
|
||||
const removeTag = isApplied ? tagId : inverseTag;
|
||||
const addTag = isApplied ? null : tagId;
|
||||
dis.dispatch(RoomListActions.tagRoom(
|
||||
defaultDispatcher.dispatch(RoomListActions.tagRoom(
|
||||
MatrixClientPeg.get(),
|
||||
this.props.room,
|
||||
removeTag,
|
||||
|
@ -346,7 +345,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: 'leave_room',
|
||||
room_id: this.props.room.roomId,
|
||||
});
|
||||
|
@ -359,7 +358,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: 'forget_room',
|
||||
room_id: this.props.room.roomId,
|
||||
});
|
||||
|
@ -370,7 +369,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: 'open_room_settings',
|
||||
room_id: this.props.room.roomId,
|
||||
});
|
||||
|
@ -383,7 +382,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: 'copy_room',
|
||||
room_id: this.props.room.roomId,
|
||||
});
|
||||
|
@ -394,7 +393,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
dis.dispatch({
|
||||
defaultDispatcher.dispatch({
|
||||
action: 'view_invite',
|
||||
roomId: this.props.room.roomId,
|
||||
});
|
||||
|
|
|
@ -196,7 +196,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
|||
|
||||
try {
|
||||
// stop any noises which might be happening
|
||||
await PlaybackManager.instance.pauseAllExcept(null);
|
||||
PlaybackManager.instance.pauseAllExcept(null);
|
||||
|
||||
const recorder = VoiceRecordingStore.instance.startRecording(this.props.room.roomId);
|
||||
await recorder.start();
|
||||
|
|
|
@ -21,8 +21,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
import { _t } from '../../../languageHandler';
|
||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||
import { formatDate } from '../../../DateUtils';
|
||||
import StyledCheckbox from '../elements/StyledCheckbox';
|
||||
import { CheckboxStyle } from '../elements/StyledCheckbox';
|
||||
import StyledCheckbox, { CheckboxStyle } from '../elements/StyledCheckbox';
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import Field from "../elements/Field";
|
||||
import TextWithTooltip from "../elements/TextWithTooltip";
|
||||
|
|
|
@ -125,7 +125,7 @@ export default class EventIndexPanel extends React.Component<{}, IState> {
|
|||
|
||||
await EventIndexPeg.initEventIndex();
|
||||
await EventIndexPeg.get().addInitialCheckpoints();
|
||||
await EventIndexPeg.get().startCrawler();
|
||||
EventIndexPeg.get().startCrawler();
|
||||
await SettingsStore.setValue('enableEventIndexing', null, SettingLevel.DEVICE, true);
|
||||
await this.updateState();
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ import React from "react";
|
|||
|
||||
import { ALTERNATE_KEY_NAME, KEY_ICON } from "../../../accessibility/KeyboardShortcuts";
|
||||
import { KeyCombo } from "../../../KeyBindingsManager";
|
||||
import { isMac, Key } from "../../../Keyboard";
|
||||
import { IS_MAC, Key } from "../../../Keyboard";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
||||
interface IKeyboardKeyProps {
|
||||
|
@ -45,7 +45,7 @@ export const KeyboardShortcut: React.FC<IKeyboardShortcutProps> = ({ value }) =>
|
|||
|
||||
const modifiersElement = [];
|
||||
if (value.ctrlOrCmdKey) {
|
||||
modifiersElement.push(<KeyboardKey key="ctrlOrCmdKey" name={isMac ? Key.META : Key.CONTROL} />);
|
||||
modifiersElement.push(<KeyboardKey key="ctrlOrCmdKey" name={IS_MAC ? Key.META : Key.CONTROL} />);
|
||||
} else if (value.ctrlKey) {
|
||||
modifiersElement.push(<KeyboardKey key="ctrlKey" name={Key.CONTROL} />);
|
||||
} else if (value.metaKey) {
|
||||
|
|
|
@ -148,7 +148,7 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
|
|||
<a href="https://mozilla.org" rel="noreferrer noopener" target="_blank">
|
||||
Mozilla Foundation
|
||||
</a> used under the terms of
|
||||
<a href="http://www.apache.org/licenses/LICENSE-2.0" rel="noreferrer noopener" target="_blank">Apache 2.0</a>.
|
||||
<a href="https://www.apache.org/licenses/LICENSE-2.0" rel="noreferrer noopener" target="_blank">Apache 2.0</a>.
|
||||
</li>
|
||||
<li>
|
||||
The <a href="https://twemoji.twitter.com/" rel="noreferrer noopener" target="_blank">
|
||||
|
|
|
@ -63,7 +63,7 @@ import QuickSettingsButton from "./QuickSettingsButton";
|
|||
import { useSettingValue } from "../../../hooks/useSettings";
|
||||
import UserMenu from "../../structures/UserMenu";
|
||||
import IndicatorScrollbar from "../../structures/IndicatorScrollbar";
|
||||
import { isMac, Key } from "../../../Keyboard";
|
||||
import { IS_MAC, Key } from "../../../Keyboard";
|
||||
import { useDispatcher } from "../../../hooks/useDispatcher";
|
||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||
import { ActionPayload } from "../../../dispatcher/payloads";
|
||||
|
@ -365,7 +365,7 @@ const SpacePanel = () => {
|
|||
{ isPanelCollapsed ? _t("Expand") : _t("Collapse") }
|
||||
</div>
|
||||
<div className="mx_Tooltip_sub">
|
||||
{ isMac
|
||||
{ IS_MAC
|
||||
? "⌘ + ⇧ + D"
|
||||
: _t(ALTERNATE_KEY_NAME[Key.CONTROL]) + " + " +
|
||||
_t(ALTERNATE_KEY_NAME[Key.SHIFT]) + " + D"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue