Skip to content

Commit

Permalink
Checking for notification bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ackernaut committed Mar 1, 2017
1 parent 3b80f0d commit 293fec7
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/universal/containers/DashLayoutContainer/DashLayoutContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ const subToAllTeams = (tms) => {
}
};

const checkForNotificationBar = (props, nextProps, dispatch) => {
const {activeMeetings, trialNotification} = props;
const {activeMeetings: nextActiveMeetings, trialNotification: nextTrialNotification} = nextProps;
const {barType} = nextTrialNotification;

if (activeMeetings !== nextActiveMeetings || trialNotification !== nextTrialNotification) {
if (nextActiveMeetings.length > 0 || barType === TRIAL_EXPIRES_SOON || barType === TRIAL_EXPIRED) {
dispatch(notificationBarPresent(true));
} else {
dispatch(notificationBarPresent(false));
}
}
};

@connect(mapStateToProps)
export default class DashLayoutContainer extends Component {
static propTypes = {
Expand All @@ -76,27 +90,21 @@ export default class DashLayoutContainer extends Component {
// userId: PropTypes.string
};

componentWillMount() {
checkForNotificationBar({}, this.props, this.props.dispatch);
}

componentDidMount() {
const {tms} = this.props;
subToAllTeams(tms);
// cashay.subscribe(NOTIFICATIONS, userId)
}

componentWillReceiveProps(nextProps) {
const {activeMeetings, trialNotification} = this.props;
const {activeMeetings: nextActiveMeetings, trialNotification: nextTrialNotification} = nextProps;
const {barType} = nextTrialNotification;
if (this.props.tms !== nextProps.tms) {
subToAllTeams(nextProps.tms);
}

if (activeMeetings !== nextActiveMeetings || trialNotification !== nextTrialNotification) {
if (nextActiveMeetings.length > 0 || barType === TRIAL_EXPIRES_SOON || barType === TRIAL_EXPIRED) {
this.props.dispatch(notificationBarPresent(true));
} else {
this.props.dispatch(notificationBarPresent(false));
}
}
checkForNotificationBar(this.props, nextProps, this.props.dispatch);
}

render() {
Expand Down

2 comments on commit 293fec7

@ackernaut
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkrick ok, so this seems to work, but it is still dispatching every time—what am I missing??

@mattkrick
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm betting it's not getting the current value, i'll dig in & see

Please sign in to comment.