From 9e9e0edbb89bd1cf92efb596020b5a6c241920a5 Mon Sep 17 00:00:00 2001 From: Maayan Glikser Date: Mon, 4 Jun 2018 23:28:14 +0300 Subject: [PATCH] fix(Master toggle): Fix master toggle not turning on and off mimic Fix an issue where we did not notify the currently registered interceptor of the new state --- lib/api/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/api/index.js b/lib/api/index.js index 565ed01e..64f33599 100644 --- a/lib/api/index.js +++ b/lib/api/index.js @@ -28,6 +28,10 @@ class PublicAPI { registerInterceptor(interceptor) { this.interceptor = interceptor; + + if (!this.enabled) { + this.interceptor.disable(); + } } connect(options) { @@ -36,11 +40,21 @@ class PublicAPI { turnOn() { this.enabled = true; + + if (this.interceptor) { + this.interceptor.enable(); + } + Emitter.emit(EVENTS.MIMIC_TURN_ON); } turnOff() { this.enabled = false; + + if (this.interceptor) { + this.interceptor.disable(); + } + Emitter.emit(EVENTS.MIMIC_TURN_OFF); }