Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
19b260a4
Commit
19b260a4
authored
Dec 15, 2020
by
picklesrus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a timeout to stop displaying the mute status when a mute expires.
parent
90ed44d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
src/views/preview/comment/compose-comment.jsx
src/views/preview/comment/compose-comment.jsx
+14
-2
test/unit/components/compose-comment.test.jsx
test/unit/components/compose-comment.test.jsx
+3
-0
No files found.
src/views/preview/comment/compose-comment.jsx
View file @
19b260a4
...
@@ -40,16 +40,27 @@ class ComposeComment extends React.Component {
...
@@ -40,16 +40,27 @@ class ComposeComment extends React.Component {
'
handleInput
'
,
'
handleInput
'
,
'
handleMuteClose
'
,
'
handleMuteClose
'
,
'
handleMuteOpen
'
,
'
handleMuteOpen
'
,
'
isMuted
'
'
isMuted
'
,
'
setupMuteExpirationTimeout
'
]);
]);
const
muteExpiresAtMs
=
this
.
props
.
muteStatus
.
muteExpiresAt
*
1000
;
// convert to ms
this
.
state
=
{
this
.
state
=
{
message
:
''
,
message
:
''
,
status
:
ComposeStatus
.
EDITING
,
status
:
ComposeStatus
.
EDITING
,
error
:
null
,
error
:
null
,
appealId
:
null
,
appealId
:
null
,
muteOpen
:
false
,
muteOpen
:
false
,
muteExpiresAtMs
:
this
.
props
.
muteStatus
.
muteExpiresAt
*
1000
// convert to m
s
muteExpiresAtMs
:
muteExpiresAtM
s
};
};
if
(
this
.
isMuted
())
{
this
.
setupMuteExpirationTimeout
(
muteExpiresAtMs
);
}
}
setupMuteExpirationTimeout
(
muteExpiresAtMs
)
{
// Change state when the mute expiration fires if the user is still on the page.
setTimeout
(()
=>
{
this
.
setState
({
muteExpiresAtMs
:
0
,
muteOpen
:
false
});
},
muteExpiresAtMs
-
Date
.
now
());
}
}
handleInput
(
event
)
{
handleInput
(
event
)
{
this
.
setState
({
this
.
setState
({
...
@@ -86,6 +97,7 @@ class ComposeComment extends React.Component {
...
@@ -86,6 +97,7 @@ class ComposeComment extends React.Component {
if
(
this
.
shouldShowMuteModal
(
body
.
status
.
mute_status
.
offenses
))
{
if
(
this
.
shouldShowMuteModal
(
body
.
status
.
mute_status
.
offenses
))
{
muteOpen
=
true
;
muteOpen
=
true
;
}
}
this
.
setupMuteExpirationTimeout
(
muteExpiresAtMs
);
}
}
// Note: does not reset the message state
// Note: does not reset the message state
this
.
setState
({
this
.
setState
({
...
...
test/unit/components/compose-comment.test.jsx
View file @
19b260a4
...
@@ -95,6 +95,7 @@ describe('Compose Comment test', () => {
...
@@ -95,6 +95,7 @@ describe('Compose Comment test', () => {
});
});
test
(
'
Comment Status initialized properly when muted
'
,
()
=>
{
test
(
'
Comment Status initialized properly when muted
'
,
()
=>
{
jest
.
useFakeTimers
();
const
realDateNow
=
Date
.
now
.
bind
(
global
.
Date
);
const
realDateNow
=
Date
.
now
.
bind
(
global
.
Date
);
global
.
Date
.
now
=
()
=>
0
;
global
.
Date
.
now
=
()
=>
0
;
const
mutedStore
=
mockStore
({
const
mutedStore
=
mockStore
({
...
@@ -114,6 +115,8 @@ describe('Compose Comment test', () => {
...
@@ -114,6 +115,8 @@ describe('Compose Comment test', () => {
const
commentInstance
=
component
.
instance
();
const
commentInstance
=
component
.
instance
();
// Check conversion to ms from seconds is done at init time.
// Check conversion to ms from seconds is done at init time.
expect
(
commentInstance
.
state
.
muteExpiresAtMs
).
toEqual
(
5
*
1000
);
expect
(
commentInstance
.
state
.
muteExpiresAtMs
).
toEqual
(
5
*
1000
);
// Check we setup a timeout to expire the widget when timeout reached.
expect
(
setTimeout
).
toHaveBeenLastCalledWith
(
expect
.
any
(
Function
),
5
*
1000
);
// Compose box should be hidden if muted unless they got muted due to a comment they just posted.
// 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
);
expect
(
component
.
find
(
'
FlexRow.compose-comment
'
).
exists
()).
toEqual
(
false
);
expect
(
component
.
find
(
'
MuteModal
'
).
exists
()).
toEqual
(
false
);
expect
(
component
.
find
(
'
MuteModal
'
).
exists
()).
toEqual
(
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment