Postpone check if buttons are installed
There's a race condition when BUTTON_INSTALLED variable is set and
checked. It's possible that label vote listener is called before
BUTTON_INSTALLED is properly set yielding to AS+1 -> CQ+2 not WAI.
R=aravindvasudev@google.com
Change-Id: Ia0b071627fd5509b7e61b2ea222ed81bc27bd2a6
diff --git a/web/autosubmit.ts b/web/autosubmit.ts
index ac863e5..1fb1b6c 100644
--- a/web/autosubmit.ts
+++ b/web/autosubmit.ts
@@ -221,15 +221,15 @@
* Inform user that CQ+2 was automatically set
*/
export function installLabelValuesCallbackAutosubmit(plugin: PluginApi) {
- if (!BUTTONS_INSTALLED) {
- return;
- }
const replyApi = plugin.changeReply();
replyApi.addLabelValuesChangedCallback(
async (labelDetail: LabelsChangedDetail, change?: ChangeInfo) => {
if (!change) {
return;
}
+ if (!BUTTONS_INSTALLED) {
+ return;
+ }
const reviewApproved =
replyApi.getLabelValue(REVIEW_LABEL) === `+${REVIEW_LABEL_MAX_VALUE}`;
const autoSubmitApproved = isAutoSubmitApproved(change, replyApi);