Skip to content

Commit b199fd2

Browse files
committed
flags: Cut never-used flags from state.flags
These all used to be genuine UserMessage flags in the server's model, and so presumably in the API, but no longer are (and haven't been for years.) In zulip-mobile, they were all first mentioned in 72f3391 in 2017-06, and they all have the same history here: we've never touched them except in (a) initializing the flags state and (b) tests. The name `is_me_message` shows up a bit more in the history because it's also the name of a property on Message itself, but its history as a flag is the same. (For that matter, we've never actually used the Message property either.)
1 parent 2cd4cf7 commit b199fd2

File tree

7 files changed

+15
-354
lines changed

7 files changed

+15
-354
lines changed

src/chat/__tests__/flagsReducer-test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,8 @@ describe('flagsReducer', () => {
323323
collapsed: { 1: true },
324324
mentioned: { 1: true },
325325
wildcard_mentioned: { 1: true },
326-
summarize_in_home: { 1: true },
327-
summarize_in_stream: { 1: true },
328-
force_expand: { 1: true },
329-
force_collapse: { 1: true },
330326
has_alert_word: { 1: true },
331327
historical: { 1: true },
332-
is_me_message: { 1: true },
333328
});
334329

335330
const action = deepFreeze({
@@ -342,13 +337,8 @@ describe('flagsReducer', () => {
342337
collapsed: {},
343338
mentioned: {},
344339
wildcard_mentioned: {},
345-
summarize_in_home: {},
346-
summarize_in_stream: {},
347-
force_expand: {},
348-
force_collapse: {},
349340
has_alert_word: {},
350341
historical: {},
351-
is_me_message: {},
352342
};
353343

354344
const actualState = flagsReducer(prevState, action);

src/chat/flagsReducer.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@ const initialState = {
2424
collapsed: {},
2525
mentioned: {},
2626
wildcard_mentioned: {},
27-
summarize_in_home: {},
28-
summarize_in_stream: {},
29-
force_expand: {},
30-
force_collapse: {},
3127
has_alert_word: {},
3228
historical: {},
33-
is_me_message: {},
3429
};
3530

3631
const addFlagsForMessages = (

src/reduxTypes.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ import type { MuteState } from './mute/muteModelTypes';
3737
import type { PmConversationsState } from './pm-conversations/pmConversationsModel';
3838
import type { UnreadState } from './unread/unreadModelTypes';
3939
import type { UserStatusesState } from './user-statuses/userStatusesCore';
40-
import type { ServerEmojiData } from './api/modelTypes';
40+
import type { ServerEmojiData, UserMessageFlag } from './api/modelTypes';
4141
import type { EmailAddressVisibility } from './api/permissionsTypes';
42+
import { typesEquivalent } from './generics';
4243

4344
export type { MuteState } from './mute/muteModelTypes';
4445
export type { UserStatusesState } from './user-statuses/userStatusesCore';
4546
export type * from './actionTypes';
4647

48+
/* eslint-disable no-unused-expressions */
49+
4750
/**
4851
* The list of known accounts, with the active account first.
4952
*
@@ -129,27 +132,18 @@ export type FetchingState = $ReadOnly<{|
129132
* `state.messages`.
130133
*/
131134
export type FlagsState = $ReadOnly<{|
132-
// Flags that are currently documented in the API:
133-
// https://zulip.com/api/update-message-flags#available-flags
134-
// i.e., those found in `UserMessageFlag`.
135135
read: {| +[messageId: number]: true |},
136136
starred: {| +[messageId: number]: true |},
137137
collapsed: {| +[messageId: number]: true |},
138138
mentioned: {| +[messageId: number]: true |},
139139
wildcard_mentioned: {| +[messageId: number]: true |},
140140
has_alert_word: {| +[messageId: number]: true |},
141141
historical: {| +[messageId: number]: true |},
142-
143-
// Flags not documented in the API.
144-
// TODO(server): Do these ever exist? Did they use to and get removed?
145-
summarize_in_home: {| +[messageId: number]: true |},
146-
summarize_in_stream: {| +[messageId: number]: true |},
147-
force_expand: {| +[messageId: number]: true |},
148-
force_collapse: {| +[messageId: number]: true |},
149-
is_me_message: {| +[messageId: number]: true |},
150142
|}>;
151143

152-
export type FlagName = $Keys<FlagsState>;
144+
// The flags in FlagsState correspond with those in the server API,
145+
// as expressed by UserMessageFlag.
146+
typesEquivalent<$Keys<FlagsState>, UserMessageFlag>();
153147

154148
/**
155149
* A map with all messages we've stored locally, indexed by ID.
@@ -427,7 +421,7 @@ export type SettingsState = $ReadOnly<{|
427421
// As part of letting GlobalState freely convert to PerAccountState,
428422
// we'll want the same for SettingsState. (This is also why
429423
// PerAccountSettingsState is inexact.)
430-
(s: SettingsState): PerAccountSettingsState => s; // eslint-disable-line no-unused-expressions
424+
(s: SettingsState): PerAccountSettingsState => s;
431425

432426
export type StreamsState = $ReadOnlyArray<Stream>;
433427

@@ -587,7 +581,7 @@ export function dubJointState(state: GlobalState): GlobalState & PerAccountState
587581
type NonMaybeProperties<O: { ... }> = $ObjMap<O, <V>(V) => $NonMaybeType<V>>;
588582
type NonMaybeGlobalState = NonMaybeProperties<GlobalState>;
589583
// This function definition will fail typechecking if GlobalState is wrong.
590-
(s: GlobalState): NonMaybeGlobalState => s; // eslint-disable-line no-unused-expressions
584+
(s: GlobalState): NonMaybeGlobalState => s;
591585

592586
/** A per-account selector returning TResult, with extra parameter TParam. */
593587
// Seems like this should be OutputSelector... but for whatever reason,
@@ -632,7 +626,6 @@ export interface GlobalDispatch {
632626
// specific account), but for now it needs none.
633627
export type GlobalThunkAction<T> = (GlobalDispatch, () => GlobalState) => T;
634628

635-
/* eslint-disable no-unused-expressions */
636629
// The two pairs of dispatch/thunk-action types aren't interchangeable,
637630
// in either direction.
638631
// $FlowExpectedError[incompatible-return]

src/storage/__tests__/migrations-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('migrations', () => {
104104
// What `base` becomes after all migrations.
105105
const endBase = {
106106
...base52,
107-
migrations: { version: 54 },
107+
migrations: { version: 55 },
108108
};
109109

110110
for (const [desc, before, after] of [
@@ -127,8 +127,8 @@ describe('migrations', () => {
127127
// redundant with this one, because none of the migration steps notice
128128
// whether any properties outside `storeKeys` are present or not.
129129
[
130-
'check dropCache at 54',
131-
{ ...endBase, migrations: { version: 53 }, mute: [], nonsense: [1, 2, 3] },
130+
'check dropCache at 55',
131+
{ ...endBase, migrations: { version: 54 }, mute: [], nonsense: [1, 2, 3] },
132132
endBase,
133133
],
134134

src/storage/migrations.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ const migrationsInner: {| [string]: (LessPartialState) => LessPartialState |} =
466466
// Add emailAddressVisibility to state.realm
467467
'54': dropCache,
468468

469+
// Drop old never-used message flags from state.flags.
470+
'55': dropCache,
471+
469472
// TIP: When adding a migration, consider just using `dropCache`.
470473
// (See its jsdoc for guidance on when that's the right answer.)
471474
};

src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android

Lines changed: 0 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,70 +1627,6 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
16271627

16281628

16291629

1630-
</div>
1631-
1632-
</div>"
1633-
`;
1634-
1635-
exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with flag: force_collapse 1`] = `
1636-
"<div class=\\"msglist-element timerow\\" data-msg-id=\\"1\\">
1637-
<div class=\\"timerow-left\\"></div>
1638-
Dec 31, 1969
1639-
<div class=\\"timerow-right\\"></div>
1640-
</div><div class=\\"msglist-element header-wrapper header stream-header topic-header\\" data-msg-id=\\"1\\" data-narrow=\\"dG9waWM6MTpleGFtcGxlIHRvcGlj\\">
1641-
<div class=\\"header stream-text\\" style=\\"color: black;
1642-
background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\">
1643-
# stream 1
1644-
</div>
1645-
<div class=\\"topic-text\\">example topic</div>
1646-
<div class=\\"topic-date\\">Dec 31, 1969</div>
1647-
</div><div class=\\"msglist-element message message-full\\" id=\\"msg-1\\" data-msg-id=\\"1\\" data-mute-state=\\"shown\\" data-force_collapse=\\"true\\">
1648-
<div class=\\"avatar\\">
1649-
<img src=\\"https://zulip.example.org/yo/avatar-10.png\\" alt=\\"Nonrandom name sender User\\" class=\\"avatar-img\\" data-sender-id=\\"10\\">
1650-
</div>
1651-
<div class=\\"content\\">
1652-
<div class=\\"subheader\\">
1653-
<div class=\\"name-and-status-emoji\\" data-sender-id=\\"10\\">
1654-
Nonrandom name sender User
1655-
</div>
1656-
<div class=\\"static-timestamp\\">11:59 PM</div>
1657-
</div>
1658-
<p>This is an example stream message.</p>
1659-
1660-
1661-
1662-
</div>
1663-
1664-
</div>"
1665-
`;
1666-
1667-
exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with flag: force_expand 1`] = `
1668-
"<div class=\\"msglist-element timerow\\" data-msg-id=\\"1\\">
1669-
<div class=\\"timerow-left\\"></div>
1670-
Dec 31, 1969
1671-
<div class=\\"timerow-right\\"></div>
1672-
</div><div class=\\"msglist-element header-wrapper header stream-header topic-header\\" data-msg-id=\\"1\\" data-narrow=\\"dG9waWM6MTpleGFtcGxlIHRvcGlj\\">
1673-
<div class=\\"header stream-text\\" style=\\"color: black;
1674-
background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\">
1675-
# stream 1
1676-
</div>
1677-
<div class=\\"topic-text\\">example topic</div>
1678-
<div class=\\"topic-date\\">Dec 31, 1969</div>
1679-
</div><div class=\\"msglist-element message message-full\\" id=\\"msg-1\\" data-msg-id=\\"1\\" data-mute-state=\\"shown\\" data-force_expand=\\"true\\">
1680-
<div class=\\"avatar\\">
1681-
<img src=\\"https://zulip.example.org/yo/avatar-10.png\\" alt=\\"Nonrandom name sender User\\" class=\\"avatar-img\\" data-sender-id=\\"10\\">
1682-
</div>
1683-
<div class=\\"content\\">
1684-
<div class=\\"subheader\\">
1685-
<div class=\\"name-and-status-emoji\\" data-sender-id=\\"10\\">
1686-
Nonrandom name sender User
1687-
</div>
1688-
<div class=\\"static-timestamp\\">11:59 PM</div>
1689-
</div>
1690-
<p>This is an example stream message.</p>
1691-
1692-
1693-
16941630
</div>
16951631

16961632
</div>"
@@ -1755,38 +1691,6 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
17551691

17561692

17571693

1758-
</div>
1759-
1760-
</div>"
1761-
`;
1762-
1763-
exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with flag: is_me_message 1`] = `
1764-
"<div class=\\"msglist-element timerow\\" data-msg-id=\\"1\\">
1765-
<div class=\\"timerow-left\\"></div>
1766-
Dec 31, 1969
1767-
<div class=\\"timerow-right\\"></div>
1768-
</div><div class=\\"msglist-element header-wrapper header stream-header topic-header\\" data-msg-id=\\"1\\" data-narrow=\\"dG9waWM6MTpleGFtcGxlIHRvcGlj\\">
1769-
<div class=\\"header stream-text\\" style=\\"color: black;
1770-
background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\">
1771-
# stream 1
1772-
</div>
1773-
<div class=\\"topic-text\\">example topic</div>
1774-
<div class=\\"topic-date\\">Dec 31, 1969</div>
1775-
</div><div class=\\"msglist-element message message-full\\" id=\\"msg-1\\" data-msg-id=\\"1\\" data-mute-state=\\"shown\\" data-is_me_message=\\"true\\">
1776-
<div class=\\"avatar\\">
1777-
<img src=\\"https://zulip.example.org/yo/avatar-10.png\\" alt=\\"Nonrandom name sender User\\" class=\\"avatar-img\\" data-sender-id=\\"10\\">
1778-
</div>
1779-
<div class=\\"content\\">
1780-
<div class=\\"subheader\\">
1781-
<div class=\\"name-and-status-emoji\\" data-sender-id=\\"10\\">
1782-
Nonrandom name sender User
1783-
</div>
1784-
<div class=\\"static-timestamp\\">11:59 PM</div>
1785-
</div>
1786-
<p>This is an example stream message.</p>
1787-
1788-
1789-
17901694
</div>
17911695

17921696
</div>"
@@ -1888,70 +1792,6 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
18881792
</div>"
18891793
`;
18901794

1891-
exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with flag: summarize_in_home 1`] = `
1892-
"<div class=\\"msglist-element timerow\\" data-msg-id=\\"1\\">
1893-
<div class=\\"timerow-left\\"></div>
1894-
Dec 31, 1969
1895-
<div class=\\"timerow-right\\"></div>
1896-
</div><div class=\\"msglist-element header-wrapper header stream-header topic-header\\" data-msg-id=\\"1\\" data-narrow=\\"dG9waWM6MTpleGFtcGxlIHRvcGlj\\">
1897-
<div class=\\"header stream-text\\" style=\\"color: black;
1898-
background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\">
1899-
# stream 1
1900-
</div>
1901-
<div class=\\"topic-text\\">example topic</div>
1902-
<div class=\\"topic-date\\">Dec 31, 1969</div>
1903-
</div><div class=\\"msglist-element message message-full\\" id=\\"msg-1\\" data-msg-id=\\"1\\" data-mute-state=\\"shown\\" data-summarize_in_home=\\"true\\">
1904-
<div class=\\"avatar\\">
1905-
<img src=\\"https://zulip.example.org/yo/avatar-10.png\\" alt=\\"Nonrandom name sender User\\" class=\\"avatar-img\\" data-sender-id=\\"10\\">
1906-
</div>
1907-
<div class=\\"content\\">
1908-
<div class=\\"subheader\\">
1909-
<div class=\\"name-and-status-emoji\\" data-sender-id=\\"10\\">
1910-
Nonrandom name sender User
1911-
</div>
1912-
<div class=\\"static-timestamp\\">11:59 PM</div>
1913-
</div>
1914-
<p>This is an example stream message.</p>
1915-
1916-
1917-
1918-
</div>
1919-
1920-
</div>"
1921-
`;
1922-
1923-
exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with flag: summarize_in_stream 1`] = `
1924-
"<div class=\\"msglist-element timerow\\" data-msg-id=\\"1\\">
1925-
<div class=\\"timerow-left\\"></div>
1926-
Dec 31, 1969
1927-
<div class=\\"timerow-right\\"></div>
1928-
</div><div class=\\"msglist-element header-wrapper header stream-header topic-header\\" data-msg-id=\\"1\\" data-narrow=\\"dG9waWM6MTpleGFtcGxlIHRvcGlj\\">
1929-
<div class=\\"header stream-text\\" style=\\"color: black;
1930-
background: hsl(0, 0%, 80%)\\" data-narrow=\\"c3RyZWFtOjE=\\">
1931-
# stream 1
1932-
</div>
1933-
<div class=\\"topic-text\\">example topic</div>
1934-
<div class=\\"topic-date\\">Dec 31, 1969</div>
1935-
</div><div class=\\"msglist-element message message-full\\" id=\\"msg-1\\" data-msg-id=\\"1\\" data-mute-state=\\"shown\\" data-summarize_in_stream=\\"true\\">
1936-
<div class=\\"avatar\\">
1937-
<img src=\\"https://zulip.example.org/yo/avatar-10.png\\" alt=\\"Nonrandom name sender User\\" class=\\"avatar-img\\" data-sender-id=\\"10\\">
1938-
</div>
1939-
<div class=\\"content\\">
1940-
<div class=\\"subheader\\">
1941-
<div class=\\"name-and-status-emoji\\" data-sender-id=\\"10\\">
1942-
Nonrandom name sender User
1943-
</div>
1944-
<div class=\\"static-timestamp\\">11:59 PM</div>
1945-
</div>
1946-
<p>This is an example stream message.</p>
1947-
1948-
1949-
1950-
</div>
1951-
1952-
</div>"
1953-
`;
1954-
19551795
exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with flag: wildcard_mentioned 1`] = `
19561796
"<div class=\\"msglist-element timerow\\" data-msg-id=\\"1\\">
19571797
<div class=\\"timerow-left\\"></div>

0 commit comments

Comments
 (0)