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
Unknown Object (File)
Wed, Apr 3, 7:39 AM
Unknown Object (File)
Wed, Apr 3, 7:39 AM
Unknown Object (File)
Wed, Apr 3, 7:39 AM
Unknown Object (File)
Wed, Apr 3, 7:39 AM
Unknown Object (File)
Wed, Apr 3, 7:32 AM
Unknown Object (File)
Thu, Mar 28, 11:15 AM
Unknown Object (File)
Feb 26 2024, 4:40 AM
Unknown Object (File)
Feb 26 2024, 4:40 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