Skip to content

Commit f514d6a

Browse files
committed
Account type: Add a property featureLevel.
This adds a new property featureLevel in the type Account. Consequently, we had to tweak loginSuccess() and realmAdd() to include featureLevel in their return values. Part of #4049.
1 parent 16b8167 commit f514d6a

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

src/__tests__/lib/exampleData.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const makeAccount = (
122122
email?: string,
123123
realm?: string,
124124
apiKey?: string,
125+
zulipFeatureLevel?: number | null,
125126
shouldHaveZulipVersion?: boolean,
126127
zulipVersion?: string,
127128
ackedPushToken?: string | null,
@@ -132,6 +133,7 @@ export const makeAccount = (
132133
email = user.email,
133134
realm: realmInner = realm,
134135
apiKey = randString() + randString(),
136+
zulipFeatureLevel: zulipFeatureLevelInner = zulipFeatureLevel,
135137
shouldHaveZulipVersion = true,
136138
zulipVersion: zulipVersionInner = zulipVersion,
137139
ackedPushToken = null,
@@ -140,6 +142,7 @@ export const makeAccount = (
140142
realm: realmInner,
141143
email,
142144
apiKey,
145+
zulipFeatureLevel: zulipFeatureLevelInner,
143146
zulipVersion: shouldHaveZulipVersion ? zulipVersionInner : undefined,
144147
ackedPushToken,
145148
});

src/account/__tests__/accountsReducer-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('accountsReducer', () => {
3131
email: '',
3232
apiKey: '',
3333
realm: 'https://new.realm.org',
34+
zulipFeatureLevel: null, // Will be removed in an upcoming commit.
3435
});
3536

3637
const action = deepFreeze({
@@ -170,6 +171,7 @@ describe('accountsReducer', () => {
170171
171172
realm: 'https://new.realm.org',
172173
shouldHaveZulipVersion: false,
174+
zulipFeatureLevel: null,
173175
});
174176

175177
const action = deepFreeze({

src/account/accountsReducer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const realmAdd = (state, action) => {
3232
apiKey: '',
3333
email: '',
3434
ackedPushToken: null,
35+
zulipFeatureLevel: null,
3536
zulipVersion: action.zulipVersion,
3637
},
3738
...state,
@@ -65,7 +66,7 @@ const loginSuccess = (state, action) => {
6566
const { realm, email, apiKey } = action;
6667
const accountIndex = findAccount(state, { realm, email });
6768
if (accountIndex === -1) {
68-
return [{ realm, email, apiKey, ackedPushToken: null }, ...state];
69+
return [{ realm, email, apiKey, ackedPushToken: null, zulipFeatureLevel: null }, ...state];
6970
}
7071
return [
7172
{ ...state[accountIndex], email, apiKey, ackedPushToken: null },

src/types.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ export type Account = {|
9494
*/
9595
zulipVersion?: string,
9696

97+
/**
98+
* An integer indicatating what features are available on the server.
99+
*
100+
* The feature level increases monotonically; a value of N means the
101+
* server supports all API features introduced before feature level N.
102+
* This is designed to provide a simple way for mobile apps to decide
103+
* whether the server supports a given feature or API change.
104+
*
105+
* Like zulipVersion, we learn the feature level from /server_settings
106+
* at the start of the login process, and again from /register when
107+
* setting up an event queue.
108+
*/
109+
zulipFeatureLevel: number | null,
110+
97111
/**
98112
* The last device token value the server has definitely heard from us.
99113
*

0 commit comments

Comments
 (0)