Commit 23da1e27 authored by seotts's avatar seotts

Continued work

parent cf71b776
......@@ -97,18 +97,20 @@ class ComposeComment extends React.Component {
let muteOpen = false;
let muteExpiresAtMs = 0;
let rejectedStatus = ComposeStatus.REJECTED;
let justMuted = true;
let showWarning = false;
let muteType = null;
if (body.status && body.status.mute_status) {
muteExpiresAtMs = body.status.mute_status.muteExpiresAt * 1000; // convert to ms
if (body.rejected === 'isBad') {
if (body.rejected === JUST_MUTED_ERROR) {
rejectedStatus = ComposeStatus.REJECTED_MUTE;
} else {
rejectedStatus = ComposeStatus.COMPOSE_DISALLOWED;
justMuted = false;
}
if (this.shouldShowMuteModal(body.status.mute_status)) {
if (this.shouldShowMuteModal(body.status.mute_status, justMuted)) {
muteOpen = true;
}
......@@ -170,7 +172,7 @@ class ComposeComment extends React.Component {
muteOpen: true
});
}
shouldShowMuteModal (muteStatus) {
shouldShowMuteModal (muteStatus, justMuted) {
// 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.
// We don't want to show it more than about once a week.
......@@ -186,7 +188,7 @@ class ComposeComment extends React.Component {
// If the user is already muted (for example, in a different tab),
// do not show modal because it would be confusing
if (this.state.status === ComposeStatus.COMPOSE_DISALLOWED) {
if (!justMuted) {
return false;
}
......@@ -390,7 +392,7 @@ class ComposeComment extends React.Component {
muteModalMessages={this.getMuteMessageInfo()}
shouldCloseOnOverlayClick={false}
showFeedback={
this.state.status === ComposeStatus.REJECTED_MUTE && this.state.error === JUST_MUTED_ERROR
this.state.status === ComposeStatus.REJECTED_MUTE
}
showWarning={this.state.showWarning}
startStep={this.getMuteModalStartStep()}
......
......@@ -68,7 +68,10 @@ describe('Compose Comment test', () => {
test('Error messages shows when comment rejected ', () => {
const component = getComposeCommentWrapper({});
const commentInstance = component.instance();
commentInstance.setState({error: 'isFlood'});
commentInstance.setState({
error: 'isFlood',
status: 'REJECTED'
});
component.update();
expect(component.find('FlexRow.compose-error-row').exists()).toEqual(true);
// Buttons stay enabled when comment rejected for non-mute reasons
......@@ -76,12 +79,12 @@ describe('Compose Comment test', () => {
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 commentInstance = component.instance();
commentInstance.setState({
error: 'isMuted',
status: 'REJECTED_MUTE'
status: 'COMPOSE_DISALLOWED'
});
component.update();
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