Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/__tests__/lib/exampleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const stream: Stream = makeStream({
description: 'An example stream.',
});

const displayRecipientFromUser = (user: User): PmRecipientUser => {
export const displayRecipientFromUser = (user: User): PmRecipientUser => {
const { email, full_name, user_id: id } = user;
return deepFreeze({
email,
Expand Down Expand Up @@ -337,6 +337,7 @@ export const action = deepFreeze({
realm_users: [],
user_id: 4,
realm_user_groups: [],
recent_private_conversations: [],
streams: [],
never_subscribed: [],
subscriptions: [],
Expand Down
6 changes: 6 additions & 0 deletions src/api/initialDataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
CrossRealmBot,
RealmEmojiById,
RealmFilter,
RecentPrivateConversation,
Stream,
Subscription,
User,
Expand Down Expand Up @@ -107,6 +108,10 @@ export type InitialDataRealmUserGroups = {|
realm_user_groups: UserGroup[],
|};

export type InitialDataRecentPmConversations = {|
recent_private_conversations: RecentPrivateConversation[],
|};

type NeverSubscribedStream = {|
description: string,
invite_only: boolean,
Expand Down Expand Up @@ -273,6 +278,7 @@ export type InitialData = {|
...InitialDataRealmFilters,
...InitialDataRealmUser,
...InitialDataRealmUserGroups,
...InitialDataRecentPmConversations,
...InitialDataStream,
...InitialDataSubscription,
...InitialDataUpdateDisplaySettings,
Expand Down
23 changes: 23 additions & 0 deletions src/api/modelTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,26 @@ export type Message = $ReadOnly<{
subject: string,
subject_links: $ReadOnlyArray<string>,
}>;

//
//
//
// ===================================================================
// Summaries of messages and conversations.
//
//

/**
* Describes a recent PM conversation.
*
* See https://github.com/zulip/zulip/commit/4c3c669b4#diff-2c2aa234cb4a0120fa5f2eeaf8a94fa2R283
* for the structure of this type and the meaning of its properties.
*
* `user_ids` does not contain the `user_id` of the current user. Consequently,
* a user's conversation with themselves will return [], which is unlike the
* behaviour found in other parts of codebase.
*/
export type RecentPrivateConversation = {|
max_message_id: number,
user_ids: number[],
|};
2 changes: 2 additions & 0 deletions src/boot/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import nav from '../nav/navReducer';
import outbox from '../outbox/outboxReducer';
import presence from '../presence/presenceReducer';
import realm from '../realm/realmReducer';
import recentPrivateConversations from '../pm-conversations/recentPmConversationsReducer';
import session from '../session/sessionReducer';
import settings from '../settings/settingsReducer';
import streams from '../streams/streamsReducer';
Expand Down Expand Up @@ -50,6 +51,7 @@ const reducers = {
outbox,
presence,
realm,
recentPrivateConversations,
session,
settings,
streams,
Expand Down
6 changes: 3 additions & 3 deletions src/boot/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export const storeKeys: Array<$Keys<GlobalState>> = [
* don't have to re-download it.
*/
// prettier-ignore
export const cacheKeys: Array<$Keys<GlobalState>> = [
'flags', 'messages', 'mute', 'narrows', 'realm', 'streams',
'subscriptions', 'unread', 'userGroups', 'users',
export const cacheKeys = [
'flags', 'messages', 'mute', 'narrows', 'realm', 'recentPrivateConversations',
'streams', 'subscriptions', 'unread', 'userGroups', 'users',
];

/**
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const config: Config = {
'realm_filters',
'realm_user',
'realm_user_groups',
'recent_private_conversations',
'stream',
'subscription',
'update_display_settings',
Expand Down
4 changes: 4 additions & 0 deletions src/directSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
Subscription,
Stream,
Outbox,
RecentPrivateConversation,
User,
UserGroup,
UserStatusState,
Expand Down Expand Up @@ -83,6 +84,9 @@ export const getSubscriptions = (state: GlobalState): Subscription[] => state.su
*/
export const getStreams = (state: GlobalState): Stream[] => state.streams;

export const getRecentPrivateConversations = (state: GlobalState): RecentPrivateConversation[] =>
state.recentPrivateConversations;

export const getPresence = (state: GlobalState): PresenceState => state.presence;

export const getOutbox = (state: GlobalState): Outbox[] => state.outbox;
Expand Down
Loading