diff --git a/__tests__/RoomItem.js b/__tests__/RoomItem.js
index 7ee2c03a..62768234 100644
--- a/__tests__/RoomItem.js
+++ b/__tests__/RoomItem.js
@@ -6,30 +6,29 @@ import RoomItem from '../app/presentation/RoomItem';
import renderer from 'react-test-renderer';
const date = new Date(2017, 10, 10, 10);
-const dateFormat = 'MM-DD-YYYY HH:mm:ss';
jest.mock('react-native-img-cache', () => { return { CachedImage: 'View' } });
it('renders correctly', () => {
- expect(renderer.create().toJSON()).toMatchSnapshot();
+ expect(renderer.create().toJSON()).toMatchSnapshot();
});
it('render unread', () => {
- expect(renderer.create().toJSON()).toMatchSnapshot();
+ expect(renderer.create().toJSON()).toMatchSnapshot();
});
it('render unread +999', () => {
- expect(renderer.create().toJSON()).toMatchSnapshot();
+ expect(renderer.create().toJSON()).toMatchSnapshot();
});
it('render no icon', () => {
- expect(renderer.create().toJSON()).toMatchSnapshot();
+ expect(renderer.create().toJSON()).toMatchSnapshot();
});
it('render private group', () => {
- expect(renderer.create( ).toJSON()).toMatchSnapshot();
+ expect(renderer.create( ).toJSON()).toMatchSnapshot();
});
it('render channel', () => {
- expect(renderer.create().toJSON()).toMatchSnapshot();
+ expect(renderer.create().toJSON()).toMatchSnapshot();
});
diff --git a/__tests__/__snapshots__/RoomItem.js.snap b/__tests__/__snapshots__/RoomItem.js.snap
index f8904769..8f1df86e 100644
--- a/__tests__/__snapshots__/RoomItem.js.snap
+++ b/__tests__/__snapshots__/RoomItem.js.snap
@@ -115,7 +115,7 @@ exports[`render channel 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
@@ -194,7 +194,7 @@ exports[`render no icon 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
@@ -273,7 +273,7 @@ exports[`render private group 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
@@ -388,7 +388,7 @@ exports[`render unread +999 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap
index 2f91e862..7adb1e3f 100644
--- a/__tests__/__snapshots__/Storyshots.test.js.snap
+++ b/__tests__/__snapshots__/Storyshots.test.js.snap
@@ -281,7 +281,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
@@ -414,7 +414,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
@@ -545,7 +545,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
- 11-10-2017 10:00:00
+ Nov 10
@@ -1546,7 +1546,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
@@ -1658,7 +1658,7 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
}
>
- 11-10-2017 10:00:00
+ Nov 10
diff --git a/app/presentation/RoomItem.js b/app/presentation/RoomItem.js
index 3731dde1..a6bd3ce0 100644
--- a/app/presentation/RoomItem.js
+++ b/app/presentation/RoomItem.js
@@ -78,8 +78,7 @@ export default class RoomItem extends React.PureComponent {
unread: PropTypes.number,
userMentions: PropTypes.number,
baseUrl: PropTypes.string,
- onPress: PropTypes.func,
- dateFormat: PropTypes.string
+ onPress: PropTypes.func
}
get icon() {
@@ -110,6 +109,13 @@ export default class RoomItem extends React.PureComponent {
);
}
+ formatDate = date => moment(date).calendar(null, {
+ lastDay: 'dddd',
+ sameDay: 'HH:mm',
+ lastWeek: 'dddd',
+ sameElse: 'MMM D'
+ })
+
renderNumber = (unread, userMentions) => {
if (!unread || unread <= 0) {
return;
@@ -140,7 +146,7 @@ export default class RoomItem extends React.PureComponent {
{this.icon}
{ name }
- {_updatedAt ? { moment(_updatedAt).format(this.props.dateFormat) } : null}
+ {_updatedAt ? { this.formatDate(_updatedAt) } : null}
{this.renderNumber(unread, userMentions)}
diff --git a/app/views/RoomsListView.js b/app/views/RoomsListView.js
index ecf68643..7ae5eeb8 100644
--- a/app/views/RoomsListView.js
+++ b/app/views/RoomsListView.js
@@ -242,7 +242,6 @@ export default class RoomsListView extends React.Component {
key={item._id}
type={item.t}
baseUrl={this.props.Site_Url}
- dateFormat='MM-DD-YYYY HH:mm:ss'
onPress={() => this._onPressItem(item)}
/>
)
diff --git a/storybook/stories/Channels/DirectMessage.js b/storybook/stories/Channels/DirectMessage.js
index e9833ab4..14c19e94 100644
--- a/storybook/stories/Channels/DirectMessage.js
+++ b/storybook/stories/Channels/DirectMessage.js
@@ -4,7 +4,6 @@ import { ScrollView } from 'react-native';
import RoomItem from '../../../app/presentation/RoomItem';
const date = new Date(2017, 10, 10, 10);
-const dateFormat = 'MM-DD-YYYY HH:mm:ss';
export default (
@@ -12,7 +11,6 @@ export default (
type='d'
name='rocket.cat'
_updatedAt={date}
- dateFormat={dateFormat}
baseUrl='https://demo.rocket.chat'
/>
@@ -28,7 +25,6 @@ export default (
type='d'
unread={1}
_updatedAt={date}
- dateFormat={dateFormat}
name='rocket.cat'
baseUrl='https://demo.rocket.chat'
/>
@@ -37,7 +33,6 @@ export default (
unread={9}
alert
_updatedAt={date}
- dateFormat={dateFormat}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
@@ -45,7 +40,6 @@ export default (
type='d'
unread={99}
_updatedAt={date}
- dateFormat={dateFormat}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
@@ -54,7 +48,6 @@ export default (
unread={100}
userMentions={0}
_updatedAt={date}
- dateFormat={dateFormat}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
@@ -63,7 +56,6 @@ export default (
unread={100000}
userMentions={0}
_updatedAt={date}
- dateFormat={dateFormat}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
@@ -72,7 +64,6 @@ export default (
unread={100000}
userMentions={1}
_updatedAt={date}
- dateFormat={dateFormat}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
@@ -80,21 +71,18 @@ export default (
type='d'
name='W'
_updatedAt={date}
- dateFormat={dateFormat}
unread={-100}
/>