Page MenuHomePhabricator

[lib] make fields in setting client store action optional
ClosedPublic

Authored by kamil on Apr 27 2023, 7:36 AM.
Tags
None
Referenced Files
F3352448: D7664.diff
Sat, Nov 23, 5:58 AM
Unknown Object (File)
Sat, Nov 2, 1:01 AM
Unknown Object (File)
Sat, Nov 2, 1:01 AM
Unknown Object (File)
Sat, Nov 2, 1:01 AM
Unknown Object (File)
Sat, Nov 2, 12:55 AM
Unknown Object (File)
Fri, Oct 25, 7:19 AM
Unknown Object (File)
Fri, Oct 25, 7:19 AM
Unknown Object (File)
Oct 20 2024, 11:13 AM
Subscribers

Details

Summary

I want to reuse this logic on the web, but only drafts are stored in the web database for now. Dispatching this with empty objects will affect the store, so we have somehow tell reducer that values are missing.

A different approach will be introducing a new action type, with only drafts, and using it in draft reducer only - in reviewers think that this is better I am open to updating this.

Depends on D7662

Test Plan

Check on native is this does not affect current logic

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Apr 27 2023, 7:58 AM

Should be ok both ways, but having a separate action is safer - the typesystem checks if all the required fields are set. And on native, not setting some fields, is probably an error state. We can also consider keeping one action but typing it safer, e.g.

+payload: {
  +platform: 'native'
  +currentUserID: ?string,
  +drafts: $ReadOnlyArray<ClientDBDraftInfo>,
  +messages: $ReadOnlyArray<ClientDBMessageInfo>,
  +threadStore: ThreadStore,
  +messageStoreThreads: $ReadOnlyArray<ClientDBThreadMessageInfo>,
} | {
  +platform: 'web'
  +currentUserID: ?string,
  +drafts: $ReadOnlyArray<ClientDBDraftInfo>,
}
lib/reducers/thread-reducer.js
475–486 ↗(On Diff #25849)
This revision is now accepted and ready to land.Apr 28 2023, 4:24 AM

address review, rebase before landing