mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 13:30:24 +08:00
Dashboards: Prevent shared queries from being unnecessarily re-run (#77490)
* Dashboards: Prevent shared queries from being unnecessarily re-run * Minor change * Set solo panel as being viewed --------- Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
@ -74,7 +74,6 @@ export interface State {
|
||||
isFirstLoad: boolean;
|
||||
renderCounter: number;
|
||||
errorMessage?: string;
|
||||
refreshWhenInView: boolean;
|
||||
context: PanelContext;
|
||||
data: PanelData;
|
||||
liveTime?: TimeRange;
|
||||
@ -95,7 +94,6 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
|
||||
this.state = {
|
||||
isFirstLoad: true,
|
||||
renderCounter: 0,
|
||||
refreshWhenInView: false,
|
||||
context: {
|
||||
eventsScope: '__global_',
|
||||
eventBus,
|
||||
@ -258,7 +256,7 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
const { isInView, width } = this.props;
|
||||
const { isInView, width, panel } = this.props;
|
||||
const { context } = this.state;
|
||||
|
||||
const app = this.getPanelContextApp();
|
||||
@ -276,7 +274,7 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
|
||||
if (isInView !== prevProps.isInView) {
|
||||
if (isInView) {
|
||||
// Check if we need a delayed refresh
|
||||
if (this.state.refreshWhenInView) {
|
||||
if (panel.refreshWhenInView) {
|
||||
this.onRefresh();
|
||||
}
|
||||
}
|
||||
@ -343,7 +341,7 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
|
||||
const { dashboard, panel, isInView, width } = this.props;
|
||||
|
||||
if (!isInView) {
|
||||
this.setState({ refreshWhenInView: true });
|
||||
panel.refreshWhenInView = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -355,9 +353,7 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state.refreshWhenInView) {
|
||||
this.setState({ refreshWhenInView: false });
|
||||
}
|
||||
panel.refreshWhenInView = false;
|
||||
panel.runAllPanelQueries({
|
||||
dashboardUID: dashboard.uid,
|
||||
dashboardTimezone: dashboard.getTimezone(),
|
||||
|
Reference in New Issue
Block a user