Skip to content

Commit c2ed78e

Browse files
committed
notif: Drop result and msg from pushToken state.
We never actually use these; and outside of bugs, there's no interesting information the server returns anyway for them to store. For investigating bugs, we have a wide variety of other tools.
1 parent 248761e commit c2ed78e

File tree

5 files changed

+25
-34
lines changed

5 files changed

+25
-34
lines changed

src/boot/store.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ const migrations = {
6060
messages: {},
6161
narrows: {},
6262
}),
63+
'2': state => ({
64+
...state,
65+
realm: {
66+
...state.realm,
67+
pushToken: {
68+
token: state.realm.pushToken.token,
69+
// Drop `result` and `msg`.
70+
},
71+
},
72+
}),
6373
};
6474

6575
const reduxPersistConfig: Config = {
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
/* @flow strict-local */
2-
import { connect } from 'react-redux';
3-
42
import React, { PureComponent } from 'react';
53
import { FlatList } from 'react-native';
64

7-
import type { GlobalState } from '../types';
85
import { Screen } from '../common';
96
import config from '../config';
107
import InfoItem from './InfoItem';
11-
import { getRealm } from '../selectors';
12-
13-
type Props = {|
14-
pushToken: { token: string, msg: string, result: string },
15-
|};
168

17-
class NotificationDiagScreen extends PureComponent<Props> {
9+
export default class NotificationDiagScreen extends PureComponent<{||}> {
1810
render() {
19-
const { pushToken } = this.props;
2011
const variables = {
21-
Result: pushToken.result,
22-
Message: pushToken.msg,
2312
'Initial notification': JSON.stringify(config.startup.notification),
2413
};
2514
return (
@@ -33,7 +22,3 @@ class NotificationDiagScreen extends PureComponent<Props> {
3322
);
3423
}
3524
}
36-
37-
export default connect((state: GlobalState) => ({
38-
pushToken: getRealm(state).pushToken,
39-
}))(NotificationDiagScreen);

src/realm/__tests__/realmReducers-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('realmReducers', () => {
2525
crossRealmBots: [],
2626
isAdmin: false,
2727
twentyFourHourTime: false,
28-
pushToken: { token: '', result: '', msg: '' },
28+
pushToken: { token: '' },
2929
emoji: {},
3030
filters: [],
3131
nonActiveUsers: [],
@@ -41,7 +41,7 @@ describe('realmReducers', () => {
4141
test('save a new PUSH token', () => {
4242
const initialState = deepFreeze({
4343
twentyFourHourTime: false,
44-
pushToken: { token: '', result: '', msg: '' },
44+
pushToken: { token: '' },
4545
emoji: { customEmoji1: {} },
4646
});
4747

@@ -54,7 +54,7 @@ describe('realmReducers', () => {
5454

5555
const expectedState = {
5656
twentyFourHourTime: false,
57-
pushToken: { token: 'new-key', result: 'b', msg: 'a' },
57+
pushToken: { token: 'new-key' },
5858
emoji: { customEmoji1: {} },
5959
};
6060

@@ -68,7 +68,7 @@ describe('realmReducers', () => {
6868
test('delete the PUSH token', () => {
6969
const initialState = deepFreeze({
7070
twentyFourHourTime: false,
71-
pushToken: { token: 'old-key', result: '', msg: '' },
71+
pushToken: { token: 'old-key' },
7272
emoji: { customEmoji1: {} },
7373
});
7474

@@ -78,7 +78,7 @@ describe('realmReducers', () => {
7878

7979
const expectedState = {
8080
twentyFourHourTime: false,
81-
pushToken: { token: '', result: '', msg: '' },
81+
pushToken: { token: '' },
8282
emoji: { customEmoji1: {} },
8383
};
8484

@@ -92,7 +92,7 @@ describe('realmReducers', () => {
9292
test('change the display settings', () => {
9393
const initialState = deepFreeze({
9494
twentyFourHourTime: false,
95-
pushToken: { token: '', result: '', msg: '' },
95+
pushToken: { token: '' },
9696
emoji: { customEmoji1: {} },
9797
});
9898

@@ -107,7 +107,7 @@ describe('realmReducers', () => {
107107

108108
const expectedState = {
109109
twentyFourHourTime: true,
110-
pushToken: { token: '', result: '', msg: '' },
110+
pushToken: { token: '' },
111111
emoji: { customEmoji1: {} },
112112
};
113113

@@ -121,7 +121,7 @@ describe('realmReducers', () => {
121121
test('update state to new realm_emoji', () => {
122122
const prevState = deepFreeze({
123123
twentyFourHourTime: false,
124-
pushToken: { token: '', result: '', msg: '' },
124+
pushToken: { token: '' },
125125
emoji: {},
126126
filter: [],
127127
});
@@ -139,7 +139,7 @@ describe('realmReducers', () => {
139139

140140
const expectedState = {
141141
twentyFourHourTime: false,
142-
pushToken: { token: '', result: '', msg: '' },
142+
pushToken: { token: '' },
143143
emoji: {
144144
customEmoji1: {},
145145
customEmoji2: {},
@@ -157,7 +157,7 @@ describe('realmReducers', () => {
157157
test('update state to new realm_filter', () => {
158158
const prevState = deepFreeze({
159159
twentyFourHourTime: false,
160-
pushToken: { token: '', result: '', msg: '' },
160+
pushToken: { token: '' },
161161
emoji: {},
162162
filters: [],
163163
});
@@ -172,7 +172,7 @@ describe('realmReducers', () => {
172172

173173
const expectedState = {
174174
twentyFourHourTime: false,
175-
pushToken: { token: '', result: '', msg: '' },
175+
pushToken: { token: '' },
176176
emoji: {},
177177
filters: [['#(?P<id>[0-9]+)', 'https://github.com/zulip/zulip/issues/%(id)s', 2]],
178178
};

src/realm/realmReducers.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const initialState = {
3131
canCreateStreams: true,
3232
crossRealmBots: [],
3333
twentyFourHourTime: false,
34-
pushToken: { token: '', result: '', msg: '' },
34+
pushToken: { token: '' },
3535
emoji: {},
3636
filters: [],
3737
isAdmin: false,
@@ -53,20 +53,18 @@ const saveTokenPush = (state: RealmState, action: SaveTokenPushAction): RealmSta
5353
...state,
5454
pushToken: {
5555
token: action.pushToken,
56-
result: action.result,
57-
msg: action.msg,
5856
},
5957
});
6058

6159
const deleteTokenPush = (state: RealmState, action: DeleteTokenPushAction): RealmState => ({
6260
...state,
63-
pushToken: { token: '', result: '', msg: '' },
61+
pushToken: { token: '' },
6462
});
6563

6664
const loginChange = (state: RealmState, action: LoginSuccessAction | LogoutAction): RealmState => ({
6765
...state,
6866
emoji: {},
69-
pushToken: { token: '', result: '', msg: '' },
67+
pushToken: { token: '' },
7068
});
7169

7270
const initRealmEmoji = (state: RealmState, action: InitRealmEmojiAction): RealmState => ({

src/types.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,6 @@ export type RealmState = {|
352352
nonActiveUsers: User[],
353353
pushToken: {|
354354
token: string,
355-
msg: string,
356-
result: string,
357355
|},
358356
filters: RealmFilter[],
359357
emoji: RealmEmojiState,

0 commit comments

Comments
 (0)