Page MenuHomePhabricator

[sqlite] implement processing community store ops on worker
ClosedPublic

Authored by ginsu on Feb 25 2024, 11:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 28, 4:01 PM
Unknown Object (File)
Sun, Apr 28, 4:01 PM
Unknown Object (File)
Sun, Apr 28, 4:01 PM
Unknown Object (File)
Sun, Apr 28, 4:00 PM
Unknown Object (File)
Sun, Apr 28, 4:00 PM
Unknown Object (File)
Mon, Apr 22, 8:58 AM
Unknown Object (File)
Apr 4 2024, 10:10 AM
Unknown Object (File)
Mar 28 2024, 12:01 PM
Subscribers

Details

Summary

introduce community store + community store ops logic to web worker

Linear task: https://linear.app/comm/issue/ENG-6534/implement-processing-community-store-ops

Depends on D11153

Test Plan

Ran the following code + confirmed things worked as expected

  const TEST_COMMUNITY_1: CommunityInfo = {
    enabledApps: {
      calendar: false,
      wiki: false,
      tasks: true,
      files: true,
    },
  };

  const TEST_COMMUNITY_2: CommunityInfo = {
    enabledApps: {
      calendar: true,
      wiki: false,
      tasks: false,
      files: false,
    },
  };

  const databaseModule = await getDatabaseModule();

  let data = await databaseModule.schedule({
    type: workerRequestMessageTypes.GET_CLIENT_STORE,
  });
  console.log(data.store.communites);

  await databaseModule.schedule({
    type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
    storeOperations: {
      communityStoreOperations: [
        {
          type: 'replace_community',
          payload: {
            id: '1',
            communityInfo: TEST_COMMUNITY_1,
          },
        },
        {
          type: 'replace_community',
          payload: {
            id: '2',
            communityInfo: TEST_COMMUNITY_2,
          },
        },
      ],
    },
  });

  data = await databaseModule.schedule({
    type: workerRequestMessageTypes.GET_CLIENT_STORE,
  });
  console.log(data.store.communites);

  const community2Updated: CommunityInfo = {
    enabledApps: {
      calendar: true,
      wiki: true,
      tasks: true,
      files: true,
    },
  };

  await databaseModule.schedule({
    type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
    storeOperations: {
      communityStoreOperations: [
        {
          type: 'replace_community',
          payload: {
            id: '2',
            communityInfo: community2Updated,
          },
        },
      ],
    },
  });

  data = await databaseModule.schedule({
    type: workerRequestMessageTypes.GET_CLIENT_STORE,
  });
  console.log(data.store.communites);

  await databaseModule.schedule({
    type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
    storeOperations: {
      communityStoreOperations: [
        {
          type: 'remove_communites',
          payload: {
            ids: ['1'],
          },
        },
      ],
    },
  });

  data = await databaseModule.schedule({
    type: workerRequestMessageTypes.GET_CLIENT_STORE,
  });
  console.log(data.store.communities);

await databaseModule.schedule({
  type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
  storeOperations: {
    communityStoreOperations: [
      {
        type: 'remove_all_communities',
      },
    ],
  },
});

data = await databaseModule.schedule({
  type: workerRequestMessageTypes.GET_CLIENT_STORE,
});
console.log(data.store.communites);

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: atul, inka, kamil.
ginsu edited the test plan for this revision. (Show Details)
ginsu published this revision for review.Feb 26 2024, 1:08 AM

will make sure ci passes before landing

I don't have any experience with web workers, will defer to other reviewers

This revision is now accepted and ready to land.Feb 27 2024, 1:22 AM