From a63d9220d2474ffd592c728371107bcfda1ae070 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 15 Jun 2021 08:26:46 +0100 Subject: [PATCH] Clear outstanding TODOs --- src/stores/SpaceStore.tsx | 17 ++++++++++------- test/utils/stringOrderField-test.ts | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/stores/SpaceStore.tsx b/src/stores/SpaceStore.tsx index d0ec573306..9ffb4eb776 100644 --- a/src/stores/SpaceStore.tsx +++ b/src/stores/SpaceStore.tsx @@ -634,9 +634,16 @@ export class SpaceStoreClass extends AsyncStoreWithClient { return sortBy(spaces, [this.getSpaceTagOrdering, "roomId"]); } - private setRootSpaceOrder(space: Room, order: string): void { + private async setRootSpaceOrder(space: Room, order: string): Promise { this.spaceOrderLocalEchoMap.set(space.roomId, order); - this.matrixClient.setRoomAccountData(space.roomId, EventType.SpaceOrder, { order }); // TODO retrying, failure + try { + await this.matrixClient.setRoomAccountData(space.roomId, EventType.SpaceOrder, { order }); + } catch (e) { + console.log("Failed to set root space order", e); + if (this.spaceOrderLocalEchoMap.get(space.roomId) === order) { + this.spaceOrderLocalEchoMap.delete(space.roomId); + } + } } public moveRootSpace(fromIndex: number, toIndex: number): void { @@ -647,11 +654,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { this.setRootSpaceOrder(this.rootSpaces[index], order); }); - if (changes.length) { - this.notifyIfOrderChanged(); - } else { - // TODO - } + this.notifyIfOrderChanged(); } } diff --git a/test/utils/stringOrderField-test.ts b/test/utils/stringOrderField-test.ts index a8bc00eeb9..a523872023 100644 --- a/test/utils/stringOrderField-test.ts +++ b/test/utils/stringOrderField-test.ts @@ -67,7 +67,7 @@ describe("stringOrderField", () => { expect(baseToString(BigInt(6241))).toEqual("`a"); expect(baseToString(BigInt(53), "abcdefghijklmnopqrstuvwxyz")).toEqual("ba"); expect(baseToString(BigInt(1234))).toBe("+}"); - expect(baseToString(BigInt(0))).toBe(""); // TODO + expect(baseToString(BigInt(0))).toBe(""); expect(baseToString(BigInt(1))).toBe(" "); expect(baseToString(BigInt(95))).toBe("~"); expect(baseToString(BigInt(96))).toBe(" ");