Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Save room's last message #8979

Merged
merged 11 commits into from
Dec 4, 2017
Prev Previous commit
Next Next commit
sidebar layout to show last message
  • Loading branch information
karlprieb committed Nov 27, 2017
commit 8f2ca277ac2518a7c2fd7c45b96c39a768596635
30 changes: 15 additions & 15 deletions packages/rocketchat-google-vision/.npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/rocketchat-theme/client/imports/components/badge.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@

&--unread {
background-color: var(--badge-unread-background);
white-space: nowrap;
margin-top: 10px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
margin-top: 2rem;
}

&__list {
& .badge {
margin: 0 4px;
}

&:not(:last-child) {
margin-bottom: 32px;
}
&__list:not(:last-child) {
margin-bottom: 32px;
}

&__type {
Expand Down Expand Up @@ -60,6 +54,10 @@
width: 100%;

background-color: var(--sidebar-background);

& .sidebar-item__info, & .sidebar-item__last-message {
display: none;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
}
}

.sidebar--big > .rooms-list .sidebar-item {
height: var(--sidebar-item-big-height);

&__picture {
flex: 0 0 var(--sidebar-item-big-thumb-size);
}

&__icon {
width: var(--sidebar-item-big-thumb-size);
height: var(--sidebar-item-big-thumb-size);
}
}

.sidebar-item {
position: relative;

Expand Down Expand Up @@ -113,36 +126,61 @@
&__body {
display: flex;
flex: 1;
flex-direction: column;
flex-direction: row;
align-items: center;

margin: 0 4px;

overflow: hidden;
}

&__message {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}

&__name {
overflow: hidden;

white-space: nowrap;
text-overflow: ellipsis;

font-size: var(--sidebar-item-text-size);

margin-bottom: 8px;
line-height: 1.2rem;
}

&__last-message {
flex: 1;
font-size: 10pt;
color: rgba(255,255,255,0.4);
font-size: 12px;
line-height: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

&__info {
flex: 0;
align-self: flex-start;
margin-top: 4px;
}

&__time {
display: flex;
justify-content: flex-end;
font-size: 10px;
color: var(--sidebar-item-text-color);
}

&__menu {
padding: 6px;
position: absolute;
right: 0;
display: none;
flex: 0;

&-icon {
fill: var(--color-white);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@
* Sidebar Item
*/
--sidebar-item-radius: 2px;
--sidebar-item-height: 55px;
--sidebar-item-height: 32px;
--sidebar-item-big-height: 62px;
--sidebar-item-thumb-size: 20px;
--sidebar-item-big-thumb-size: 36px;

--sidebar-item-text-color: var(--color-gray);
--sidebar-item-background: inherit;
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui-sidenav/client/chatRoomItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Template.chatRoomItem.helpers({

if (RocketChat.settings.get('Store_Last_Message')) {
const room = RocketChat.models.Rooms.findOne(this.rid, { fields: { lastMessage: 1 } });

roomData.lastMessage = room.lastMessage;
console.log(this.rid, room);
roomData.lastMessage = room.lastMessage ? room.lastMessage : false;
}

return roomData;
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui-sidenav/client/sideNav.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="sideNav">
<aside class="sidebar" role="navigation">
<aside class="sidebar {{#if isLastMessageActive}}sidebar--big{{/if}}" role="navigation">
<header class="sidebar__header">
{{> accountBox }}
{{> toolbar}}
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-ui-sidenav/client/sideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Template.sideNav.helpers({

loggedInUser() {
return !!Meteor.userId();
},

isLastMessageActive() {
return RocketChat.settings.get('Store_Last_Message');
}
});

Expand Down
34 changes: 24 additions & 10 deletions packages/rocketchat-ui-sidenav/client/sidebarItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,32 @@
{{/if}}
{{/if}}
<div class="sidebar-item__body">
<div class="sidebar-item__name {{archivedClass}}">{{name}}</div>
<div class="sidebar-item__last-message">{{lastMessage}}</div>
</div>
<div class="sidebar-item__message">
<div class="sidebar-item__name {{archivedClass}}">{{name}}</div>
{{#if lastMessage}}
<div class="sidebar-item__last-message">{{lastMessage.u.username}}: {{lastMessage.msg}}</div>
{{else}}
<div class="sidebar-item__last-message">No last message</div>
{{/if}}
</div>

{{#if unread}}
<span class="badge badge--unread">{{#if userMentions}}@ {{/if}}{{unread}}</span>
{{/if}}
{{#if isRoom}}
<div class="sidebar-item__menu">
{{> icon block="sidebar-item__menu-icon" icon="menu"}}
<div class="sidebar-item__info">
{{#if lastMessage}}
<span class="sidebar-item__time">
3h
</span>
{{/if}}
{{#if unread}}
<span class="badge badge--unread">{{#if userMentions}}@ {{/if}}{{unread}}</span>
{{/if}}
</div>
{{/if}}

{{#if isRoom}}
<div class="sidebar-item__menu">
{{> icon block="sidebar-item__menu-icon" icon="menu"}}
</div>
{{/if}}
</div>
</a>
</li>
</template>
6 changes: 5 additions & 1 deletion packages/rocketchat-ui-sidenav/client/sidebarItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* globals menu popover */
import moment from 'moment';

Template.sidebarItem.helpers({
or(...args) {
args.pop();
Expand All @@ -9,8 +11,10 @@ Template.sidebarItem.helpers({
},
lastMessage() {
if (this.lastMessage) {
return `${ this.lastMessage.u.username }: ${ this.lastMessage.msg }`;
return this.lastMessage;
}

return false;
}
});

Expand Down