@formixru/b2b-ui 3.6.0 → 3.6.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formixru/b2b-ui",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,7 +4,7 @@ import { isString } from 'es-toolkit';
4
4
 
5
5
  import { errorHandler } from '../../utils/error-handler.js';
6
6
  import { hide as hideDialog, show as showDialog } from '../dialog/index.js';
7
- import { clearLoaderTimeout, hide as hideLoader, show as showLoader } from '../loader/index.js';
7
+ import { hide as hideLoader, show as showLoader } from '../loader/index.js';
8
8
  import { hide as hideSidebar, show as showSidebar } from '../sidebar/index.js';
9
9
 
10
10
  export const initRequestContent = ($b) => {
@@ -78,16 +78,12 @@ export const request = async ({
78
78
  data = { content: raw };
79
79
  }
80
80
 
81
+ const shouldHideLoader = loader && hideLoaderOnSuccess;
82
+ let isLoaderHidden = false;
83
+
81
84
  if (isString(data.redirect)) {
82
85
  if (data.redirect) {
83
86
  location.assign(data.redirect);
84
- if (data.redirect.startsWith('tg:')) {
85
- if (loader) {
86
- hideLoader();
87
- }
88
- } else {
89
- clearLoaderTimeout();
90
- }
91
87
  } else {
92
88
  location.reload();
93
89
  }
@@ -100,13 +96,6 @@ export const request = async ({
100
96
  }
101
97
  }
102
98
 
103
- const isReloadPending =
104
- (data.reloadOnHideDialog && data.hideDialog) || (data.reloadOnHideSidebar && data.hideSidebar);
105
- const isUIComponentClosing = data.hideDialog || data.hideSidebar;
106
- const shouldSkipLoaderClose = isReloadPending || (data.trigger && !isUIComponentClosing);
107
- const shouldHideLoader = loader && hideLoaderOnSuccess && !shouldSkipLoaderClose;
108
- let isLoaderHidden = false;
109
-
110
99
  if (data.dialog) {
111
100
  const elementId = getElementId(data.dialog.id);
112
101
  const $dialog = document.querySelector(elementId);
@@ -204,10 +193,10 @@ export const request = async ({
204
193
  }
205
194
  }
206
195
  }
196
+ }
207
197
 
208
- if (shouldHideLoader && !isLoaderHidden) {
209
- hideLoader();
210
- }
198
+ if (shouldHideLoader && !isLoaderHidden) {
199
+ hideLoader(isString(data.redirect) ? 3000 : undefined);
211
200
  }
212
201
 
213
202
  return data;
@@ -215,9 +204,18 @@ export const request = async ({
215
204
  if (error.status === 401) {
216
205
  location.reload();
217
206
  } else {
207
+ if (
208
+ error.name === 'AbortError' ||
209
+ error.message?.includes('NetworkError') ||
210
+ error.message?.includes('Failed to fetch')
211
+ ) {
212
+ return;
213
+ }
214
+
218
215
  if (loader) {
219
216
  hideLoader();
220
217
  }
218
+
221
219
  errorHandler(error);
222
220
  }
223
221
  }