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)
Tue, Nov 26, 11:35 PM
Unknown Object (File)
Wed, Nov 13, 7:57 PM
Unknown Object (File)
Tue, Nov 12, 3:48 PM
Unknown Object (File)
Tue, Nov 12, 2:39 PM
Unknown Object (File)
Tue, Nov 12, 2:39 PM
Unknown Object (File)
Tue, Nov 12, 2:18 PM
Unknown Object (File)
Oct 12 2024, 3:34 PM
Unknown Object (File)
Oct 12 2024, 3:34 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
No Lint Coverage
Unit
No Test Coverage

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