@wutiange/log-listener-plugin 2.0.2-alpha.4 → 2.0.2-alpha.5

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 +2 -2
  2. package/src/Server.ts +15 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wutiange/log-listener-plugin",
3
- "version": "2.0.2-alpha.4",
3
+ "version": "2.0.2-alpha.5",
4
4
  "description": "log-record 客户端对应的的插件\r\nLog-record client corresponding plugin",
5
5
  "source": "index.ts",
6
6
  "react-native": "index.ts",
@@ -49,4 +49,4 @@
49
49
  "url-parse": "^1.5.10"
50
50
  },
51
51
  "packageManager": "yarn@4.5.3"
52
- }
52
+ }
package/src/Server.ts CHANGED
@@ -60,7 +60,7 @@ class Server {
60
60
  try {
61
61
  const { path, token } = service.txt ?? {};
62
62
  const url = `http://${service.host}:${service.port}`;
63
- if (!(path && token) || this.baseUrlArr.has(url)) {
63
+ if (!(path && token)) {
64
64
  return;
65
65
  }
66
66
  if (!(await this.requestJoin(`${url}${path}`, token))) {
@@ -80,8 +80,14 @@ class Server {
80
80
  if (currentUrl === undefined) {
81
81
  return;
82
82
  }
83
- this.baseUrlArr.delete(currentUrl);
83
+ const isExistSomeUrl = Array.from(this.urlsObj.values()).some(
84
+ (url) => url === currentUrl,
85
+ );
84
86
  this.urlsObj.delete(name);
87
+ if (isExistSomeUrl) {
88
+ return;
89
+ }
90
+ this.baseUrlArr.delete(currentUrl);
85
91
  if (this.urlsListener) {
86
92
  this.urlsListener(this.baseUrlArr);
87
93
  }
@@ -147,8 +153,14 @@ class Server {
147
153
  if (!currentUrl) {
148
154
  return;
149
155
  }
150
- this.baseUrlArr.delete(currentUrl);
156
+ const isExistSomeUrl = Array.from(this.urlsObj.values()).some(
157
+ (url) => url === currentUrl,
158
+ );
151
159
  this.urlsObj.delete('Default');
160
+ if (isExistSomeUrl) {
161
+ return;
162
+ }
163
+ this.baseUrlArr.delete(currentUrl);
152
164
  } else if (!hasPort(tempUrl)) {
153
165
  this.updateUrl(`${tempUrl}:${DEFAULT_PORT}`);
154
166
  } else {