Skip to content

Commit

Permalink
only dispatch SET_ANALYTICS if the value is different from what we ha…
Browse files Browse the repository at this point in the history
…ve in state (#2306)
  • Loading branch information
codebykat authored Aug 28, 2020
1 parent 34d023e commit e6ab711
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/state/simperium/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,15 @@ export const initSimperium = (
return;
}

dispatch({
type: 'SET_ANALYTICS',
allowAnalytics: !!updatedEntity.analytics_enabled,
preferencesBucket.get('preferences-key').then((preferences) => {
if (
updatedEntity.analytics_enabled !== preferences.data.analytics_enabled
) {
dispatch({
type: 'SET_ANALYTICS',
allowAnalytics: !!updatedEntity.analytics_enabled,
});
}
});
});

Expand Down

0 comments on commit e6ab711

Please sign in to comment.