@etsoo/react 1.3.42 → 1.3.43
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/lib/app/ServiceApp.js +17 -4
- package/package.json +1 -1
- package/src/app/ServiceApp.ts +20 -3
package/lib/app/ServiceApp.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createClient } from '@etsoo/appscript';
|
|
1
|
+
import { ActionResultError, createClient } from '@etsoo/appscript';
|
|
2
|
+
import { ApiDataError } from '@etsoo/restclient';
|
|
2
3
|
import { DomUtils } from '@etsoo/shared';
|
|
3
4
|
import { CoreConstants } from './CoreConstants';
|
|
4
5
|
import { ReactApp } from './ReactApp';
|
|
@@ -126,9 +127,21 @@ export class ServiceApp extends ReactApp {
|
|
|
126
127
|
return false;
|
|
127
128
|
// Refresh token
|
|
128
129
|
return await this.refreshToken({
|
|
129
|
-
callback: (
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
callback: (result) => {
|
|
131
|
+
if (typeof result === 'boolean') {
|
|
132
|
+
this.toLoginPage();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const message = result instanceof ApiDataError
|
|
136
|
+
? this.formatError(result)
|
|
137
|
+
: typeof result !== 'string'
|
|
138
|
+
? ActionResultError.format(result)
|
|
139
|
+
: result;
|
|
140
|
+
this.notifier.alert(message, () => {
|
|
141
|
+
this.toLoginPage();
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
showLoading: true
|
|
132
145
|
});
|
|
133
146
|
}
|
|
134
147
|
/**
|
package/package.json
CHANGED
package/src/app/ServiceApp.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ActionResultError,
|
|
2
3
|
createClient,
|
|
3
4
|
IApi,
|
|
4
5
|
IApiPayload,
|
|
5
6
|
RefreshTokenProps
|
|
6
7
|
} from '@etsoo/appscript';
|
|
8
|
+
import { ApiDataError } from '@etsoo/restclient';
|
|
7
9
|
import { DomUtils } from '@etsoo/shared';
|
|
8
10
|
import { CoreConstants } from './CoreConstants';
|
|
9
11
|
import { IServiceAppSettings } from './IServiceAppSettings';
|
|
@@ -173,9 +175,24 @@ export class ServiceApp<
|
|
|
173
175
|
|
|
174
176
|
// Refresh token
|
|
175
177
|
return await this.refreshToken({
|
|
176
|
-
callback: (
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
callback: (result) => {
|
|
179
|
+
if (typeof result === 'boolean') {
|
|
180
|
+
this.toLoginPage();
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const message =
|
|
185
|
+
result instanceof ApiDataError
|
|
186
|
+
? this.formatError(result)
|
|
187
|
+
: typeof result !== 'string'
|
|
188
|
+
? ActionResultError.format(result)
|
|
189
|
+
: result;
|
|
190
|
+
|
|
191
|
+
this.notifier.alert(message, () => {
|
|
192
|
+
this.toLoginPage();
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
showLoading: true
|
|
179
196
|
});
|
|
180
197
|
}
|
|
181
198
|
|