Skip to content

Commit

Permalink
Use async/await in the then clause to make code more readable.
Browse files Browse the repository at this point in the history
  • Loading branch information
KeesCBakker committed May 13, 2024
1 parent 90dffbf commit c27aeb9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/grafana.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ module.exports = (robot) => {
title = `Dashboards tagged \`${tag}\`:\n`;
}

service.search(null, tag).then((dashboards) => {
service.search(null, tag).then(async (dashboards) => {
if (dashboards == null) return;
return sendDashboardList(dashboards, title, context);
await sendDashboardList(dashboards, title, context);
});
});

Expand All @@ -108,10 +108,10 @@ module.exports = (robot) => {
const query = msg.match[1].trim();
robot.logger.debug(query);

service.search(query).then((dashboards) => {
service.search(query).then(async (dashboards) => {
if (dashboards == null) return;
const title = `Dashboards matching \`${query}\`:\n`;
return sendDashboardList(dashboards, title, msg);
await sendDashboardList(dashboards, title, msg);
});
});

Expand Down Expand Up @@ -160,11 +160,11 @@ module.exports = (robot) => {
const paused = msg.match[1] === 'pause';
const alertId = msg.match[2];

const message = service.pauseSingleAlert(alertId, paused);

if (message) {
msg.send(message);
}
service.pauseSingleAlert(alertId, paused).then((message) => {
if (message) {
msg.send(message);
}
});
});

// Pause/unpause all alerts
Expand Down

0 comments on commit c27aeb9

Please sign in to comment.