|
@@ -32,11 +32,51 @@ type Props = {
|
32
|
32
|
t: Function
|
33
|
33
|
};
|
34
|
34
|
|
|
35
|
+/**
|
|
36
|
+ * State of the component.
|
|
37
|
+ */
|
|
38
|
+type State = {
|
|
39
|
+
|
|
40
|
+ /**
|
|
41
|
+ * True if the label status is stale, so it needs to be removed.
|
|
42
|
+ */
|
|
43
|
+ staleLabel: boolean
|
|
44
|
+};
|
|
45
|
+
|
|
46
|
+/**
|
|
47
|
+ * The timeout after a label is considered stale. See {@code _updateStaleStatus}
|
|
48
|
+ * for more details.
|
|
49
|
+ */
|
|
50
|
+const STALE_TIMEOUT = 10 * 1000;
|
|
51
|
+
|
35
|
52
|
/**
|
36
|
53
|
* Abstract class for the {@code RecordingLabel} component.
|
37
|
54
|
*/
|
38
|
55
|
export default class AbstractRecordingLabel
|
39
|
|
- extends Component<Props> {
|
|
56
|
+ extends Component<Props, State> {
|
|
57
|
+ /**
|
|
58
|
+ * Initializes a new {@code AbstractRecordingLabel} component.
|
|
59
|
+ *
|
|
60
|
+ * @inheritdoc
|
|
61
|
+ */
|
|
62
|
+ constructor(props: Props) {
|
|
63
|
+ super(props);
|
|
64
|
+
|
|
65
|
+ this.state = {
|
|
66
|
+ staleLabel: false
|
|
67
|
+ };
|
|
68
|
+
|
|
69
|
+ this._updateStaleStatus({}, props);
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ /**
|
|
73
|
+ * Implements {@code Component#componentWillReceiveProps}.
|
|
74
|
+ *
|
|
75
|
+ * @inheritdoc
|
|
76
|
+ */
|
|
77
|
+ componentWillReceiveProps(newProps: Props) {
|
|
78
|
+ this._updateStaleStatus(this.props, newProps);
|
|
79
|
+ }
|
40
|
80
|
|
41
|
81
|
/**
|
42
|
82
|
* Implements React {@code Component}'s render.
|
|
@@ -44,7 +84,8 @@ export default class AbstractRecordingLabel
|
44
|
84
|
* @inheritdoc
|
45
|
85
|
*/
|
46
|
86
|
render() {
|
47
|
|
- return this.props._status ? this._renderLabel() : null;
|
|
87
|
+ return this.props._status && !this.state.staleLabel
|
|
88
|
+ ? this._renderLabel() : null;
|
48
|
89
|
}
|
49
|
90
|
|
50
|
91
|
_getLabelKey: () => ?string
|
|
@@ -75,6 +116,34 @@ export default class AbstractRecordingLabel
|
75
|
116
|
*/
|
76
|
117
|
_renderLabel: () => React$Element<*>
|
77
|
118
|
|
|
119
|
+ /**
|
|
120
|
+ * Updates the stale status of the label on a prop change. A label is stale
|
|
121
|
+ * if it's in a {@code _status} that doesn't need to be rendered anymore.
|
|
122
|
+ *
|
|
123
|
+ * @param {Props} oldProps - The previous props of the component.
|
|
124
|
+ * @param {Props} newProps - The new props of the component.
|
|
125
|
+ * @returns {void}
|
|
126
|
+ */
|
|
127
|
+ _updateStaleStatus(oldProps, newProps) {
|
|
128
|
+ if (newProps._status === JitsiRecordingConstants.status.OFF) {
|
|
129
|
+ if (oldProps._status !== JitsiRecordingConstants.status.OFF) {
|
|
130
|
+ setTimeout(() => {
|
|
131
|
+ // Only if it's still OFF.
|
|
132
|
+ if (this.props._status
|
|
133
|
+ === JitsiRecordingConstants.status.OFF) {
|
|
134
|
+ this.setState({
|
|
135
|
+ staleLabel: true
|
|
136
|
+ });
|
|
137
|
+ }
|
|
138
|
+ }, STALE_TIMEOUT);
|
|
139
|
+ }
|
|
140
|
+ } else if (this.state.staleLabel) {
|
|
141
|
+ this.setState({
|
|
142
|
+ staleLabel: false
|
|
143
|
+ });
|
|
144
|
+ }
|
|
145
|
+ }
|
|
146
|
+
|
78
|
147
|
}
|
79
|
148
|
|
80
|
149
|
/**
|