Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions src/account/accountsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
LOGOUT,
ACCOUNT_REMOVE,
} from '../actionConstants';

import { EventTypes } from '../api/eventTypes';
import type { AccountsState, Identity, Action } from '../types';
import { NULL_ARRAY } from '../nullObjects';
import { ZulipVersion } from '../utils/zulipVersion';
Expand Down Expand Up @@ -115,24 +115,22 @@ export default (state: AccountsState = initialState, action: Action): AccountsSt
case EVENT: {
const { event } = action;
switch (event.type) {
case 'restart': {
case EventTypes.restart: {
const { zulip_feature_level, zulip_version } = event;
return zulip_feature_level !== undefined && zulip_version !== undefined
? [
{
...state[0],

// TODO (?): Detect if these are different from the values
// we had before, so we know it's an upgrade, not just a
// restart. Then, implement logic like "be sure to refetch
// from scratch within N hours" (to avoid thundering
// herding the server).
zulipVersion: new ZulipVersion(zulip_version),
zulipFeatureLevel: zulip_feature_level,
},
...state.slice(1),
]
: state;
if (zulip_feature_level === undefined || zulip_version === undefined) {
return state;
}

// TODO: Detect if the feature level has changed, indicating an upgrade;
// if so, trigger a full refetch of server data. See #4793.
return [
{
...state[0],
zulipVersion: new ZulipVersion(zulip_version),
zulipFeatureLevel: zulip_feature_level,
},
...state.slice(1),
];
}
default:
return state;
Expand Down