@seamly/web-ui 20.5.0 → 20.6.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.
@@ -13,6 +13,34 @@ import Event from './event/event'
13
13
  import Loader from './loader'
14
14
  import ComponentFilter from './component-filter'
15
15
 
16
+ const Events = () => {
17
+ const events = useEvents()
18
+
19
+ let prevParticipant = null
20
+ return events.map((event) => {
21
+ const { type, payload } = event
22
+ const { participant, fromClient } = payload
23
+ let participantChanged = false
24
+ if (type !== 'participant') {
25
+ const currentParticipant = fromClient
26
+ ? 'seamly-client-participant'
27
+ : participant
28
+ if (event.type !== 'info' && prevParticipant !== currentParticipant) {
29
+ participantChanged = true
30
+ }
31
+ prevParticipant = currentParticipant
32
+ }
33
+
34
+ return (
35
+ <Event
36
+ key={event.payload.key || event.payload.id}
37
+ event={event}
38
+ newParticipant={participantChanged}
39
+ />
40
+ )
41
+ })
42
+ }
43
+
16
44
  const Conversation = () => {
17
45
  const { t } = useI18n()
18
46
  const chatBodyContainer = useRef(null)
@@ -30,31 +58,6 @@ const Conversation = () => {
30
58
  }
31
59
  }, [events, isLoading, isOpen, loadedImageEventIds])
32
60
 
33
- const renderEvents = () => {
34
- let prevParticipant = null
35
- return events.map((event) => {
36
- const { type, payload } = event
37
- const { participant, fromClient } = payload
38
- let participantChanged = false
39
- if (type !== 'participant') {
40
- const currentParticipant = fromClient
41
- ? 'seamly-client-participant'
42
- : participant
43
- if (event.type !== 'info' && prevParticipant !== currentParticipant) {
44
- participantChanged = true
45
- }
46
- prevParticipant = currentParticipant
47
- }
48
- return (
49
- <Event
50
- key={event.payload.id}
51
- event={event}
52
- newParticipant={participantChanged}
53
- />
54
- )
55
- })
56
- }
57
-
58
61
  const onClickHandler = (e) => {
59
62
  e.preventDefault()
60
63
  focusSkiplinkTarget()
@@ -75,7 +78,9 @@ const Conversation = () => {
75
78
  <div className={className('conversation__container')}>
76
79
  <PrivacyDisclaimer />
77
80
  <ol className={className('conversation')}>
78
- <ComponentFilter>{renderEvents()}</ComponentFilter>
81
+ <ComponentFilter>
82
+ <Events />
83
+ </ComponentFilter>
79
84
  {isLoading && <Loader />}
80
85
  </ol>
81
86
  </div>
@@ -1,3 +1,4 @@
1
+ import { randomId } from 'lib/id'
1
2
  import { getTimeFromSeconds } from './general-utils'
2
3
 
3
4
  export const eventTypes = {
@@ -355,6 +356,8 @@ export const seamlyStateReducer = (state, action) => {
355
356
  ? readStates.read
356
357
  : readStates.received,
357
358
  }),
359
+ // We add a randomid to use as key for mapping of Events to avoid rerendering
360
+ key: randomId(),
358
361
  ...payload,
359
362
  },
360
363
  },
@@ -1,4 +1,6 @@
1
- module.exports = (env, argv, { PUBLIC_PATH }) => ({
1
+ const path = require('path')
2
+
3
+ module.exports = (env, argv, { PUBLIC_PATH, SRC_ROOT }) => ({
2
4
  devtool: 'eval-source-map',
3
5
  devServer: {
4
6
  headers: { 'Access-Control-Allow-Origin': '*' },
@@ -9,4 +11,11 @@ module.exports = (env, argv, { PUBLIC_PATH }) => ({
9
11
  allowedHosts: 'all',
10
12
  hot: true,
11
13
  },
14
+ resolve: {
15
+ alias: {
16
+ api: path.resolve(SRC_ROOT, 'javascripts/api'),
17
+ domains: path.resolve(SRC_ROOT, 'javascripts/domains'),
18
+ ui: path.resolve(SRC_ROOT, 'javascripts/ui'),
19
+ },
20
+ },
12
21
  })
package/src/.DS_Store DELETED
Binary file