forked from bigbluebutton/bbb-playback
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
119 lines (109 loc) · 3.61 KB
/
index.js
File metadata and controls
119 lines (109 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import React from 'react';
import PropTypes from 'prop-types';
import UserMessage from './user';
import PollMessage from './system/poll';
import QuestionMessage from './system/question';
import VideoMessage from './system/video';
import { ID } from 'utils/constants';
import { getMessageType } from 'utils/data';
import storage from 'utils/data/storage';
import './index.scss';
const propTypes = {
currentIndex: PropTypes.number,
setRef: PropTypes.func,
};
const defaultProps = {
currentIndex: 0,
setRef: () => { },
};
const Messages = ({
currentIndex,
scrollTo,
setRef,
}) => {
return (
<div className="list">
<div className="message-wrapper">
{storage.messages.map((item, index) => {
const active = index <= currentIndex;
const { timestamp } = item;
const type = getMessageType(item);
switch (type) {
case ID.USERS:
const indexOfMessageToBeReplied = (item.replyToMessageId)
? storage.messages.findIndex((message) => message.id === item.replyToMessageId) : -1;
const messageToBeReplied = (indexOfMessageToBeReplied !== -1)
? storage.messages[indexOfMessageToBeReplied]
: null;
return (
<span
key={item.id}
id={item.id}
className='user-message-wrapper'
ref={node => setRef(node, index)}>
<UserMessage
edited={!!item.lastEditedTimestamp}
reactions={item.reactions}
active={active}
emphasized={item.emphasized}
hyperlink={item.hyperlink}
initials={item.initials}
moderator={item.moderator}
name={item.name}
messageToBeReplied={messageToBeReplied}
scrollTo={scrollTo}
text={item.message}
timestamp={timestamp}
/>
</span>
);
case ID.POLLS:
return (
<span ref={node => setRef(node, index)}>
<PollMessage
active={active}
answers={item.answers}
question={item.question}
responders={item.responders}
timestamp={timestamp}
type={item.type}
isQuiz={item.isQuiz}
showCorrectAnswer={item.showCorrectAnswer}
/>
</span>
);
case ID.QUESTIONS:
return (
<span ref={node => setRef(node, index)}>
<QuestionMessage
active={active}
answer={item.answer}
text={item.text}
timestamp={timestamp}
/>
</span>
);
case ID.VIDEOS:
return (
<span ref={node => setRef(node, index)}>
<VideoMessage
active={active}
url={item.url}
timestamp={timestamp}
type={item.type}
isAudio={item.isAudio}
isLocal={item.isLocal}
/>
</span>
);
default:
return <span ref={node => setRef(node, index)} />;
}
})}
</div>
</div>
);
};
Messages.propTypes = propTypes;
Messages.defaultProps = defaultProps;
export default Messages;