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
c9eacf4a
Commit
c9eacf4a
authored
Sep 19, 2017
by
Matthew Taylor
Committed by
GitHub
Sep 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1559 from mewtaylor/issue/gh-1545
Fix GH-1545: add `unread` as a key/value on each message
parents
129042fc
a9cb7bbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
src/views/messages/container.jsx
src/views/messages/container.jsx
+21
-8
src/views/messages/presentation.jsx
src/views/messages/presentation.jsx
+5
-9
No files found.
src/views/messages/container.jsx
View file @
c9eacf4a
...
@@ -116,11 +116,23 @@ var Messages = React.createClass({
...
@@ -116,11 +116,23 @@ var Messages = React.createClass({
)
)
);
);
},
},
filterMessages
:
function
(
messages
,
typesAllowed
)
{
filterMessages
:
function
(
messages
,
typesAllowed
,
unreadCount
)
{
var
filteredMessages
=
[];
var
filteredMessages
=
[];
for
(
var
i
in
messages
)
{
if
(
typesAllowed
.
length
>
0
)
{
if
(
typesAllowed
.
indexOf
(
messages
[
i
].
type
)
>
-
1
)
{
for
(
var
i
in
messages
)
{
filteredMessages
.
push
(
messages
[
i
]);
// check to see if the position of the message in the list is earlier
// than the unread count. If it is, then the message is totally unread.
messages
[
i
].
unread
=
false
;
if
(
i
<
unreadCount
)
messages
[
i
].
unread
=
true
;
if
(
typesAllowed
.
indexOf
(
messages
[
i
].
type
)
>
-
1
)
{
filteredMessages
.
push
(
messages
[
i
]);
}
}
}
else
{
filteredMessages
=
messages
;
for
(
var
j
=
0
;
j
<
unreadCount
;
j
++
)
{
filteredMessages
[
j
].
unread
=
true
;
}
}
}
}
return
filteredMessages
;
return
filteredMessages
;
...
@@ -131,10 +143,11 @@ var Messages = React.createClass({
...
@@ -131,10 +143,11 @@ var Messages = React.createClass({
loadMore
=
false
;
loadMore
=
false
;
}
}
var
messages
=
this
.
props
.
messages
;
var
messages
=
this
.
filterMessages
(
if
(
this
.
state
.
filterValues
.
length
>
0
)
{
this
.
props
.
messages
,
messages
=
this
.
filterMessages
(
messages
,
this
.
state
.
filterValues
);
this
.
state
.
filterValues
,
}
this
.
props
.
numNewMessages
);
return
(
return
(
<
MessagesPresentation
<
MessagesPresentation
...
...
src/views/messages/presentation.jsx
View file @
c9eacf4a
...
@@ -42,8 +42,8 @@ var SocialMessagesList = React.createClass({
...
@@ -42,8 +42,8 @@ var SocialMessagesList = React.createClass({
numNewMessages
:
0
numNewMessages
:
0
};
};
},
},
getComponentForMessage
:
function
(
message
,
unread
)
{
getComponentForMessage
:
function
(
message
)
{
var
className
=
(
unread
)
?
'
mod-unread
'
:
''
;
var
className
=
(
message
.
unread
===
true
)
?
'
mod-unread
'
:
''
;
var
key
=
message
.
type
+
'
_
'
+
message
.
id
;
var
key
=
message
.
type
+
'
_
'
+
message
.
id
;
switch
(
message
.
type
)
{
switch
(
message
.
type
)
{
...
@@ -140,14 +140,10 @@ var SocialMessagesList = React.createClass({
...
@@ -140,14 +140,10 @@ var SocialMessagesList = React.createClass({
/>;
/>;
}
}
},
},
renderSocialMessages
:
function
(
messages
,
unreadCount
)
{
renderSocialMessages
:
function
(
messages
)
{
var
messageList
=
[];
var
messageList
=
[];
for
(
var
i
in
messages
)
{
for
(
var
i
in
messages
)
{
if
(
i
<=
unreadCount
)
{
messageList
.
push
(
this
.
getComponentForMessage
(
messages
[
i
]));
messageList
.
push
(
this
.
getComponentForMessage
(
messages
[
i
],
true
));
}
else
{
messageList
.
push
(
this
.
getComponentForMessage
(
messages
[
i
],
false
));
}
}
}
return
messageList
;
return
messageList
;
},
},
...
@@ -195,7 +191,7 @@ var SocialMessagesList = React.createClass({
...
@@ -195,7 +191,7 @@ var SocialMessagesList = React.createClass({
</
h4
>
</
h4
>
</
div
>,
</
div
>,
<
ul
className=
"messages-social-list"
key=
"messages-social-list"
>
<
ul
className=
"messages-social-list"
key=
"messages-social-list"
>
{
this
.
renderSocialMessages
(
this
.
props
.
messages
,
(
this
.
props
.
numNewMessages
-
1
)
)
}
{
this
.
renderSocialMessages
(
this
.
props
.
messages
)
}
</
ul
>,
</
ul
>,
this
.
renderLoadMore
(
this
.
props
.
loadMore
)
this
.
renderLoadMore
(
this
.
props
.
loadMore
)
]
:
[]
}
]
:
[]
}
...
...
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