Skip to content

Commit 1a95148

Browse files
committed
basic date separator support
1 parent a2ca5f2 commit 1a95148

6 files changed

Lines changed: 34 additions & 11 deletions

File tree

skins/base/css/common.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ div.error {
2828
}
2929

3030
h2 {
31+
color: #80cef4;
3132
font-weight: 400;
3233
font-size: 20px;
3334
margin-top: 16px;

skins/base/css/organisms/LeftPanel.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ limitations under the License.
4444
padding-left: 16px;
4545
padding-right: 16px;
4646

47-
/* background-color: #0ff; */
4847
height: 100%;
4948
overflow-y: scroll;
5049
}

skins/base/css/organisms/RoomView.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ limitations under the License.
6464
width: 100%;
6565
height: 100%;
6666
margin-bottom: 60px;
67-
/* background-color: #ff0; */
6867

6968
overflow-y: scroll;
7069
}
@@ -78,6 +77,14 @@ limitations under the License.
7877
width: 100%;
7978
}
8079

80+
.mx_RoomView_MessageList h2 {
81+
clear: both;
82+
margin-top: 32px;
83+
margin-bottom: 8px;
84+
padding-bottom: 6px;
85+
border-bottom: 1px solid #a8dbf3;
86+
}
87+
8188
.mx_RoomView_invitePrompt {
8289
}
8390

skins/base/views/molecules/MRoomMemberTile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ module.exports = React.createClass({
4545

4646
render: function() {
4747
// XXX: for now, just cheekily borrow the css from message tile...
48+
var timestamp = this.props.last ? <MessageTimestamp ts={this.props.mxEvent.getTs()} /> : null;
49+
4850
return (
4951
<div className="mx_MessageTile">
5052
<div className="mx_MessageTile_avatar">
5153
<img src={ this.props.mxEvent.target ? MatrixClientPeg.get().getAvatarUrlForMember(this.props.mxEvent.target, 40, 40, "crop") : null } width="40" height="40"/>
5254
</div>
53-
<MessageTimestamp ts={this.props.mxEvent.getTs()} />
55+
{ timestamp }
5456
<span className="mx_SenderProfile"></span>
5557
<span className="mx_MessageTile_content">
5658
{this.getMemberEventText()}

src/ComponentBroker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ require('../skins/base/views/organisms/RightPanel');
9898
require('../skins/base/views/molecules/RoomCreate');
9999
require('../skins/base/views/molecules/RoomDropTarget');
100100
require('../skins/base/views/molecules/DirectoryMenu');
101+
require('../skins/base/views/molecules/DateSeparator');
101102
require('../skins/base/views/atoms/voip/VideoFeed');
102103
require('../skins/base/views/molecules/voip/VideoView');
103104
require('../skins/base/views/molecules/voip/CallView');

src/controllers/organisms/RoomView.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ var tileTypes = {
3636
'm.call.hangup': ComponentBroker.get('molecules/voip/MCallHangupTile')
3737
};
3838

39+
var DateSeparator = ComponentBroker.get('molecules/DateSeparator');
40+
3941
module.exports = {
4042
getInitialState: function() {
4143
return {
@@ -231,22 +233,33 @@ module.exports = {
231233
var TileType = tileTypes[mxEv.getType()];
232234
var continuation = false;
233235
var last = false;
236+
var dateSeparator = null;
234237
if (i == this.state.room.timeline.length - 1) {
235238
last = true;
236239
}
237-
if (i > 0 &&
238-
count < this.state.messageCap - 1 &&
239-
this.state.room.timeline[i].sender &&
240-
this.state.room.timeline[i - 1].sender &&
241-
this.state.room.timeline[i].sender.userId ===
240+
if (i > 0 && count < this.state.messageCap - 1) {
241+
if (this.state.room.timeline[i].sender &&
242+
this.state.room.timeline[i - 1].sender &&
243+
this.state.room.timeline[i].sender.userId ===
242244
this.state.room.timeline[i - 1].sender.userId)
243-
{
244-
continuation = true;
245-
}
245+
{
246+
continuation = true;
247+
}
248+
249+
var ts0 = this.state.room.timeline[i - 1].getTs();
250+
var ts1 = this.state.room.timeline[i].getTs();
251+
if (new Date(ts0).toDateString() !== new Date(ts1).toDateString()) {
252+
dateSeparator = <DateSeparator key={ts1} ts={ts1}/>;
253+
continuation = false;
254+
}
255+
}
246256
if (!TileType) continue;
247257
ret.unshift(
248258
<TileType key={mxEv.getId()} mxEvent={mxEv} continuation={continuation} last={last}/>
249259
);
260+
if (dateSeparator) {
261+
ret.unshift(dateSeparator);
262+
}
250263
++count;
251264
}
252265
return ret;

0 commit comments

Comments
 (0)