Skip to content

Commit 09dc8d3

Browse files
committed
model: Remove various fallbacks for ancient, sometimes prehistoric servers
This completes all our `TODO(#5102)`s.
1 parent 145aeea commit 09dc8d3

9 files changed

+6
-81
lines changed

src/alertWords/__tests__/alertWordsReducer-test.js

-20
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,6 @@ describe('alertWordsReducer', () => {
2626
),
2727
).toEqual(['word', '@mobile-core', 'alert']);
2828
});
29-
30-
// TODO(#5102): Delete; see comment on implementation.
31-
test('when no `alert_words` data is given reset state', () => {
32-
const prevState = deepFreeze(['word']);
33-
const actualState = alertWordsReducer(
34-
prevState,
35-
eg.mkActionRegisterComplete({
36-
// Hmm, we should need a Flow suppression here. This property is
37-
// marked required in InitialData, and this explicit undefined is
38-
// meant to defy that; see TODO(#5102) above.
39-
// mkActionRegisterComplete is designed to accept input with this or
40-
// any property *omitted*… and I think, as a side effect of handling
41-
// that, Flow mistakenly accepts an explicit undefined here, so it
42-
// doesn't catch the resulting malformed InitialData.
43-
alert_words: undefined,
44-
}),
45-
);
46-
47-
expect(actualState).toEqual([]);
48-
});
4929
});
5030

5131
describe('EVENT_ALERT_WORDS', () => {

src/alertWords/alertWordsReducer.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@ export default (
1414
return initialState;
1515

1616
case REGISTER_COMPLETE:
17-
return (
18-
action.data.alert_words
19-
// TODO(#5102): Delete fallback once we enforce any threshold for
20-
// ancient servers we refuse to connect to. It was added in #2878
21-
// (2018-11-16), but it wasn't clear even then, it seems, whether
22-
// any servers actually omit the data. The API doc doesn't mention
23-
// any servers that omit it, and our Flow types mark it required.
24-
|| initialState
25-
);
17+
return action.data.alert_words;
2618

2719
case EVENT_ALERT_WORDS:
2820
return action.alert_words || initialState;

src/api/initialDataTypes.js

-4
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,6 @@ export type InitialDataRealmUser = $ReadOnly<{|
419419
|}>;
420420

421421
export type InitialDataRealmUserGroups = $ReadOnly<{|
422-
// New in Zulip 1.8.
423-
// TODO(#5102): In userGroupsReducer, we still have a fallback for pre-1.8
424-
// servers; remove that, and remove the above comment, which will be
425-
// irrelevant.
426422
realm_user_groups: $ReadOnlyArray<UserGroup>,
427423
|}>;
428424

src/unread/unreadHuddlesReducer.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ export default (
9494
return initialState;
9595

9696
case REGISTER_COMPLETE:
97-
return (
98-
(action.data.unread_msgs && action.data.unread_msgs.huddles)
99-
// TODO(#5102): Delete fallback once we refuse to connect to Zulip
100-
// servers before 1.7.0, when it seems this feature was added; see
101-
// comment on InitialDataUpdateMessageFlags.
102-
|| initialState
103-
);
97+
return action.data.unread_msgs.huddles;
10498

10599
case EVENT_NEW_MESSAGE:
106100
return eventNewMessage(state, action);

src/unread/unreadMentionsReducer.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ export default (
5252
return initialState;
5353

5454
case REGISTER_COMPLETE:
55-
return (
56-
(action.data.unread_msgs && action.data.unread_msgs.mentions)
57-
// TODO(#5102): Delete fallback once we refuse to connect to Zulip
58-
// servers before 1.7.0, when it seems this feature was added; see
59-
// comment on InitialDataUpdateMessageFlags.
60-
|| initialState
61-
);
55+
return action.data.unread_msgs.mentions;
6256

6357
case EVENT_NEW_MESSAGE: {
6458
const { flags } = action.message;

src/unread/unreadModel.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@ function streamsReducer(
129129
return initialStreamsState;
130130

131131
case REGISTER_COMPLETE: {
132-
// TODO(#5102): Delete fallback once we refuse to connect to Zulip
133-
// servers before 1.7.0, when it seems this feature was added; see
134-
// comment on InitialDataUpdateMessageFlags.
135-
// flowlint-next-line unnecessary-optional-chain:off
136-
const data = action.data.unread_msgs?.streams ?? [];
132+
const data = action.data.unread_msgs.streams;
137133

138134
// First, collect together all the data for a given stream, just in a
139135
// plain old Array.

src/unread/unreadPmsReducer.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ export default (
9494
return initialState;
9595

9696
case REGISTER_COMPLETE:
97-
return (
98-
(action.data.unread_msgs && action.data.unread_msgs.pms)
99-
// TODO(#5102): Delete fallback once we refuse to connect to Zulip
100-
// servers before 1.7.0, when it seems this feature was added; see
101-
// comment on InitialDataUpdateMessageFlags.
102-
|| initialState
103-
);
97+
return action.data.unread_msgs.pms;
10498

10599
case EVENT_NEW_MESSAGE:
106100
return eventNewMessage(state, action);

src/user-groups/__tests__/userGroupsReducer-test.js

-20
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,6 @@ describe('userGroupsReducer', () => {
2222
userGroupsReducer(prevState, eg.mkActionRegisterComplete({ realm_user_groups: [group] })),
2323
).toEqual([group]);
2424
});
25-
26-
// TODO(#5102): Remove this test case, which is for pre-1.8 servers.
27-
test('when no data is given reset state', () => {
28-
const prevState = deepFreeze([eg.makeUserGroup()]);
29-
expect(
30-
userGroupsReducer(
31-
prevState,
32-
eg.mkActionRegisterComplete({
33-
// Hmm, we should need a Flow suppression here. This property is
34-
// marked required in InitialData, and this explicit undefined is
35-
// meant to defy that; see TODO(#5102) above.
36-
// mkActionRegisterComplete is designed to accept input with this or
37-
// any property *omitted*… and I think, as a side effect of handling
38-
// that, Flow mistakenly accepts an explicit undefined here, so it
39-
// doesn't catch the resulting malformed InitialData.
40-
realm_user_groups: undefined,
41-
}),
42-
),
43-
).toEqual([]);
44-
});
4525
});
4626

4727
describe('RESET_ACCOUNT_DATA', () => {

src/user-groups/userGroupsReducer.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export default (
5252
return initialState;
5353

5454
case REGISTER_COMPLETE:
55-
// TODO(#5102): Remove fallback for pre-1.8 servers
56-
return action.data.realm_user_groups || initialState;
55+
return action.data.realm_user_groups;
5756

5857
case EVENT_USER_GROUP_ADD:
5958
return [...state, action.group];

0 commit comments

Comments
 (0)