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
F3387333: D7664.diff
Fri, Nov 29, 8:55 AM
Unknown Object (File)
Tue, Nov 26, 11:39 PM
Unknown Object (File)
Mon, Nov 25, 8:50 PM
Unknown Object (File)
Mon, Nov 25, 8:50 PM
Unknown Object (File)
Mon, Nov 25, 8:50 PM
Unknown Object (File)
Sat, Nov 23, 9:30 AM
Unknown Object (File)
Sat, Nov 23, 9:09 AM
Unknown Object (File)
Sat, Nov 23, 5:58 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
Lint Not Applicable
Unit
Tests Not Applicable

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