Skip to content

Commit

Permalink
refactor: sliding sync: swap to lists-as-keys (#3086)
Browse files Browse the repository at this point in the history
* refactor: sliding sync: swap to lists-as-keys

Update the request/response API shape to match the latest
MSC3575 version, which converts `lists` from being an array
of list objects to being a map of list objects.

* Linting

* prettier

* add extra setListRanges test

* Default to right type
  • Loading branch information
kegsay authored Jan 23, 2023
1 parent 02aa3ed commit 6cf6a0c
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 236 deletions.
9 changes: 4 additions & 5 deletions spec/integ/sliding-sync-sdk.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ describe("SlidingSyncSdk", () => {
const selfAccessToken = "aseukfgwef";

const mockifySlidingSync = (s: SlidingSync): SlidingSync => {
s.getList = jest.fn();
s.getListParams = jest.fn();
s.getListData = jest.fn();
s.getRoomSubscriptions = jest.fn();
s.listLength = jest.fn();
s.modifyRoomSubscriptionInfo = jest.fn();
s.modifyRoomSubscriptions = jest.fn();
s.registerExtension = jest.fn();
Expand Down Expand Up @@ -115,7 +114,7 @@ describe("SlidingSyncSdk", () => {
const testClient = new TestClient(selfUserId, "DEVICE", selfAccessToken);
httpBackend = testClient.httpBackend;
client = testClient.client;
mockSlidingSync = mockifySlidingSync(new SlidingSync("", [], {}, client, 0));
mockSlidingSync = mockifySlidingSync(new SlidingSync("", new Map(), {}, client, 0));
if (testOpts.withCrypto) {
httpBackend!.when("GET", "/room_keys/version").respond(404, {});
await client!.initCrypto();
Expand Down Expand Up @@ -549,7 +548,7 @@ describe("SlidingSyncSdk", () => {
it("emits SyncState.Reconnecting when < FAILED_SYNC_ERROR_THRESHOLD & SyncState.Error when over", async () => {
mockSlidingSync!.emit(SlidingSyncEvent.Lifecycle, SlidingSyncState.Complete, {
pos: "h",
lists: [],
lists: {},
rooms: {},
extensions: {},
});
Expand Down Expand Up @@ -577,7 +576,7 @@ describe("SlidingSyncSdk", () => {
it("emits SyncState.Syncing after a previous SyncState.Error", async () => {
mockSlidingSync!.emit(SlidingSyncEvent.Lifecycle, SlidingSyncState.Complete, {
pos: "i",
lists: [],
lists: {},
rooms: {},
extensions: {},
});
Expand Down
Loading

0 comments on commit 6cf6a0c

Please sign in to comment.