@seamly/web-ui 20.8.0-beta.1 → 20.8.0-beta.2
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/build/dist/lib/index.debug.js +5 -5
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.js +15 -26
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +17 -30
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +11 -17
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/domains/app/actions.ts +45 -41
- package/src/javascripts/domains/store/slice.ts +7 -2
- package/src/javascripts/domains/translations/slice.ts +0 -6
- package/src/javascripts/ui/hooks/use-seamly-chat.js +3 -9
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import SeamlySessionExpiredError from 'api/errors/seamly-session-expired-error'
|
|
|
3
3
|
import SeamlyUnavailableError from 'api/errors/seamly-unavailable-error'
|
|
4
4
|
import { Config } from 'config.types'
|
|
5
5
|
import { initializeConfig, resetConfig } from 'domains/config/actions'
|
|
6
|
+
import { setLocale } from 'domains/i18n/actions'
|
|
6
7
|
import { ThunkAPI } from 'domains/redux/redux.types'
|
|
7
8
|
import type { RootState } from 'domains/store'
|
|
8
9
|
import { initializeVisibility } from 'domains/visibility/actions'
|
|
@@ -16,58 +17,61 @@ export const initializeApp = createAsyncThunk<
|
|
|
16
17
|
},
|
|
17
18
|
void,
|
|
18
19
|
ThunkAPI
|
|
19
|
-
>(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
>(
|
|
21
|
+
'initializeApp',
|
|
22
|
+
async (_, { extra: { api, config }, rejectWithValue, dispatch }) => {
|
|
23
|
+
let locale = config?.context?.locale
|
|
24
|
+
try {
|
|
25
|
+
if (api.hasConversation()) {
|
|
26
|
+
const initialState = await api.getConversationIntitialState()
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
locale = initialState.translation?.locale || locale
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
return { initialState, locale, config }
|
|
31
|
+
} else {
|
|
32
|
+
if (config?.context?.topic) {
|
|
33
|
+
api.send('action', {
|
|
34
|
+
type: actionTypes.setTopic,
|
|
35
|
+
body: {
|
|
36
|
+
name: config.context.topic,
|
|
37
|
+
// Separate fallback message is not needed here. Only an attached service will use this, but none will
|
|
38
|
+
// be attached before the conversation has started (meaning the fallback message will never be shown).
|
|
39
|
+
fallbackMessage: config.context.topic,
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
if (config?.context?.translationLocale) {
|
|
44
|
+
locale = config.context.translationLocale
|
|
45
|
+
api.send('action', {
|
|
46
|
+
type: actionTypes.setTranslation,
|
|
47
|
+
body: { enabled: true, locale },
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
dispatch(setLocale(locale))
|
|
51
|
+
return { initialState: undefined, locale, config }
|
|
39
52
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
} catch (e) {
|
|
54
|
+
if (e instanceof SeamlySessionExpiredError) {
|
|
55
|
+
const err = new SeamlySessionExpiredError()
|
|
56
|
+
|
|
57
|
+
return rejectWithValue({
|
|
58
|
+
name: err.name,
|
|
59
|
+
message: err.message,
|
|
60
|
+
originalEvent: err.originalEvent,
|
|
61
|
+
originalError: err.originalError,
|
|
62
|
+
action: err.action,
|
|
45
63
|
})
|
|
46
64
|
}
|
|
47
65
|
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
} catch (e) {
|
|
51
|
-
if (e instanceof SeamlySessionExpiredError) {
|
|
52
|
-
const err = new SeamlySessionExpiredError()
|
|
53
|
-
|
|
66
|
+
const err = new SeamlyUnavailableError()
|
|
54
67
|
return rejectWithValue({
|
|
55
68
|
name: err.name,
|
|
56
69
|
message: err.message,
|
|
57
|
-
|
|
58
|
-
originalError: err.originalError,
|
|
59
|
-
action: err.action,
|
|
70
|
+
langKey: err.langKey,
|
|
60
71
|
})
|
|
61
72
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return rejectWithValue({
|
|
65
|
-
name: err.name,
|
|
66
|
-
message: err.message,
|
|
67
|
-
langKey: err.langKey,
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
})
|
|
73
|
+
},
|
|
74
|
+
)
|
|
71
75
|
|
|
72
76
|
export const resetApp = createAsyncThunk<unknown, void, ThunkAPI>(
|
|
73
77
|
'resetApp',
|
|
@@ -360,7 +360,7 @@ export const storeSlice = createSlice({
|
|
|
360
360
|
)
|
|
361
361
|
|
|
362
362
|
// Only set uploads if it was initialised by the account config.
|
|
363
|
-
if (newFeaturesHasUpload && lastParticipantEvent
|
|
363
|
+
if (newFeaturesHasUpload && lastParticipantEvent?.type === 'message') {
|
|
364
364
|
const { payload: lastParticipantEventPayload } = lastParticipantEvent
|
|
365
365
|
const entryType = lastParticipantEventPayload?.entry?.type || {}
|
|
366
366
|
newFeatures = {
|
|
@@ -394,7 +394,12 @@ export const storeSlice = createSlice({
|
|
|
394
394
|
...state.serviceInfo,
|
|
395
395
|
activeServiceSessionId,
|
|
396
396
|
}
|
|
397
|
-
|
|
397
|
+
|
|
398
|
+
state.serviceData = {
|
|
399
|
+
...state.serviceData,
|
|
400
|
+
...serviceData,
|
|
401
|
+
}
|
|
402
|
+
|
|
398
403
|
state.options = {
|
|
399
404
|
...state.options,
|
|
400
405
|
features: newFeatures || {},
|
|
@@ -87,12 +87,6 @@ export const translationSlice = createSlice({
|
|
|
87
87
|
},
|
|
88
88
|
extraReducers: (builder) => {
|
|
89
89
|
builder
|
|
90
|
-
.addCase(initializeApp.fulfilled, (state, { payload }) => {
|
|
91
|
-
if (!payload.config?.context?.translationLocale) return
|
|
92
|
-
|
|
93
|
-
state.isActive = true
|
|
94
|
-
state.currentLocale = payload.locale
|
|
95
|
-
})
|
|
96
90
|
.addCase(initializeConfig.fulfilled, (state, { payload }) => {
|
|
97
91
|
const feature = payload?.features?.translation
|
|
98
92
|
if (!feature) return
|
|
@@ -7,7 +7,7 @@ import { useDispatch, useSelector } from 'react-redux'
|
|
|
7
7
|
import { selectShowInlineView } from '../../domains/visibility/selectors'
|
|
8
8
|
import { useLiveRegion } from './live-region-hooks'
|
|
9
9
|
import { useSeamlyHasConversation } from './seamly-api-hooks'
|
|
10
|
-
import {
|
|
10
|
+
import { useSeamlyLayoutMode } from './seamly-state-hooks'
|
|
11
11
|
import useSeamlyCommands from './use-seamly-commands'
|
|
12
12
|
|
|
13
13
|
const useSeamlyChat = () => {
|
|
@@ -16,7 +16,6 @@ const useSeamlyChat = () => {
|
|
|
16
16
|
const { isOpen, isVisible, setVisibility } = useVisibility()
|
|
17
17
|
const showInlineView = useSelector(selectShowInlineView)
|
|
18
18
|
const dispatch = useDispatch()
|
|
19
|
-
const events = useEvents()
|
|
20
19
|
const spinnerTimeout = useRef(null)
|
|
21
20
|
const { start, connect, apiConfigReady, apiConnected } = useSeamlyCommands()
|
|
22
21
|
const hasConversation = useSeamlyHasConversation()
|
|
@@ -25,8 +24,6 @@ const useSeamlyChat = () => {
|
|
|
25
24
|
const startCalled = useRef(false)
|
|
26
25
|
const { sendAssertive } = useLiveRegion()
|
|
27
26
|
|
|
28
|
-
const hasEvents = events.length > 0
|
|
29
|
-
|
|
30
27
|
useEffect(() => {
|
|
31
28
|
if (isVisible) {
|
|
32
29
|
// Wait for the live containers to stabilise in the DOM before injecting
|
|
@@ -60,14 +57,11 @@ const useSeamlyChat = () => {
|
|
|
60
57
|
spinnerTimeout.current = setTimeout(() => {
|
|
61
58
|
dispatch(setIsLoading(true))
|
|
62
59
|
}, 500)
|
|
63
|
-
}, [dispatch])
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
if (hasEvents) {
|
|
61
|
+
return () => {
|
|
67
62
|
clearTimeout(spinnerTimeout.current)
|
|
68
|
-
dispatch(setIsLoading(false))
|
|
69
63
|
}
|
|
70
|
-
}, [
|
|
64
|
+
}, [dispatch])
|
|
71
65
|
|
|
72
66
|
useEffect(() => {
|
|
73
67
|
// This is needed to reset the ref to allow connect and start to happen again.
|