Page MenuHomePhabricator

[CommCoreModule] Update thread `REPLACE_OPERATION` to handle `avatar`
ClosedPublic

Authored by atul on Apr 7 2023, 9:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 5, 8:14 AM
Unknown Object (File)
Thu, Dec 5, 8:13 AM
Unknown Object (File)
Thu, Dec 5, 8:13 AM
Unknown Object (File)
Thu, Dec 5, 8:13 AM
Unknown Object (File)
Thu, Dec 5, 8:13 AM
Unknown Object (File)
Nov 10 2024, 6:38 PM
Unknown Object (File)
Nov 10 2024, 6:35 PM
Unknown Object (File)
Nov 10 2024, 2:28 PM
Subscribers

Details

Summary

We need to update construction of REPLACE_OPERATION to handle avatar.

After this diff avatar will be persisted in the SQLite threads table and will REHYDRATE Redux.

NOTE: I am NOT going to include a migration to handle avatars that may already be in the Redux store because there should be no avatars on prod as of this diff landing.
Test Plan
  1. Set thread avatar from native.
  1. Observe that thread avatar is set in serverDB:

27604a.png (122×1 px, 24 KB)

  1. Observe that Redux state on native is updated with avatar:

3afc84.png (182×374 px, 21 KB)

  1. Observe that avatar field is persisted in clientDB threads table.
  1. Observe that avatar is included in SET_CLIENT_DB_STORE action:

caac41.png (1×2 px, 389 KB)

Diff Detail

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

Event Timeline

atul published this revision for review.Apr 7 2023, 9:28 AM
ashoat added a subscriber: rohan.
ashoat added inline comments.
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
641

In D7211, @rohan got a crash when pinnedCount was missing and he called this:

std::lround(threadObj.getProperty(rt, "pinnedCount").asNumber())

I'm not sure which part of that caused the crash... eg. does getProperty() cause a crash if the property doesn't exist, or does asNumber() cause that crash, or does std::lround cause it. But worth making sure that your code doesn't crash if avatar is missing from threadObj

This revision is now accepted and ready to land.Apr 7 2023, 5:50 PM
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
641

Yeah I ensured that mine didn't crash. I'm fairly confident it's the asNumber() call that's causing the crash there.

That's why we first check maybe{Property} before making any further JSI calls that assume truthiness/existence.

atul edited the test plan for this revision. (Show Details)

rebase and land

This revision was landed with ongoing or failed builds.Apr 8 2023, 3:38 PM
This revision was automatically updated to reflect the committed changes.