TimePicker: Fixed update issue after plugin uses getLocationSrv().update (#20466)

* TimePicker: Fixed update issue after plugin uses getLocationSrv().update

* comment fix

* don't mess with the text panel
pull/20496/head
Torkel Ödegaard 6 years ago committed by GitHub
parent c2e401667c
commit 322c110b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx

@ -28,6 +28,21 @@ export class DashNavTimeControls extends Component<Props> {
timeSrv: TimeSrv = getTimeSrv();
$rootScope = this.props.$injector.get('$rootScope');
componentDidMount() {
// Only reason for this is that sometimes time updates can happen via redux location changes
// and this happens before timeSrv has had chance to update state (as it listens to angular route-updated)
// This can be removed after timeSrv listens redux location
this.props.dashboard.on(CoreEvents.timeRangeUpdated, this.triggerForceUpdate);
}
componentWillUnmount() {
this.props.dashboard.off(CoreEvents.timeRangeUpdated, this.triggerForceUpdate);
}
triggerForceUpdate = () => {
this.forceUpdate();
};
get refreshParamInUrl(): string {
return this.props.location.query.refresh as string;
}

Loading…
Cancel
Save