Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant, stringly-typed fields from PmConversationData #4116

Closed
Closed
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
example data: Add auxiliary function makeMessagesState.
... which assembles a `MessagesState` from the `Message`s that compose
it.
rk-for-zulip committed May 20, 2020
commit 1e6668f5adada33592b29ceaec9aa1e29de87980
7 changes: 6 additions & 1 deletion src/__tests__/lib/exampleData.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import deepFreeze from 'deep-freeze';
import { createStore } from 'redux';

import type { CrossRealmBot, Message, PmRecipientUser, Stream, User } from '../../api/modelTypes';
import type { Action, GlobalState, RealmState } from '../../reduxTypes';
import type { Action, GlobalState, MessagesState, RealmState } from '../../reduxTypes';
import type { Auth, Account, Outbox } from '../../types';
import { ZulipVersion } from '../../utils/zulipVersion';
import {
@@ -17,6 +17,7 @@ import rootReducer from '../../boot/reducers';
import { authOfAccount } from '../../account/accountMisc';
import { HOME_NARROW } from '../../utils/narrow';
import { NULL_OBJECT } from '../../nullObjects';
import { objectFromEntries } from '../../jsBackport';

/* ========================================================================
* Utilities
@@ -291,6 +292,10 @@ export const streamMessage = (extra?: $Rest<Message, {}>): Message => {
return deepFreeze({ ...baseMessage, ...extra });
};

/** Construct a MessagesState from a list of messages. */
export const makeMessagesState = (messages: Message[]): MessagesState =>
objectFromEntries(messages.map(m => [m.id, m]));
Comment on lines +296 to +297
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback at #4104 (comment) resolved by a) stripping the exactness from both MessagesState itself (until Flow v0.111.0) and its indexer-property's value type, and b) eliminating the $FlowFixMe entirely.


/* ========================================================================
* Outbox messages
*