Skip to content

Commit 03f7a98

Browse files
committed
realm state: Store enableReadReceipts
1 parent bc930f6 commit 03f7a98

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

src/realm/__tests__/realmReducer-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('realmReducer', () => {
6767
enableSpectatorAccess: action.data.realm_enable_spectator_access,
6868
waitingPeriodThreshold: action.data.realm_waiting_period_threshold,
6969
allowEditHistory: action.data.realm_allow_edit_history,
70+
enableReadReceipts: action.data.realm_enable_read_receipts,
7071

7172
//
7273
// InitialDataRealmUser
@@ -491,6 +492,14 @@ describe('realmReducer', () => {
491492
check(false, true);
492493
check(false, false);
493494
});
495+
496+
describe('enableReadReceipts / enable_read_receipts', () => {
497+
const check = mkCheck('enableReadReceipts', 'enable_read_receipts');
498+
check(true, true);
499+
check(true, false);
500+
check(false, true);
501+
check(false, false);
502+
});
494503
});
495504
});
496505
});

src/realm/realmReducer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const initialState = {
5353
enableSpectatorAccess: false,
5454
waitingPeriodThreshold: 90,
5555
allowEditHistory: false,
56+
enableReadReceipts: false,
5657

5758
//
5859
// InitialDataRealmUser
@@ -160,6 +161,7 @@ export default (
160161
enableSpectatorAccess: action.data.realm_enable_spectator_access ?? false,
161162
waitingPeriodThreshold: action.data.realm_waiting_period_threshold,
162163
allowEditHistory: action.data.realm_allow_edit_history,
164+
enableReadReceipts: action.data.realm_enable_read_receipts ?? false,
163165

164166
//
165167
// InitialDataRealmUser
@@ -260,6 +262,9 @@ export default (
260262
if (data.allow_edit_history !== undefined) {
261263
result.allowEditHistory = data.allow_edit_history;
262264
}
265+
if (data.enable_read_receipts !== undefined) {
266+
result.enableReadReceipts = data.enable_read_receipts;
267+
}
263268

264269
return result;
265270
}

src/reduxTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ export type RealmState = {|
306306
+enableSpectatorAccess: boolean,
307307
+waitingPeriodThreshold: number,
308308
+allowEditHistory: boolean,
309+
+enableReadReceipts: boolean,
309310

310311
//
311312
// InitialDataRealmUser

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: 52 },
107+
migrations: { version: 53 },
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 51',
131-
{ ...endBase, migrations: { version: 50 }, mute: [], nonsense: [1, 2, 3] },
130+
'check dropCache at 53',
131+
{ ...endBase, migrations: { version: 52 }, 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
@@ -460,6 +460,9 @@ const migrationsInner: {| [string]: (LessPartialState) => LessPartialState |} =
460460
};
461461
},
462462

463+
// Add enableReadReceipts to state.realm.
464+
'53': dropCache,
465+
463466
// TIP: When adding a migration, consider just using `dropCache`.
464467
// (See its jsdoc for guidance on when that's the right answer.)
465468
};

0 commit comments

Comments
 (0)