Selaa lähdekoodia

ref(recording-label): derive when the label state is no longer stale

master
Leonard Kim 6 vuotta sitten
vanhempi
commit
d4e18e78fa
1 muutettua tiedostoa jossa 15 lisäystä ja 8 poistoa
  1. 15
    8
      react/features/recording/components/AbstractRecordingLabel.js

+ 15
- 8
react/features/recording/components/AbstractRecordingLabel.js Näytä tiedosto

@@ -54,6 +54,18 @@ const STALE_TIMEOUT = 10 * 1000;
54 54
  */
55 55
 export default class AbstractRecordingLabel
56 56
     extends Component<Props, State> {
57
+    /**
58
+     * Implements {@code Component#getDerivedStateFromProps}.
59
+     *
60
+     * @inheritdoc
61
+     */
62
+    static getDerivedStateFromProps(props: Props, prevState: State) {
63
+        return {
64
+            staleLabel: props._status !== JitsiRecordingConstants.status.OFF
65
+                && prevState.staleLabel ? false : prevState.staleLabel
66
+        };
67
+    }
68
+
57 69
     /**
58 70
      * Initializes a new {@code AbstractRecordingLabel} component.
59 71
      *
@@ -70,12 +82,12 @@ export default class AbstractRecordingLabel
70 82
     }
71 83
 
72 84
     /**
73
-     * Implements {@code Component#componentWillReceiveProps}.
85
+     * Implements {@code Component#componentDidUpdate}.
74 86
      *
75 87
      * @inheritdoc
76 88
      */
77
-    componentWillReceiveProps(newProps: Props) {
78
-        this._updateStaleStatus(this.props, newProps);
89
+    componentDidUpdate(prevProps: Props) {
90
+        this._updateStaleStatus(prevProps, this.props);
79 91
     }
80 92
 
81 93
     /**
@@ -137,13 +149,8 @@ export default class AbstractRecordingLabel
137 149
                     }
138 150
                 }, STALE_TIMEOUT);
139 151
             }
140
-        } else if (this.state.staleLabel) {
141
-            this.setState({
142
-                staleLabel: false
143
-            });
144 152
         }
145 153
     }
146
-
147 154
 }
148 155
 
149 156
 /**

Loading…
Peruuta
Tallenna