Skip to content

Commit 78fbc7e

Browse files
committed
notifs: Make report.serverData undefined, not null, for non-active accounts
1 parent 6e06749 commit 78fbc7e

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/settings/NotifTroubleshootingScreen.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ export enum NotificationProblem {
135135
* Data relevant to an account's push notifications, for support requests.
136136
*
137137
* Use jsonifyNotificationReport to get this into the form we want the user
138-
* to send the data in.
138+
* to send the data in. One thing that does is strip away properties with
139+
* value `undefined`.
139140
*/
140141
export type NotificationReport = {|
141142
...Identity,
@@ -151,8 +152,9 @@ export type NotificationReport = {|
151152
/**
152153
* Server data from an event queue, if any.
153154
*
154-
* Pre-#5006, this will only be present for the active, logged-in
155-
* account, if it exists.
155+
* Pre-#5006, this will be undefined except for the active, logged-in
156+
* account, if it exists. For an active account that doesn't have server
157+
* data yet, will be null.
156158
*/
157159
// TODO(#5006): When we store server data for multiple accounts, include
158160
// this for all accounts that have server data.
@@ -163,7 +165,7 @@ export type NotificationReport = {|
163165
+offlineNotification: boolean,
164166
+onlineNotification: boolean,
165167
+streamNotification: boolean,
166-
|} | null,
168+
|} | null | void,
167169
|};
168170

169171
/**
@@ -198,21 +200,22 @@ export function useNotificationReportsByIdentityKey(): Map<string, NotificationR
198200
const identity = identityOfAccount(account);
199201
const isLoggedIn = apiKey !== '';
200202

201-
let serverData = null;
203+
let serverData = undefined;
202204
if (
203205
activeAccountState
204206
&& keyOfIdentity(identityOfAccount(getAccount(activeAccountState)))
205207
=== keyOfIdentity(identityOfAccount(account))
206-
&& getHaveServerData(activeAccountState)
207208
) {
208-
serverData = {
209-
zulipVersion: getServerVersion(activeAccountState),
210-
zulipFeatureLevel: getZulipFeatureLevel(activeAccountState),
211-
pushNotificationsEnabled: getRealm(activeAccountState).pushNotificationsEnabled,
212-
offlineNotification: getSettings(activeAccountState).offlineNotification,
213-
onlineNotification: getSettings(activeAccountState).onlineNotification,
214-
streamNotification: getSettings(activeAccountState).streamNotification,
215-
};
209+
serverData = getHaveServerData(activeAccountState)
210+
? {
211+
zulipVersion: getServerVersion(activeAccountState),
212+
zulipFeatureLevel: getZulipFeatureLevel(activeAccountState),
213+
pushNotificationsEnabled: getRealm(activeAccountState).pushNotificationsEnabled,
214+
offlineNotification: getSettings(activeAccountState).offlineNotification,
215+
onlineNotification: getSettings(activeAccountState).onlineNotification,
216+
streamNotification: getSettings(activeAccountState).streamNotification,
217+
}
218+
: null;
216219
}
217220

218221
const problems = [];

0 commit comments

Comments
 (0)