Skip to content

Commit 38575a6

Browse files
authored
Revert "Implement sticky date separators"
1 parent 7202556 commit 38575a6

3 files changed

Lines changed: 36 additions & 34 deletions

File tree

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"react-dnd-html5-backend": "^2.1.2",
7676
"react-dom": "^15.6.0",
7777
"react-gemini-scrollbar": "matrix-org/react-gemini-scrollbar#5e97aef",
78-
"react-sticky": "^6.0.1",
7978
"sanitize-html": "^1.11.1",
8079
"text-encoding-utf-8": "^1.0.1",
8180
"ua-parser-js": "^0.7.10",

‎src/components/views/messages/DateSeparator.js‎

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,45 @@ limitations under the License.
1515
*/
1616

1717
import React from 'react';
18+
import { _t } from 'matrix-react-sdk/lib/languageHandler';
1819
import DateUtils from 'matrix-react-sdk/lib/DateUtils';
19-
import { Sticky } from 'react-sticky';
20+
21+
function getdaysArray() {
22+
return [
23+
_t('Sunday'),
24+
_t('Monday'),
25+
_t('Tuesday'),
26+
_t('Wednesday'),
27+
_t('Thursday'),
28+
_t('Friday'),
29+
_t('Saturday'),
30+
];
31+
}
2032

2133
module.exports = React.createClass({
2234
displayName: 'DateSeparator',
2335
render: function() {
24-
const date = new Date(this.props.ts);
25-
const label = DateUtils.formatDateSeparator(date);
36+
var date = new Date(this.props.ts);
37+
var today = new Date();
38+
var yesterday = new Date();
39+
var days = getdaysArray();
40+
yesterday.setDate(today.getDate() - 1);
41+
var label;
42+
if (date.toDateString() === today.toDateString()) {
43+
label = _t('Today');
44+
}
45+
else if (date.toDateString() === yesterday.toDateString()) {
46+
label = _t('Yesterday');
47+
}
48+
else if (today.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
49+
label = days[date.getDay()];
50+
}
51+
else {
52+
label = DateUtils.formatFullDate(date, this.props.showTwelveHour);
53+
}
54+
2655
return (
27-
<Sticky relative={true} disableCompensation={true}>
28-
{({style, isSticky, wasSticky, distanceFromTop}) => {
29-
return (
30-
<div className={"mx_DateSeparator_container mx_DateSeparator_container" + (isSticky ? '_sticky' : '')}
31-
style={{top: isSticky ? -distanceFromTop + "px" : 0}}
32-
>
33-
<h2 className="mx_DateSeparator">{ label }</h2>
34-
</div>
35-
);
36-
}}
37-
</Sticky>
56+
<h2 className="mx_DateSeparator">{ label }</h2>
3857
);
39-
},
58+
}
4059
});

‎src/skins/vector/css/vector-web/views/messages/_DateSeparator.scss‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,10 @@ limitations under the License.
1616

1717
.mx_DateSeparator {
1818
clear: both;
19-
margin-top: 0px;
20-
margin-bottom: 0px;
19+
margin-top: 32px;
20+
margin-bottom: 8px;
2121
margin-left: 63px;
22-
padding-top: 5px;
2322
padding-bottom: 6px;
2423
border-bottom: 1px solid $primary-hairline-color;
2524
}
2625

27-
.mx_DateSeparator_container {
28-
margin-top: 27px;
29-
margin-bottom: 8px;
30-
background-color: $primary-bg-color;
31-
z-index: 3;
32-
}
33-
34-
.mx_DateSeparator_container_sticky {
35-
position: relative;
36-
border-bottom: 1px solid $primary-hairline-color;
37-
}
38-
39-
.mx_DateSeparator_container_sticky .mx_DateSeparator {
40-
border: 0px;
41-
}

0 commit comments

Comments
 (0)