Browse Source

fix(ResumeTask) Avoid adding multiple NETWORK_INFO_EVENT listeners

release-8443
Romick2005 1 year ago
parent
commit
f5f1c314c9
No account linked to committer's email address
1 changed files with 15 additions and 4 deletions
  1. 15
    4
      modules/xmpp/ResumeTask.js

+ 15
- 4
modules/xmpp/ResumeTask.js View File

47
      */
47
      */
48
     schedule() {
48
     schedule() {
49
         this._cancelResume();
49
         this._cancelResume();
50
+        this._removeNetworkOnlineListener();
50
 
51
 
51
         this._resumeRetryN += 1;
52
         this._resumeRetryN += 1;
52
 
53
 
106
         }
107
         }
107
     }
108
     }
108
 
109
 
110
+    /**
111
+     * Removes network online listener for the NETWORK_INFO_EVENT event.
112
+     *
113
+     * @private
114
+     * @returns {void}
115
+     */
116
+    _removeNetworkOnlineListener() {
117
+        if (this._networkOnlineListener) {
118
+            this._networkOnlineListener();
119
+            this._networkOnlineListener = null;
120
+        }
121
+    }
122
+
109
     /**
123
     /**
110
      * Resumes the XMPP connection using the stream management plugin.
124
      * Resumes the XMPP connection using the stream management plugin.
111
      *
125
      *
152
      */
166
      */
153
     cancel() {
167
     cancel() {
154
         this._cancelResume();
168
         this._cancelResume();
169
+        this._removeNetworkOnlineListener();
155
         this._resumeRetryN = 0;
170
         this._resumeRetryN = 0;
156
-        if (this._networkOnlineListener) {
157
-            this._networkOnlineListener();
158
-            this._networkOnlineListener = null;
159
-        }
160
     }
171
     }
161
 }
172
 }

Loading…
Cancel
Save