mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 10:55:00 +08:00
Correct logic for disabling activity subscriptions
This commit is contained in:
@@ -199,25 +199,42 @@ class ModerationContainer extends Component {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
// Stop activity indicator tracking, as we'll handle it here.
|
||||
this.props.setIndicatorTrack(false);
|
||||
if (!this.props.data.variables.asset_id) {
|
||||
// Stop activity indicator tracking, as we'll handle it here.
|
||||
this.props.setIndicatorTrack(false);
|
||||
}
|
||||
this.props.clearState();
|
||||
this.subscribeToUpdates();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
// Restart activity indicator tracking.
|
||||
this.props.setIndicatorTrack(true);
|
||||
if (!this.props.data.variables.asset_id) {
|
||||
// Restart activity indicator tracking.
|
||||
this.props.setIndicatorTrack(true);
|
||||
}
|
||||
this.unsubscribe();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const currentAssetId = this.props.data.variables.asset_id;
|
||||
const nextAssetId = nextProps.data.variables.asset_id;
|
||||
|
||||
// Resubscribe when we change between assets.
|
||||
if (
|
||||
this.props.data.variables.asset_id !== nextProps.data.variables.asset_id
|
||||
) {
|
||||
if (currentAssetId !== nextAssetId) {
|
||||
this.resubscribe(nextProps.data.variables);
|
||||
}
|
||||
|
||||
// We are only subscribing to a specific asset_id, so activity indicator
|
||||
// needs to do its own tracking.
|
||||
if (!currentAssetId && nextAssetId) {
|
||||
this.props.setIndicatorTrack(true);
|
||||
}
|
||||
|
||||
// We are subscribing to all comment changes, and as such there is no
|
||||
// need for the activity indicator to do the same.
|
||||
if (currentAssetId && !nextAssetId) {
|
||||
this.props.setIndicatorTrack(false);
|
||||
}
|
||||
}
|
||||
|
||||
cleanUpQueue = queue => {
|
||||
|
||||
Reference in New Issue
Block a user