mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 10:58:23 -05:00
Rename state's muteExpiresAt to muteExpiresAtMs so units are explicit.
Also, fix isMuted so it doesn't do an extra unit conversion.
This commit is contained in:
parent
8d4a5c2f91
commit
110077e8e8
2 changed files with 11 additions and 11 deletions
|
@ -48,7 +48,7 @@ class ComposeComment extends React.Component {
|
|||
error: null,
|
||||
appealId: null,
|
||||
muteOpen: false,
|
||||
muteExpiresAt: this.props.muteStatus.muteExpiresAt * 1000 // convert to ms
|
||||
muteExpiresAtMs: this.props.muteStatus.muteExpiresAt * 1000 // convert to ms
|
||||
};
|
||||
}
|
||||
handleInput (event) {
|
||||
|
@ -78,10 +78,10 @@ class ComposeComment extends React.Component {
|
|||
}
|
||||
if (body.rejected && this.state.status === ComposeStatus.SUBMITTING) {
|
||||
let muteOpen = false;
|
||||
let muteExpiresAt = 0;
|
||||
let muteExpiresAtMs = 0;
|
||||
let rejectedStatus = ComposeStatus.REJECTED;
|
||||
if (body.status && body.status.mute_status) {
|
||||
muteExpiresAt = body.status.mute_status.muteExpiresAt * 1000; // convert to ms
|
||||
muteExpiresAtMs = body.status.mute_status.muteExpiresAt * 1000; // convert to ms
|
||||
rejectedStatus = ComposeStatus.REJECTED_MUTE;
|
||||
if (this.shouldShowMuteModal(body.status.mute_status.offenses)) {
|
||||
muteOpen = true;
|
||||
|
@ -93,7 +93,7 @@ class ComposeComment extends React.Component {
|
|||
error: body.rejected,
|
||||
appealId: body.appealId,
|
||||
muteOpen: muteOpen,
|
||||
muteExpiresAt: muteExpiresAt
|
||||
muteExpiresAtMs: muteExpiresAtMs
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class ComposeComment extends React.Component {
|
|||
}
|
||||
|
||||
isMuted () {
|
||||
return this.state.muteExpiresAt * 1000 > Date.now();
|
||||
return this.state.muteExpiresAtMs > Date.now();
|
||||
}
|
||||
|
||||
handleMuteClose () {
|
||||
|
@ -174,7 +174,7 @@ class ComposeComment extends React.Component {
|
|||
<CommentingStatus>
|
||||
<p>Scratch thinks your comment was disrespectful.</p>
|
||||
<p> You will be able to comment
|
||||
again {formatTime.formatRelativeTime(this.state.muteExpiresAt, window._locale)}.
|
||||
again {formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}.
|
||||
Your account has been paused from commenting until then.
|
||||
|
||||
</p>
|
||||
|
@ -263,7 +263,7 @@ class ComposeComment extends React.Component {
|
|||
useStandardSizes
|
||||
className="mod-mute"
|
||||
shouldCloseOnOverlayClick={false}
|
||||
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAt, window._locale)}
|
||||
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
|
||||
onRequestClose={this.handleMuteClose}
|
||||
/>
|
||||
) : null}
|
||||
|
|
|
@ -81,7 +81,7 @@ describe('Compose Comment test', () => {
|
|||
global.Date.now = () => 0;
|
||||
const component = getComposeCommentWrapper({});
|
||||
const commentInstance = component.instance();
|
||||
commentInstance.setState({muteExpiresAt: 100});
|
||||
commentInstance.setState({muteExpiresAtMs: 100});
|
||||
component.update();
|
||||
// Compose box should be hidden if muted unless they got muted due to a comment they just posted.
|
||||
expect(component.find('FlexRow.compose-comment').exists()).toEqual(false);
|
||||
|
@ -96,7 +96,7 @@ describe('Compose Comment test', () => {
|
|||
const commentInstance = component.instance();
|
||||
commentInstance.setState({
|
||||
status: 'REJECTED_MUTE',
|
||||
muteExpiresAt: 100
|
||||
muteExpiresAtMs: 100
|
||||
});
|
||||
component.update();
|
||||
expect(component.find('FlexRow.compose-comment').exists()).toEqual(true);
|
||||
|
@ -196,7 +196,7 @@ describe('Compose Comment test', () => {
|
|||
global.Date.now = () => 0; // Set "now" to 0 for easier testing.
|
||||
|
||||
const commentInstance = getComposeCommentWrapper({}).instance();
|
||||
commentInstance.setState({muteExpiresAt: 100});
|
||||
commentInstance.setState({muteExpiresAtMs: 100});
|
||||
expect(commentInstance.isMuted()).toBe(true);
|
||||
global.Date.now = realDateNow;
|
||||
});
|
||||
|
@ -206,7 +206,7 @@ describe('Compose Comment test', () => {
|
|||
global.Date.now = () => 0;
|
||||
|
||||
const commentInstance = getComposeCommentWrapper({}).instance();
|
||||
commentInstance.setState({muteExpiresAt: -100});
|
||||
commentInstance.setState({muteExpiresAtMs: -100});
|
||||
expect(commentInstance.isMuted()).toBe(false);
|
||||
global.Date.now = realDateNow;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue