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
This commit is contained in:
Torkel Ödegaard
2019-11-19 21:19:10 +01:00
committed by GitHub
parent c2e401667c
commit 322c110b89

View File

@@ -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;
}