Commit 23da1e27 authored by seotts's avatar seotts

Continued work

parent cf71b776
...@@ -97,18 +97,20 @@ class ComposeComment extends React.Component { ...@@ -97,18 +97,20 @@ class ComposeComment extends React.Component {
let muteOpen = false; let muteOpen = false;
let muteExpiresAtMs = 0; let muteExpiresAtMs = 0;
let rejectedStatus = ComposeStatus.REJECTED; let rejectedStatus = ComposeStatus.REJECTED;
let justMuted = true;
let showWarning = false; let showWarning = false;
let muteType = null; let muteType = null;
if (body.status && body.status.mute_status) { if (body.status && body.status.mute_status) {
muteExpiresAtMs = body.status.mute_status.muteExpiresAt * 1000; // convert to ms muteExpiresAtMs = body.status.mute_status.muteExpiresAt * 1000; // convert to ms
if (body.rejected === 'isBad') { if (body.rejected === JUST_MUTED_ERROR) {
rejectedStatus = ComposeStatus.REJECTED_MUTE; rejectedStatus = ComposeStatus.REJECTED_MUTE;
} else { } else {
rejectedStatus = ComposeStatus.COMPOSE_DISALLOWED; rejectedStatus = ComposeStatus.COMPOSE_DISALLOWED;
justMuted = false;
} }
if (this.shouldShowMuteModal(body.status.mute_status)) { if (this.shouldShowMuteModal(body.status.mute_status, justMuted)) {
muteOpen = true; muteOpen = true;
} }
...@@ -170,7 +172,7 @@ class ComposeComment extends React.Component { ...@@ -170,7 +172,7 @@ class ComposeComment extends React.Component {
muteOpen: true muteOpen: true
}); });
} }
shouldShowMuteModal (muteStatus) { shouldShowMuteModal (muteStatus, justMuted) {
// We should show the mute modal if the user is in danger of being blocked or // We should show the mute modal if the user is in danger of being blocked or
// when the user is newly muted or hasn't seen it for a while. // when the user is newly muted or hasn't seen it for a while.
// We don't want to show it more than about once a week. // We don't want to show it more than about once a week.
...@@ -186,7 +188,7 @@ class ComposeComment extends React.Component { ...@@ -186,7 +188,7 @@ class ComposeComment extends React.Component {
// If the user is already muted (for example, in a different tab), // If the user is already muted (for example, in a different tab),
// do not show modal because it would be confusing // do not show modal because it would be confusing
if (this.state.status === ComposeStatus.COMPOSE_DISALLOWED) { if (!justMuted) {
return false; return false;
} }
...@@ -390,7 +392,7 @@ class ComposeComment extends React.Component { ...@@ -390,7 +392,7 @@ class ComposeComment extends React.Component {
muteModalMessages={this.getMuteMessageInfo()} muteModalMessages={this.getMuteMessageInfo()}
shouldCloseOnOverlayClick={false} shouldCloseOnOverlayClick={false}
showFeedback={ showFeedback={
this.state.status === ComposeStatus.REJECTED_MUTE && this.state.error === JUST_MUTED_ERROR this.state.status === ComposeStatus.REJECTED_MUTE
} }
showWarning={this.state.showWarning} showWarning={this.state.showWarning}
startStep={this.getMuteModalStartStep()} startStep={this.getMuteModalStartStep()}
......
...@@ -68,7 +68,10 @@ describe('Compose Comment test', () => { ...@@ -68,7 +68,10 @@ describe('Compose Comment test', () => {
test('Error messages shows when comment rejected ', () => { test('Error messages shows when comment rejected ', () => {
const component = getComposeCommentWrapper({}); const component = getComposeCommentWrapper({});
const commentInstance = component.instance(); const commentInstance = component.instance();
commentInstance.setState({error: 'isFlood'}); commentInstance.setState({
error: 'isFlood',
status: 'REJECTED'
});
component.update(); component.update();
expect(component.find('FlexRow.compose-error-row').exists()).toEqual(true); expect(component.find('FlexRow.compose-error-row').exists()).toEqual(true);
// Buttons stay enabled when comment rejected for non-mute reasons // Buttons stay enabled when comment rejected for non-mute reasons
...@@ -76,12 +79,12 @@ describe('Compose Comment test', () => { ...@@ -76,12 +79,12 @@ describe('Compose Comment test', () => {
expect(component.find('Button.compose-cancel').props().disabled).toBe(false); expect(component.find('Button.compose-cancel').props().disabled).toBe(false);
}); });
test('No error message shows when comment rejected because user muted ', () => { test('No error message shows when comment rejected because user is already muted ', () => {
const component = getComposeCommentWrapper({}); const component = getComposeCommentWrapper({});
const commentInstance = component.instance(); const commentInstance = component.instance();
commentInstance.setState({ commentInstance.setState({
error: 'isMuted', error: 'isMuted',
status: 'REJECTED_MUTE' status: 'COMPOSE_DISALLOWED'
}); });
component.update(); component.update();
expect(component.find('FlexRow.compose-error-row').exists()).toEqual(false); expect(component.find('FlexRow.compose-error-row').exists()).toEqual(false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment