@seamly/web-ui 19.0.0-beta.3 → 19.0.0

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.
@@ -3485,13 +3485,23 @@ class SeamlyUnauthorizedError extends Error {
3485
3485
 
3486
3486
 
3487
3487
 
3488
-
3489
3488
  const handledErrorTypes = [SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError];
3490
- function middleware_createMiddleware() {
3489
+ function middleware_createMiddleware({
3490
+ api
3491
+ }) {
3491
3492
  return () => next => action => {
3492
- if (action.type === String(Actions.set)) {
3493
- if (!handledErrorTypes.some(ErrorType => action.error instanceof ErrorType)) {
3494
- throw action.error;
3493
+ const {
3494
+ error
3495
+ } = action;
3496
+
3497
+ if (error) {
3498
+ if (!handledErrorTypes.some(ErrorType => error instanceof ErrorType)) {
3499
+ throw error;
3500
+ } else if (error.action === 'reset') {
3501
+ // [SMLY-942] We clear the store before a reset to force a new conversation if the page is refreshed before the conversation is reset
3502
+ api.disconnect().then(() => {
3503
+ api.clearStore();
3504
+ });
3495
3505
  }
3496
3506
  }
3497
3507
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamly/web-ui",
3
- "version": "19.0.0-beta.3",
3
+ "version": "19.0.0",
4
4
  "main": "build/dist/lib/index.js",
5
5
  "module": "",
6
6
  "exports": {
@@ -3,7 +3,6 @@ import SeamlyConfigurationError from '../../api/errors/seamly-configuration-erro
3
3
  import SeamlySessionExpiredError from '../../api/errors/seamly-session-expired-error'
4
4
  import SeamlyOfflineError from '../../api/errors/seamly-offline-error'
5
5
  import SeamlyUnauthorizedError from '../../api/errors/seamly-unauthorized-error'
6
- import * as Actions from './actions'
7
6
 
8
7
  const handledErrorTypes = [
9
8
  SeamlyGeneralError,
@@ -13,15 +12,17 @@ const handledErrorTypes = [
13
12
  SeamlyUnauthorizedError,
14
13
  ]
15
14
 
16
- export default function createMiddleware() {
15
+ export default function createMiddleware({ api }) {
17
16
  return () => (next) => (action) => {
18
- if (action.type === String(Actions.set)) {
19
- if (
20
- !handledErrorTypes.some(
21
- (ErrorType) => action.error instanceof ErrorType,
22
- )
23
- ) {
24
- throw action.error
17
+ const { error } = action
18
+ if (error) {
19
+ if (!handledErrorTypes.some((ErrorType) => error instanceof ErrorType)) {
20
+ throw error
21
+ } else if (error.action === 'reset') {
22
+ // [SMLY-942] We clear the store before a reset to force a new conversation if the page is refreshed before the conversation is reset
23
+ api.disconnect().then(() => {
24
+ api.clearStore()
25
+ })
25
26
  }
26
27
  }
27
28
 
@@ -35,7 +35,7 @@ export function createStore({ initialState, api } = {}) {
35
35
  api,
36
36
  }),
37
37
  createConfigMiddleware(),
38
- createInterruptMiddleware(),
38
+ createInterruptMiddleware({ api }),
39
39
  createOptionsMiddleware({ api }),
40
40
  createI18nMiddleware(),
41
41
  ],