@seamly/web-ui 20.8.1 → 21.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.
- package/build/dist/lib/deprecated-view.js +1 -1
- package/build/dist/lib/index.debug.js +585 -584
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +110 -110
- package/build/dist/lib/index.js +20269 -26441
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +6 -1
- package/build/dist/lib/standalone.js +27728 -34583
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.LICENSE.txt +1 -1
- package/build/dist/lib/storage.js +6 -15
- package/build/dist/lib/style-guide.js +9660 -8970
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles-default-implementation.js +1 -1
- package/build/dist/lib/styles.js +1 -1
- package/build/dist/lib/utils.js +85 -3
- package/build/dist/lib/utils.min.js +1 -1
- package/package.json +54 -52
- package/src/icons/icon_check-16.svg +14 -0
- package/src/icons/icon_check-32.svg +14 -0
- package/src/javascripts/api/conversation-connector.ts +149 -0
- package/src/javascripts/api/errors/seamly-base-error.js +19 -0
- package/src/javascripts/api/errors/seamly-unavailable-error.js +5 -7
- package/src/javascripts/api/{index.js → index.ts} +163 -116
- package/src/javascripts/config.types.ts +5 -4
- package/src/javascripts/domains/app/actions.ts +47 -46
- package/src/javascripts/domains/app/hooks.js +1 -1
- package/src/javascripts/domains/config/actions.ts +2 -8
- package/src/javascripts/domains/config/hooks.ts +1 -1
- package/src/javascripts/domains/config/selectors.ts +6 -6
- package/src/javascripts/domains/config/slice.ts +3 -3
- package/src/javascripts/domains/errors/index.ts +66 -0
- package/src/javascripts/domains/forms/context.ts +1 -1
- package/src/javascripts/domains/forms/forms.types.ts +3 -3
- package/src/javascripts/domains/forms/hooks.ts +10 -10
- package/src/javascripts/domains/forms/provider.tsx +9 -9
- package/src/javascripts/domains/i18n/actions.ts +11 -5
- package/src/javascripts/domains/i18n/hooks.ts +11 -8
- package/src/javascripts/domains/i18n/selectors.ts +10 -4
- package/src/javascripts/domains/i18n/slice.ts +0 -1
- package/src/javascripts/domains/interrupt/hooks.ts +1 -1
- package/src/javascripts/domains/interrupt/middleware.ts +1 -1
- package/src/javascripts/domains/store/index.ts +1 -1
- package/src/javascripts/domains/store/selectors.ts +16 -0
- package/src/javascripts/domains/store/slice.ts +47 -41
- package/src/javascripts/domains/store/store.types.ts +38 -10
- package/src/javascripts/domains/translations/components/{options-button.js → options-button.tsx} +30 -20
- package/src/javascripts/domains/translations/components/options-dialog/index.tsx +33 -0
- package/src/javascripts/domains/translations/components/options-dialog/translation-option.tsx +37 -0
- package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx +85 -0
- package/src/javascripts/domains/translations/components/translation-status.tsx +15 -0
- package/src/javascripts/domains/translations/hooks.ts +77 -11
- package/src/javascripts/domains/translations/slice.ts +20 -9
- package/src/javascripts/domains/translations/translations.types.ts +4 -2
- package/src/javascripts/domains/visibility/actions.ts +6 -10
- package/src/javascripts/domains/visibility/hooks.ts +33 -14
- package/src/javascripts/domains/visibility/selectors.ts +3 -2
- package/src/javascripts/domains/visibility/slice.ts +2 -6
- package/src/javascripts/index.ts +19 -21
- package/src/javascripts/lib/engine/{index.js → index.tsx} +25 -7
- package/src/javascripts/lib/url-helpers.ts +112 -0
- package/src/javascripts/package/utils.js +5 -2
- package/src/javascripts/schema.ts +28 -0
- package/src/javascripts/style-guide/components/app.js +16 -12
- package/src/javascripts/style-guide/components/links.js +6 -6
- package/src/javascripts/style-guide/components/static-core.js +6 -3
- package/src/javascripts/style-guide/components/view.js +1 -1
- package/src/javascripts/style-guide/states.js +129 -31
- package/src/javascripts/style-guide/style-guide-engine.js +1 -1
- package/src/javascripts/ui/components/app-options/index.js +25 -6
- package/src/javascripts/ui/components/chat-app.js +1 -1
- package/src/javascripts/ui/components/chat-status/chat-status-action.tsx +30 -0
- package/src/javascripts/ui/components/chat-status/index.tsx +61 -0
- package/src/javascripts/ui/components/conversation/component-filter.js +9 -9
- package/src/javascripts/ui/components/conversation/{conversation.js → conversation.tsx} +32 -41
- package/src/javascripts/ui/components/conversation/event/card-component.js +2 -2
- package/src/javascripts/ui/components/conversation/event/card-message.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +4 -4
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +1 -1
- package/src/javascripts/ui/components/conversation/event/chat-scroll/chat-scroll-context.ts +12 -0
- package/src/javascripts/ui/components/conversation/event/chat-scroll/chat-scroll-provider.tsx +46 -0
- package/src/javascripts/ui/components/conversation/event/chat-scroll/unread-messages-button.tsx +27 -0
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +12 -8
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +6 -6
- package/src/javascripts/ui/components/conversation/event/cta.js +2 -2
- package/src/javascripts/ui/components/conversation/event/divider/index.js +0 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/default.js +1 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +17 -22
- package/src/javascripts/ui/components/conversation/event/divider/variants/time-indicator.js +2 -2
- package/src/javascripts/ui/components/conversation/event/event-participant.js +1 -1
- package/src/javascripts/ui/components/conversation/event/event.tsx +66 -0
- package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js +1 -1
- package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +1 -1
- package/src/javascripts/ui/components/conversation/event/image-lightbox.js +1 -1
- package/src/javascripts/ui/components/conversation/event/image.js +2 -2
- package/src/javascripts/ui/components/conversation/event/splash.js +1 -1
- package/src/javascripts/ui/components/conversation/event/translation.js +1 -1
- package/src/javascripts/ui/components/conversation/event/upload.js +2 -2
- package/src/javascripts/ui/components/conversation/event/video.js +2 -2
- package/src/javascripts/ui/components/conversation/event-divider.js +1 -1
- package/src/javascripts/ui/components/conversation/message-container.js +1 -1
- package/src/javascripts/ui/components/conversation/use-chat-scroll.ts +108 -0
- package/src/javascripts/ui/components/core/{seamly-activity-monitor.js → seamly-activity-monitor.tsx} +12 -5
- package/src/javascripts/ui/components/core/seamly-api-context.ts +7 -0
- package/src/javascripts/ui/components/core/seamly-chat.tsx +8 -0
- package/src/javascripts/ui/components/core/{seamly-core.js → seamly-core.tsx} +27 -14
- package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +340 -0
- package/src/javascripts/ui/components/core/seamly-file-upload.js +2 -2
- package/src/javascripts/ui/components/core/seamly-idle-detach-counter.js +1 -1
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +24 -11
- package/src/javascripts/ui/components/core/seamly-live-region.js +4 -4
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +3 -3
- package/src/javascripts/ui/components/core/seamly-read-state.js +2 -33
- package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +4 -4
- package/src/javascripts/ui/components/entry/entry-container.js +8 -8
- package/src/javascripts/ui/components/entry/text-entry/hooks.js +3 -3
- package/src/javascripts/ui/components/entry/text-entry/index.js +3 -3
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +4 -4
- package/src/javascripts/ui/components/entry/upload/file-upload-form.js +3 -3
- package/src/javascripts/ui/components/entry/upload/index.js +5 -5
- package/src/javascripts/ui/components/entry/upload-toggle.js +6 -6
- package/src/javascripts/ui/components/faq/faq.js +14 -14
- package/src/javascripts/ui/components/form-controls/error.js +2 -2
- package/src/javascripts/ui/components/form-controls/file-input.js +3 -3
- package/src/javascripts/ui/components/layout/agent-info.js +3 -3
- package/src/javascripts/ui/components/layout/chat-frame.js +20 -12
- package/src/javascripts/ui/components/layout/chat.js +5 -5
- package/src/javascripts/ui/components/layout/deprecated-app-frame.js +6 -6
- package/src/javascripts/ui/components/layout/deprecated-chat-frame.js +34 -0
- package/src/javascripts/ui/components/layout/header.js +2 -2
- package/src/javascripts/ui/components/layout/icon.js +11 -9
- package/src/javascripts/ui/components/layout/interrupt.js +7 -5
- package/src/javascripts/ui/components/layout/pre-chat-messages.js +1 -1
- package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
- package/src/javascripts/ui/components/options/options-button.js +5 -5
- package/src/javascripts/ui/components/options/{options-frame.js → options-frame.tsx} +52 -18
- package/src/javascripts/ui/components/options/transcript/index.js +9 -10
- package/src/javascripts/ui/components/options/transcript/transcript-form.js +2 -2
- package/src/javascripts/ui/components/suggestions/index.js +8 -8
- package/src/javascripts/ui/components/suggestions/suggestions-item.js +1 -1
- package/src/javascripts/{domains/translations/components/chat-status.js → ui/components/translation-chat-status/index.tsx} +13 -14
- package/src/javascripts/ui/components/translation-proposal/index.tsx +36 -0
- package/src/javascripts/ui/components/view/app-view.js +2 -7
- package/src/javascripts/ui/components/view/deprecated-view.js +8 -10
- package/src/javascripts/ui/components/view/index.js +6 -6
- package/src/javascripts/ui/components/view/inline-view.js +4 -8
- package/src/javascripts/ui/components/view/window-view/collapse-button.js +2 -2
- package/src/javascripts/ui/components/view/window-view/index.js +11 -17
- package/src/javascripts/ui/components/view/window-view/window-open-button.js +6 -6
- package/src/javascripts/ui/components/warnings/idle-detach-warning.js +3 -3
- package/src/javascripts/ui/components/warnings/prompt.js +1 -1
- package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +4 -4
- package/src/javascripts/ui/components/widgets/in-out-transition.js +20 -18
- package/src/javascripts/ui/components/widgets/lightbox.js +3 -3
- package/src/javascripts/ui/components/widgets/modal.js +2 -2
- package/src/javascripts/ui/components/widgets/upload-progress.js +2 -2
- package/src/javascripts/ui/hooks/file-upload-hooks.js +1 -1
- package/src/javascripts/ui/hooks/focus-helper-hooks.js +1 -1
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +6 -6
- package/src/javascripts/ui/hooks/seamly-hooks.js +11 -10
- package/src/javascripts/ui/hooks/seamly-option-hooks.js +6 -6
- package/src/javascripts/ui/hooks/{seamly-state-hooks.js → seamly-state-hooks.ts} +9 -6
- package/src/javascripts/ui/hooks/use-click-outside.ts +29 -0
- package/src/javascripts/ui/hooks/use-event-component-mapping.js +11 -10
- package/src/javascripts/ui/hooks/use-interval.js +1 -1
- package/src/javascripts/ui/hooks/use-seamly-actions.ts +29 -29
- package/src/javascripts/ui/hooks/use-seamly-chat.js +13 -23
- package/src/javascripts/ui/hooks/use-seamly-commands.js +20 -15
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +8 -8
- package/src/javascripts/ui/hooks/use-seamly-resume-conversation-prompt.js +2 -2
- package/src/javascripts/ui/hooks/use-single-file-upload.js +1 -1
- package/src/javascripts/ui/hooks/utility-hooks.js +1 -1
- package/src/javascripts/ui/utils/general-utils.js +0 -23
- package/src/javascripts/ui/utils/seamly-utils.ts +10 -1
- package/src/javascripts/ui/utils/seamly-utils.types.ts +9 -0
- package/src/stylesheets/1-settings/_config.scss +1 -1
- package/src/stylesheets/3-chat/_chat.scss +23 -5
- package/src/stylesheets/5-components/_chat-status.scss +72 -16
- package/src/stylesheets/5-components/_conversation.scss +35 -1
- package/src/stylesheets/5-components/_disclaimer.scss +0 -5
- package/src/stylesheets/5-components/_options.scss +16 -2
- package/src/stylesheets/5-components/_translation-options.scss +39 -0
- package/src/stylesheets/6-default-implementation/_scrollbar.scss +1 -1
- package/src/stylesheets/7-deprecated/3-app/_app.scss +19 -4
- package/src/stylesheets/7-deprecated/5-components/_chat-status.scss +5 -0
- package/src/stylesheets/7-deprecated/5-components/_options.scss +1 -0
- package/src/stylesheets/7-deprecated/5-components/_translation-options.scss +39 -0
- package/src/stylesheets/deprecated-view.scss +1 -0
- package/src/stylesheets/styles.scss +1 -0
- package/webpack/config.common.js +4 -4
- package/webpack/config.package.js +10 -16
- package/webpack/config.site.js +4 -1
- package/webpack/config.test.js +2 -1
- package/build/dist/lib/deprecated-view.css +0 -1
- package/build/dist/lib/styles-default-implementation.css +0 -1
- package/build/dist/lib/styles.css +0 -1
- package/src/.DS_Store +0 -0
- package/src/javascripts/api/event-producer.js +0 -20
- package/src/javascripts/api/producer.js +0 -136
- package/src/javascripts/domains/errors/index.js +0 -37
- package/src/javascripts/domains/translations/components/options-dialog/form.js +0 -70
- package/src/javascripts/domains/translations/components/options-dialog/index.js +0 -87
- package/src/javascripts/ui/components/chat-status/index.js +0 -38
- package/src/javascripts/ui/components/conversation/event/event.js +0 -36
- package/src/javascripts/ui/components/core/seamly-api-context.js +0 -5
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +0 -279
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import SeamlyGeneralError from 'api/errors/seamly-general-error'
|
|
2
|
-
import SeamlyOfflineError from 'api/errors/seamly-offline-error'
|
|
3
|
-
import SeamlySessionExpiredError from 'api/errors/seamly-session-expired-error'
|
|
4
|
-
import { setHasResponded } from 'domains/app/slice'
|
|
5
|
-
import { clearInterrupt, setInterrupt } from 'domains/interrupt/slice'
|
|
6
|
-
import {
|
|
7
|
-
ackEvent,
|
|
8
|
-
addEvent,
|
|
9
|
-
clearEvents,
|
|
10
|
-
initResumeConversationPrompt,
|
|
11
|
-
setActiveService,
|
|
12
|
-
setFeatureEnabledState,
|
|
13
|
-
setHeaderSubTitle,
|
|
14
|
-
setHistory,
|
|
15
|
-
setIsLoading,
|
|
16
|
-
setParticipant,
|
|
17
|
-
setServiceDataItem,
|
|
18
|
-
setServiceEntryMetadata,
|
|
19
|
-
} from 'domains/store/slice'
|
|
20
|
-
import { useEffect, useRef } from 'preact/hooks'
|
|
21
|
-
import { useDispatch } from 'react-redux'
|
|
22
|
-
import {
|
|
23
|
-
useEvents,
|
|
24
|
-
useSeamlyApiContext,
|
|
25
|
-
useSeamlyCommands,
|
|
26
|
-
useSeamlyIdleDetachCountdown,
|
|
27
|
-
} from 'ui/hooks/seamly-hooks'
|
|
28
|
-
import { featureKeys } from 'ui/utils/seamly-utils'
|
|
29
|
-
|
|
30
|
-
const EMITTABLE_MESSAGE_TYPES = ['text', 'choice_prompt', 'image', 'video']
|
|
31
|
-
|
|
32
|
-
const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
33
|
-
const api = useSeamlyApiContext()
|
|
34
|
-
const dispatch = useDispatch()
|
|
35
|
-
const events = useEvents()
|
|
36
|
-
const prevEmittedEventId = useRef(null)
|
|
37
|
-
const { initCountdown, endCountdown } = useSeamlyIdleDetachCountdown()
|
|
38
|
-
const { emitEvent } = useSeamlyCommands()
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (api.connectionInfo) {
|
|
42
|
-
const updateParticipant = (event) => {
|
|
43
|
-
const { payload } = event
|
|
44
|
-
|
|
45
|
-
if (!payload || !payload.participant) {
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const { fromClient, participant } = payload
|
|
50
|
-
|
|
51
|
-
if (!fromClient && participant.name) {
|
|
52
|
-
dispatch(setHeaderSubTitle(participant.name))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
dispatch(
|
|
56
|
-
setParticipant({
|
|
57
|
-
participant,
|
|
58
|
-
fromClient,
|
|
59
|
-
}),
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
if (participant.introduction) {
|
|
63
|
-
dispatch(addEvent(event))
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const subscription = api.stream().subscribe({
|
|
68
|
-
next: (event) => {
|
|
69
|
-
const { type, payload } = event
|
|
70
|
-
switch (type) {
|
|
71
|
-
case 'ui':
|
|
72
|
-
if (payload.state && payload.state.hasOwnProperty('loading')) {
|
|
73
|
-
dispatch(setIsLoading(payload.state.loading))
|
|
74
|
-
}
|
|
75
|
-
switch (payload.type) {
|
|
76
|
-
case 'idle_detach_countdown':
|
|
77
|
-
initCountdown(payload.body.duration)
|
|
78
|
-
break
|
|
79
|
-
case 'idle_detach_countdown_elapsed':
|
|
80
|
-
endCountdown(undefined, true)
|
|
81
|
-
break
|
|
82
|
-
case 'resume_conversation_prompt':
|
|
83
|
-
dispatch(initResumeConversationPrompt())
|
|
84
|
-
break
|
|
85
|
-
case 'user_first_response':
|
|
86
|
-
dispatch(setHasResponded(true))
|
|
87
|
-
eventBus.emit('system.userFirstResponse', payload.body)
|
|
88
|
-
break
|
|
89
|
-
}
|
|
90
|
-
break
|
|
91
|
-
case 'message':
|
|
92
|
-
updateParticipant(payload)
|
|
93
|
-
switch (payload.type) {
|
|
94
|
-
case 'text':
|
|
95
|
-
case 'choice_prompt':
|
|
96
|
-
case 'splash':
|
|
97
|
-
case 'image':
|
|
98
|
-
case 'upload':
|
|
99
|
-
case 'video':
|
|
100
|
-
case 'cta':
|
|
101
|
-
case 'custom':
|
|
102
|
-
case 'carousel':
|
|
103
|
-
case 'card':
|
|
104
|
-
if (payload.service && payload.service.serviceSessionId) {
|
|
105
|
-
dispatch(setActiveService(payload.service.serviceSessionId))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
dispatch(addEvent(event))
|
|
109
|
-
break
|
|
110
|
-
}
|
|
111
|
-
break
|
|
112
|
-
case 'participant':
|
|
113
|
-
updateParticipant(event)
|
|
114
|
-
break
|
|
115
|
-
case 'service_data':
|
|
116
|
-
if (payload.persist) {
|
|
117
|
-
dispatch(setServiceDataItem(payload))
|
|
118
|
-
}
|
|
119
|
-
break
|
|
120
|
-
case 'ack':
|
|
121
|
-
dispatch(ackEvent(event.payload))
|
|
122
|
-
break
|
|
123
|
-
case 'system':
|
|
124
|
-
if (payload.type === 'service_changed') {
|
|
125
|
-
const { serviceSettings, ...eventPayload } = payload
|
|
126
|
-
const { entry } = serviceSettings
|
|
127
|
-
const { upload } = entry.options
|
|
128
|
-
|
|
129
|
-
dispatch(
|
|
130
|
-
setFeatureEnabledState({
|
|
131
|
-
key: featureKeys.uploads,
|
|
132
|
-
enabled: !!(upload && upload.enabled),
|
|
133
|
-
}),
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
dispatch(setServiceEntryMetadata(entry))
|
|
137
|
-
dispatch(setActiveService(payload.serviceSessionId))
|
|
138
|
-
|
|
139
|
-
emitEvent('system.serviceChanged', eventPayload)
|
|
140
|
-
}
|
|
141
|
-
break
|
|
142
|
-
case 'info':
|
|
143
|
-
if (
|
|
144
|
-
payload.type === 'divider' ||
|
|
145
|
-
payload.type === 'text' ||
|
|
146
|
-
payload.type === 'translation'
|
|
147
|
-
) {
|
|
148
|
-
dispatch(addEvent(event))
|
|
149
|
-
}
|
|
150
|
-
break
|
|
151
|
-
case 'error':
|
|
152
|
-
switch (payload.type) {
|
|
153
|
-
case 'find_conversation_erred':
|
|
154
|
-
const seamlySessionExpiredError =
|
|
155
|
-
new SeamlySessionExpiredError(event)
|
|
156
|
-
dispatch(
|
|
157
|
-
setInterrupt({
|
|
158
|
-
name: seamlySessionExpiredError.name,
|
|
159
|
-
action: seamlySessionExpiredError.action,
|
|
160
|
-
message: seamlySessionExpiredError.message,
|
|
161
|
-
originalEvent: seamlySessionExpiredError.originalEvent,
|
|
162
|
-
originalError: seamlySessionExpiredError.originalError,
|
|
163
|
-
}),
|
|
164
|
-
)
|
|
165
|
-
break
|
|
166
|
-
case 'seamly_offline':
|
|
167
|
-
const seamlyOfflineError = new SeamlyOfflineError(event)
|
|
168
|
-
dispatch(
|
|
169
|
-
setInterrupt({
|
|
170
|
-
name: seamlyOfflineError.name,
|
|
171
|
-
message: seamlyOfflineError.message,
|
|
172
|
-
langKey: seamlyOfflineError.langKey,
|
|
173
|
-
originalEvent: seamlyOfflineError.originalEvent,
|
|
174
|
-
originalError: seamlyOfflineError.originalError,
|
|
175
|
-
}),
|
|
176
|
-
)
|
|
177
|
-
dispatch(clearEvents())
|
|
178
|
-
break
|
|
179
|
-
default:
|
|
180
|
-
const seamlyGeneralError = new SeamlyGeneralError(event)
|
|
181
|
-
dispatch(
|
|
182
|
-
setInterrupt({
|
|
183
|
-
name: seamlyGeneralError.name,
|
|
184
|
-
message: seamlyGeneralError.message,
|
|
185
|
-
langKey: seamlyGeneralError.langKey,
|
|
186
|
-
originalEvent: seamlyGeneralError.originalEvent,
|
|
187
|
-
originalError: seamlyGeneralError.originalError,
|
|
188
|
-
action: seamlyGeneralError.action,
|
|
189
|
-
}),
|
|
190
|
-
)
|
|
191
|
-
break
|
|
192
|
-
}
|
|
193
|
-
break
|
|
194
|
-
case 'socket_opened':
|
|
195
|
-
dispatch(clearInterrupt())
|
|
196
|
-
break
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
api
|
|
202
|
-
.stream()
|
|
203
|
-
.filter(
|
|
204
|
-
(e) =>
|
|
205
|
-
e.type === 'message' &&
|
|
206
|
-
EMITTABLE_MESSAGE_TYPES.includes(e.payload.type),
|
|
207
|
-
)
|
|
208
|
-
.subscribe({
|
|
209
|
-
next: ({ payload }) => {
|
|
210
|
-
// This check dedupes the sending of messages via
|
|
211
|
-
// the bus if a duplicate connection exists in an
|
|
212
|
-
// error situation.
|
|
213
|
-
if (payload.id !== prevEmittedEventId.current) {
|
|
214
|
-
eventBus.emit('message', payload)
|
|
215
|
-
}
|
|
216
|
-
prevEmittedEventId.current = payload.id
|
|
217
|
-
},
|
|
218
|
-
})
|
|
219
|
-
return () => {
|
|
220
|
-
subscription.unsubscribe()
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return () => undefined
|
|
224
|
-
}, [dispatch, api, eventBus, initCountdown, endCountdown, emitEvent])
|
|
225
|
-
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
const subscribe = () => {
|
|
228
|
-
return api
|
|
229
|
-
.stream()
|
|
230
|
-
.filter((e) => e.type === 'sync')
|
|
231
|
-
.subscribe({
|
|
232
|
-
next: (event) => {
|
|
233
|
-
const { payload } = event
|
|
234
|
-
|
|
235
|
-
const lastEvent = events[events.length - 1]
|
|
236
|
-
const { id: payloadLastEventId } = payload.lastEvent
|
|
237
|
-
|
|
238
|
-
if (lastEvent && payloadLastEventId === lastEvent.payload.id) {
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
api
|
|
243
|
-
.getConversation()
|
|
244
|
-
.then((history) => {
|
|
245
|
-
if (!history) {
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
dispatch(setHistory(history))
|
|
250
|
-
})
|
|
251
|
-
.catch((error) => {
|
|
252
|
-
dispatch(
|
|
253
|
-
setInterrupt({
|
|
254
|
-
name: error.name,
|
|
255
|
-
message: error.message,
|
|
256
|
-
langKey: error.langKey,
|
|
257
|
-
originalEvent: error.originalEvent,
|
|
258
|
-
originalError: error.originalError,
|
|
259
|
-
}),
|
|
260
|
-
)
|
|
261
|
-
})
|
|
262
|
-
},
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (api.stream) {
|
|
267
|
-
const subscription = subscribe()
|
|
268
|
-
return () => {
|
|
269
|
-
subscription.unsubscribe()
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return () => undefined
|
|
274
|
-
}, [api, events, dispatch])
|
|
275
|
-
|
|
276
|
-
return null
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export default SeamlyEventSubscriber
|