Page MenuHomePhabricator

[native] Reintroduce `updateClientDBThreadStoreThreadInfos`
ClosedPublic

Authored by atul on Feb 15 2024, 1:00 PM.
Tags
None
Referenced Files
F3367233: D11097.id37381.diff
Mon, Nov 25, 2:15 PM
Unknown Object (File)
Thu, Nov 7, 3:08 AM
Unknown Object (File)
Oct 15 2024, 7:48 PM
Unknown Object (File)
Oct 15 2024, 7:48 PM
Unknown Object (File)
Oct 15 2024, 7:48 PM
Unknown Object (File)
Oct 15 2024, 7:48 PM
Unknown Object (File)
Oct 15 2024, 7:48 PM
Unknown Object (File)
Sep 16 2024, 10:05 AM
Subscribers

Details

Summary

Similar to D11095, we reintroduce updateClientDBThreadStoreThreadInfos based heavily on the deprecated version. I specify the changes inline.


Depends on D11095

Test Plan

This gets consumed for the first time in the upcoming specialRoles migration where it will be tested implicitly.

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul requested review of this revision.Feb 15 2024, 1:17 PM

Could you link to the code that you're reintroducing?

I specify the changes inline.

This seems to be missed.

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

Sorry, added annotation showing original code.

native/redux/client-db-utils.js
29–53

Here's the code it's based on:

function deprecatedUpdateClientDBThreadStoreThreadInfos(
  state: AppState,
  migrationFunc: MixedRawThreadInfos => MixedRawThreadInfos,
  handleMigrationFailure?: AppState => AppState,
): AppState {
  // Get threads from SQLite `threads` table.
  const clientDBThreadInfos = commCoreModule.getAllThreadsSync();

  const operations = deprecatedCreateUpdateDBOpsForThreadStoreThreadInfos(
    clientDBThreadInfos,
    migrationFunc,
  );

  // Try processing `ClientDBThreadStoreOperation`s and log out if
  //    `processThreadStoreOperationsSync(...)` throws an exception.
  try {
    commCoreModule.processThreadStoreOperationsSync(operations);
  } catch (exception) {
    console.log(exception);
    if (handleMigrationFailure) {
      return handleMigrationFailure(state);
    }
    return ({ ...state, cookie: null }: any);
  }

  return state;
}

As well as screenshot with correct syntax highlighting + type hints:

82faa1.png (1×2 px, 295 KB)

This revision was landed with ongoing or failed builds.Feb 20 2024, 12:19 PM
This revision was automatically updated to reflect the committed changes.