瀏覽代碼

feat(ts) migrate StropheLastSuccess to TS

dev0
Yash 6 月之前
父節點
當前提交
aa17095e14
No account linked to committer's email address
共有 1 個文件被更改,包括 13 次插入5 次删除
  1. 13
    5
      modules/xmpp/StropheLastSuccess.ts

modules/xmpp/StropheLastSuccess.js → modules/xmpp/StropheLastSuccess.ts 查看文件

1
 /**
1
 /**
2
  * Attaches to the {@link Strophe.Connection.rawInput} which is called whenever any data is received from the server.
2
  * Attaches to the {@link Strophe.Connection.rawInput} which is called whenever any data is received from the server.
3
  */
3
  */
4
+
5
+import XmppConnection from './XmppConnection';
6
+import { Strophe } from 'strophe.js';
7
+
8
+
4
 export default class LastRequestTracker {
9
 export default class LastRequestTracker {
10
+    private _lastSuccess: number | null;
11
+    private _lastFailedMessage: string | null;
12
+
5
     /**
13
     /**
6
      * Initializes new instance.
14
      * Initializes new instance.
7
      */
15
      */
14
      * Starts tracking requests on the given connection.
22
      * Starts tracking requests on the given connection.
15
      *
23
      *
16
      * @param {XmppConnection} xmppConnection - The XMPP connection which manages the given {@code stropheConnection}.
24
      * @param {XmppConnection} xmppConnection - The XMPP connection which manages the given {@code stropheConnection}.
17
-     * @param {Object} stropheConnection - Strophe connection instance.
25
+     * @param {Strophe.Connection} stropheConnection - Strophe connection instance.
18
      */
26
      */
19
-    startTracking(xmppConnection, stropheConnection) {
27
+    startTracking(xmppConnection: XmppConnection, stropheConnection: Strophe.Connection): void {
20
         const originalRawInput = stropheConnection.rawInput;
28
         const originalRawInput = stropheConnection.rawInput;
21
 
29
 
22
-        stropheConnection.rawInput = (...args) => {
30
+        stropheConnection.rawInput = (...args: any[]): void => {
23
             const rawMessage = args[0];
31
             const rawMessage = args[0];
24
 
32
 
25
             if (rawMessage.includes('failure')) {
33
             if (rawMessage.includes('failure')) {
40
      *
48
      *
41
      * @returns {string|null}
49
      * @returns {string|null}
42
      */
50
      */
43
-    getLastFailedMessage() {
51
+    getLastFailedMessage(): string | null {
44
         return this._lastFailedMessage;
52
         return this._lastFailedMessage;
45
     }
53
     }
46
 
54
 
49
      *
57
      *
50
      * @returns {number|null}
58
      * @returns {number|null}
51
      */
59
      */
52
-    getTimeSinceLastSuccess() {
60
+    getTimeSinceLastSuccess(): number | null {
53
         return this._lastSuccess
61
         return this._lastSuccess
54
             ? Date.now() - this._lastSuccess
62
             ? Date.now() - this._lastSuccess
55
             : null;
63
             : null;

Loading…
取消
儲存