浏览代码

feat(ts) migrate StropheLastSuccess to TS

dev0
Yash 6 个月前
父节点
当前提交
aa17095e14
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 13 次插入5 次删除
  1. 13
    5
      modules/xmpp/StropheLastSuccess.ts

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

@@ -1,7 +1,15 @@
1 1
 /**
2 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 9
 export default class LastRequestTracker {
10
+    private _lastSuccess: number | null;
11
+    private _lastFailedMessage: string | null;
12
+
5 13
     /**
6 14
      * Initializes new instance.
7 15
      */
@@ -14,12 +22,12 @@ export default class LastRequestTracker {
14 22
      * Starts tracking requests on the given connection.
15 23
      *
16 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 28
         const originalRawInput = stropheConnection.rawInput;
21 29
 
22
-        stropheConnection.rawInput = (...args) => {
30
+        stropheConnection.rawInput = (...args: any[]): void => {
23 31
             const rawMessage = args[0];
24 32
 
25 33
             if (rawMessage.includes('failure')) {
@@ -40,7 +48,7 @@ export default class LastRequestTracker {
40 48
      *
41 49
      * @returns {string|null}
42 50
      */
43
-    getLastFailedMessage() {
51
+    getLastFailedMessage(): string | null {
44 52
         return this._lastFailedMessage;
45 53
     }
46 54
 
@@ -49,7 +57,7 @@ export default class LastRequestTracker {
49 57
      *
50 58
      * @returns {number|null}
51 59
      */
52
-    getTimeSinceLastSuccess() {
60
+    getTimeSinceLastSuccess(): number | null {
53 61
         return this._lastSuccess
54 62
             ? Date.now() - this._lastSuccess
55 63
             : null;

正在加载...
取消
保存