iterate PR
This commit is contained in:
parent
a63d9220d2
commit
cee294f5a7
6 changed files with 34 additions and 35 deletions
|
@ -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) => {
|
||||
const charCode = c.charCodeAt(0);
|
||||
return charCode >= 0x20 && charCode <= 0x7E;
|
||||
})) {
|
||||
return order;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
// 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 {
|
||||
await this.matrixClient.setRoomAccountData(space.roomId, EventType.SpaceOrder, { order });
|
||||
} 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) {
|
||||
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.
|
||||
* @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 [removed] = result.splice(fromIndex, 1);
|
||||
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 { reorder } from "./arrays";
|
||||
import { moveElement } from "./arrays";
|
||||
|
||||
export const midPointsBetweenStrings = (
|
||||
a: string,
|
||||
|
@ -73,7 +73,7 @@ export const reorderLexicographically = (
|
|||
// zip orders with their indices to simplify later index wrangling
|
||||
const ordersWithIndices: IEntry[] = orders.map((order, index) => ({ index, order }));
|
||||
// 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
|
||||
const orderToLeftUndefined = newOrder[toIndex - 1]?.order === undefined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue