react-native-mosquito-transport 0.0.45 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +6 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mosquito-transport",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "React native javascript sdk for mosquito-transport (https://github.com/brainbehindx/mosquito-transport)",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -63,9 +63,7 @@ class RNMT {
63
63
  triggerAuthToken(projectUrl);
64
64
  initTokenRefresher({ ...this.config }, true);
65
65
 
66
- let isConnected,
67
- lastSentToken,
68
- queuedToken;
66
+ let isConnected, recentToken;
69
67
 
70
68
  const socket = io(`${this.config.wsPrefix}://${this.config.baseUrl}`, {
71
69
  transports: ['websocket', 'polling', 'flashsocket'],
@@ -80,7 +78,7 @@ class RNMT {
80
78
  ++connectionIte;
81
79
  isConnected = true;
82
80
  Scoped.IS_CONNECTED[projectUrl] = true;
83
- if (queuedToken) updateMountedToken(queuedToken.token);
81
+ if (recentToken) updateMountedToken();
84
82
  ServerReachableListener.dispatch(projectUrl, true);
85
83
  awaitStore().then(() => {
86
84
  if (isConnected) trySendPendingWrite(projectUrl);
@@ -114,18 +112,13 @@ class RNMT {
114
112
  manualCheckConnection();
115
113
  });
116
114
 
117
- const updateMountedToken = (token) => {
118
- if ((lastSentToken || null) !== (token || null)) {
119
- socket.emit('_update_mounted_user', token || null);
120
- lastSentToken = token;
121
- }
122
- queuedToken = undefined;
115
+ const updateMountedToken = () => {
116
+ socket.emit('_update_mounted_user', recentToken || null);
123
117
  };
124
118
 
125
119
  listenToken(token => {
126
- if (isConnected) {
127
- updateMountedToken(token);
128
- } else queuedToken = { token };
120
+ recentToken = token;
121
+ if (isConnected) updateMountedToken();
129
122
  }, projectUrl);
130
123
 
131
124
  TokenRefreshListener.listenTo(projectUrl, v => {