mirror of https://github.com/vector-im/riot-web
iterate PR
parent
a63d9220d2
commit
cee294f5a7
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, {HTMLAttributes} from "react";
|
import React, { HTMLAttributes } from "react";
|
||||||
|
|
||||||
interface IProps extends HTMLAttributes<HTMLDivElement> {
|
interface IProps extends HTMLAttributes<HTMLDivElement> {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|
|
@ -14,34 +14,34 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, {ReactNode, useMemo, useState} from "react";
|
import React, { ReactNode, useMemo, useState } from "react";
|
||||||
import {Room} from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import {MatrixClient} from "matrix-js-sdk/src/client";
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
import {EventType, RoomType} from "matrix-js-sdk/src/@types/event";
|
import { EventType, RoomType } from "matrix-js-sdk/src/@types/event";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import {sortBy} from "lodash";
|
import { sortBy } from "lodash";
|
||||||
|
|
||||||
import {MatrixClientPeg} from "../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||||
import dis from "../../dispatcher/dispatcher";
|
import dis from "../../dispatcher/dispatcher";
|
||||||
import {_t} from "../../languageHandler";
|
import { _t } from "../../languageHandler";
|
||||||
import AccessibleButton, {ButtonEvent} from "../views/elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent } from "../views/elements/AccessibleButton";
|
||||||
import BaseDialog from "../views/dialogs/BaseDialog";
|
import BaseDialog from "../views/dialogs/BaseDialog";
|
||||||
import Spinner from "../views/elements/Spinner";
|
import Spinner from "../views/elements/Spinner";
|
||||||
import SearchBox from "./SearchBox";
|
import SearchBox from "./SearchBox";
|
||||||
import RoomAvatar from "../views/avatars/RoomAvatar";
|
import RoomAvatar from "../views/avatars/RoomAvatar";
|
||||||
import RoomName from "../views/elements/RoomName";
|
import RoomName from "../views/elements/RoomName";
|
||||||
import {useAsyncMemo} from "../../hooks/useAsyncMemo";
|
import { useAsyncMemo } from "../../hooks/useAsyncMemo";
|
||||||
import {EnhancedMap} from "../../utils/maps";
|
import { EnhancedMap } from "../../utils/maps";
|
||||||
import StyledCheckbox from "../views/elements/StyledCheckbox";
|
import StyledCheckbox from "../views/elements/StyledCheckbox";
|
||||||
import AutoHideScrollbar from "./AutoHideScrollbar";
|
import AutoHideScrollbar from "./AutoHideScrollbar";
|
||||||
import BaseAvatar from "../views/avatars/BaseAvatar";
|
import BaseAvatar from "../views/avatars/BaseAvatar";
|
||||||
import {mediaFromMxc} from "../../customisations/Media";
|
import { mediaFromMxc } from "../../customisations/Media";
|
||||||
import InfoTooltip from "../views/elements/InfoTooltip";
|
import InfoTooltip from "../views/elements/InfoTooltip";
|
||||||
import TextWithTooltip from "../views/elements/TextWithTooltip";
|
import TextWithTooltip from "../views/elements/TextWithTooltip";
|
||||||
import {useStateToggle} from "../../hooks/useStateToggle";
|
import { useStateToggle } from "../../hooks/useStateToggle";
|
||||||
import {getChildOrder} from "../../stores/SpaceStore";
|
import { getChildOrder } from "../../stores/SpaceStore";
|
||||||
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton";
|
import AccessibleTooltipButton from "../views/elements/AccessibleTooltipButton";
|
||||||
import {linkifyElement} from "../../HtmlUtils";
|
import { linkifyElement } from "../../HtmlUtils";
|
||||||
|
|
||||||
interface IHierarchyProps {
|
interface IHierarchyProps {
|
||||||
space: Room;
|
space: Room;
|
||||||
|
|
|
@ -14,23 +14,23 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, {InputHTMLAttributes, LegacyRef} from "react";
|
import React, { InputHTMLAttributes, LegacyRef } from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import {Room} from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
|
||||||
import RoomAvatar from "../avatars/RoomAvatar";
|
import RoomAvatar from "../avatars/RoomAvatar";
|
||||||
import SpaceStore from "../../../stores/SpaceStore";
|
import SpaceStore from "../../../stores/SpaceStore";
|
||||||
import SpaceTreeLevelLayoutStore from "../../../stores/SpaceTreeLevelLayoutStore";
|
import SpaceTreeLevelLayoutStore from "../../../stores/SpaceTreeLevelLayoutStore";
|
||||||
import NotificationBadge from "../rooms/NotificationBadge";
|
import NotificationBadge from "../rooms/NotificationBadge";
|
||||||
import {RovingAccessibleButton} from "../../../accessibility/roving/RovingAccessibleButton";
|
import { RovingAccessibleButton } from "../../../accessibility/roving/RovingAccessibleButton";
|
||||||
import {RovingAccessibleTooltipButton} from "../../../accessibility/roving/RovingAccessibleTooltipButton";
|
import { RovingAccessibleTooltipButton } from "../../../accessibility/roving/RovingAccessibleTooltipButton";
|
||||||
import IconizedContextMenu, {
|
import IconizedContextMenu, {
|
||||||
IconizedContextMenuOption,
|
IconizedContextMenuOption,
|
||||||
IconizedContextMenuOptionList,
|
IconizedContextMenuOptionList,
|
||||||
} from "../context_menus/IconizedContextMenu";
|
} from "../context_menus/IconizedContextMenu";
|
||||||
import {_t} from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import {ContextMenuTooltipButton} from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
import { ContextMenuTooltipButton } from "../../../accessibility/context_menu/ContextMenuTooltipButton";
|
||||||
import {toRightOf} from "../../structures/ContextMenu";
|
import { toRightOf } from "../../structures/ContextMenu";
|
||||||
import {
|
import {
|
||||||
shouldShowSpaceSettings,
|
shouldShowSpaceSettings,
|
||||||
showAddExistingRooms,
|
showAddExistingRooms,
|
||||||
|
@ -39,15 +39,15 @@ import {
|
||||||
showSpaceSettings,
|
showSpaceSettings,
|
||||||
} from "../../../utils/space";
|
} from "../../../utils/space";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
import AccessibleButton, {ButtonEvent} from "../elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
|
||||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||||
import {Action} from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import RoomViewStore from "../../../stores/RoomViewStore";
|
import RoomViewStore from "../../../stores/RoomViewStore";
|
||||||
import {SetRightPanelPhasePayload} from "../../../dispatcher/payloads/SetRightPanelPhasePayload";
|
import { SetRightPanelPhasePayload } from "../../../dispatcher/payloads/SetRightPanelPhasePayload";
|
||||||
import {RightPanelPhases} from "../../../stores/RightPanelStorePhases";
|
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
|
||||||
import {EventType} from "matrix-js-sdk/src/@types/event";
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
import {StaticNotificationState} from "../../../stores/notifications/StaticNotificationState";
|
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
||||||
import {NotificationColor} from "../../../stores/notifications/NotificationColor";
|
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
|
||||||
|
|
||||||
interface IItemProps extends InputHTMLAttributes<HTMLLIElement> {
|
interface IItemProps extends InputHTMLAttributes<HTMLLIElement> {
|
||||||
space?: Room;
|
space?: Room;
|
||||||
|
|
|
@ -62,14 +62,13 @@ const partitionSpacesAndRooms = (arr: Room[]): [Room[], Room[]] => { // [spaces,
|
||||||
}, [[], []]);
|
}, [[], []]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const validOrder = (order: string): string | null => {
|
const validOrder = (order: string): string | undefined => {
|
||||||
if (typeof order === "string" && order.length <= 50 && Array.from(order).every((c: string) => {
|
if (typeof order === "string" && order.length <= 50 && Array.from(order).every((c: string) => {
|
||||||
const charCode = c.charCodeAt(0);
|
const charCode = c.charCodeAt(0);
|
||||||
return charCode >= 0x20 && charCode <= 0x7E;
|
return charCode >= 0x20 && charCode <= 0x7E;
|
||||||
})) {
|
})) {
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// For sorting space children using a validated `order`, `m.room.create`'s `origin_server_ts`, `room_id`
|
// For sorting space children using a validated `order`, `m.room.create`'s `origin_server_ts`, `room_id`
|
||||||
|
@ -639,7 +638,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
try {
|
try {
|
||||||
await this.matrixClient.setRoomAccountData(space.roomId, EventType.SpaceOrder, { order });
|
await this.matrixClient.setRoomAccountData(space.roomId, EventType.SpaceOrder, { order });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Failed to set root space order", e);
|
console.warn("Failed to set root space order", e);
|
||||||
if (this.spaceOrderLocalEchoMap.get(space.roomId) === order) {
|
if (this.spaceOrderLocalEchoMap.get(space.roomId) === order) {
|
||||||
this.spaceOrderLocalEchoMap.delete(space.roomId);
|
this.spaceOrderLocalEchoMap.delete(space.roomId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ export function arrayMerge<T>(...a: T[][]): T[] {
|
||||||
* @param toIndex the index of where to put the element.
|
* @param toIndex the index of where to put the element.
|
||||||
* @returns A new array with the requested value moved.
|
* @returns A new array with the requested value moved.
|
||||||
*/
|
*/
|
||||||
export function reorder<T>(list: T[], fromIndex: number, toIndex: number): T[] {
|
export function moveElement<T>(list: T[], fromIndex: number, toIndex: number): T[] {
|
||||||
const result = Array.from(list);
|
const result = Array.from(list);
|
||||||
const [removed] = result.splice(fromIndex, 1);
|
const [removed] = result.splice(fromIndex, 1);
|
||||||
result.splice(toIndex, 0, removed);
|
result.splice(toIndex, 0, removed);
|
||||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
import { alphabetPad, baseToString, stringToBase, DEFAULT_ALPHABET } from "matrix-js-sdk/src/utils";
|
import { alphabetPad, baseToString, stringToBase, DEFAULT_ALPHABET } from "matrix-js-sdk/src/utils";
|
||||||
|
|
||||||
import { reorder } from "./arrays";
|
import { moveElement } from "./arrays";
|
||||||
|
|
||||||
export const midPointsBetweenStrings = (
|
export const midPointsBetweenStrings = (
|
||||||
a: string,
|
a: string,
|
||||||
|
@ -73,7 +73,7 @@ export const reorderLexicographically = (
|
||||||
// zip orders with their indices to simplify later index wrangling
|
// zip orders with their indices to simplify later index wrangling
|
||||||
const ordersWithIndices: IEntry[] = orders.map((order, index) => ({ index, order }));
|
const ordersWithIndices: IEntry[] = orders.map((order, index) => ({ index, order }));
|
||||||
// apply the fundamental order update to the zipped array
|
// apply the fundamental order update to the zipped array
|
||||||
const newOrder = reorder(ordersWithIndices, fromIndex, toIndex);
|
const newOrder = moveElement(ordersWithIndices, fromIndex, toIndex);
|
||||||
|
|
||||||
// check if we have to fill undefined orders to complete placement
|
// check if we have to fill undefined orders to complete placement
|
||||||
const orderToLeftUndefined = newOrder[toIndex - 1]?.order === undefined;
|
const orderToLeftUndefined = newOrder[toIndex - 1]?.order === undefined;
|
||||||
|
|
Loading…
Reference in New Issue