mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 05:04:57 +08:00
Apply suggestions from code review
This commit is contained in:
parent
6cb86057c5
commit
e519e704e9
@ -37,13 +37,13 @@ export default class LiveRecordingClock extends React.PureComponent<IProps, ISta
|
||||
private scheduledUpdate = new MarkedExecution(
|
||||
() => this.updateClock(),
|
||||
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
|
||||
)
|
||||
);
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
seconds: 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@ -56,7 +56,7 @@ export default class LiveRecordingClock extends React.PureComponent<IProps, ISta
|
||||
private updateClock() {
|
||||
this.setState({
|
||||
seconds: this.seconds,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
@ -25,7 +25,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
interface IState {
|
||||
waveform: number[]
|
||||
waveform: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,13 +41,13 @@ export default class LiveRecordingWaveform extends React.PureComponent<IProps, I
|
||||
private scheduledUpdate = new MarkedExecution(
|
||||
() => this.updateWaveform(),
|
||||
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
|
||||
)
|
||||
);
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
waveform: [],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -22,7 +22,7 @@ limitations under the License.
|
||||
* The function starts unmarked.
|
||||
*/
|
||||
export class MarkedExecution {
|
||||
private _marked = false;
|
||||
private marked = false;
|
||||
|
||||
/**
|
||||
* Creates a MarkedExecution for the provided function.
|
||||
@ -37,22 +37,22 @@ export class MarkedExecution {
|
||||
* Resets the mark without calling the function.
|
||||
*/
|
||||
public reset() {
|
||||
this._marked = false;
|
||||
this.marked = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the function to be called upon trigger().
|
||||
*/
|
||||
public mark() {
|
||||
if (!this._marked) this.onMarkCallback?.();
|
||||
this._marked = true;
|
||||
if (!this.marked) this.onMarkCallback?.();
|
||||
this.marked = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If marked, the function will be called, otherwise this does nothing.
|
||||
*/
|
||||
public trigger() {
|
||||
if (!this._marked) return;
|
||||
if (!this.marked) return;
|
||||
this.reset(); // reset first just in case the fn() causes a trigger()
|
||||
this.fn();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user