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

Fix: Unread line #9149

Merged
merged 2 commits into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/rocketchat-theme/client/imports/general/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ button {
&::before {
position: absolute;
z-index: 1;
top: -10px;
top: 0;
left: 0;

width: 100%;
Expand All @@ -137,21 +137,24 @@ button {
&::after {
position: absolute;
z-index: 2;
top: -20px;
top: -6px;
right: 0;

padding: 0 1rem;
padding: 0 5px;
padding-bottom: 2px;

content: attr(data-unread-text);
text-align: right;
text-transform: uppercase;
text-transform: lowercase;

color: var(--rc-color-error);
background: #ffffff;

font-size: 10px;

pointer-events: none;
line-height: 10px;
border-radius: 2px;
}
}

Expand All @@ -166,7 +169,7 @@ button {
}

&::after {
top: -30px;
top: -26px;
}
}
}
12 changes: 6 additions & 6 deletions packages/rocketchat-theme/client/imports/general/base_old.css
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@

.rc-old .container-bars {
position: absolute;
z-index: 1;
z-index: 2;
top: 4px; /* --header-height */
right: 10px;
left: 10px;
Expand Down Expand Up @@ -2879,7 +2879,7 @@
}

&.new-day {
margin-top: 60px;
margin-top: 40px;

&::before {
position: absolute;
Expand All @@ -2897,6 +2897,8 @@

font-size: 12px;
font-weight: 600;

pointer-events: none;
}

&::after {
Expand All @@ -2911,6 +2913,8 @@
content: " ";

border-width: 1px 0 0;

pointer-events: none;
}
}

Expand Down Expand Up @@ -3096,10 +3100,6 @@

}

&.first-unread {
margin-top: 20px;
}

&.system .body {
font-style: italic;

Expand Down
11 changes: 6 additions & 5 deletions packages/rocketchat-ui/client/views/app/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ this.modal = {
errorEl.style.display = 'block';
},
onKeydown(e) {
e.preventDefault();
e.stopPropagation();

if (e.key === 'Enter') {
e.preventDefault();
e.stopPropagation();

modal.confirm(true);
}
} else if (e.key === 'Escape') {
e.preventDefault();
e.stopPropagation();

if (e.key === 'Escape') {
modal.close();
}
}
Expand Down
36 changes: 23 additions & 13 deletions packages/rocketchat-ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,26 +917,36 @@ Template.room.onRendered(function() {

const rtl = $('html').hasClass('rtl');

const updateUnreadCount = _.throttle(function() {
let lastInvisibleMessageOnScreen;
const getElementFromPoint = function(topOffset = 0) {
const messageBoxOffset = messageBox.offset();

let element;
if (rtl) {
lastInvisibleMessageOnScreen = document.elementFromPoint((messageBoxOffset.left + messageBox.width()) - 1, messageBoxOffset.top + 1);
element = document.elementFromPoint((messageBoxOffset.left + messageBox.width()) - 1, messageBoxOffset.top + topOffset + 1);
} else {
lastInvisibleMessageOnScreen = document.elementFromPoint(messageBoxOffset.left + 1, messageBoxOffset.top + 1);
element = document.elementFromPoint(messageBoxOffset.left + 1, messageBoxOffset.top + topOffset + 1);
}

if ((lastInvisibleMessageOnScreen != null ? lastInvisibleMessageOnScreen.id : undefined) != null) {
const lastMessage = ChatMessage.findOne(lastInvisibleMessageOnScreen.id);
if (lastMessage != null) {
const subscription = ChatSubscription.findOne({ rid: template.data._id });
const count = ChatMessage.find({ rid: template.data._id, ts: { $lte: lastMessage.ts, $gt: (subscription != null ? subscription.ls : undefined) } }).count();
template.unreadCount.set(count);
} else {
template.unreadCount.set(0);
}
if (element && element.classList.contains('message')) {
return element;
}
};

const updateUnreadCount = _.throttle(function() {
const lastInvisibleMessageOnScreen = getElementFromPoint(0) || getElementFromPoint(20) || getElementFromPoint(40);

if (lastInvisibleMessageOnScreen == null || lastInvisibleMessageOnScreen.id == null) {
return template.unreadCount.set(0);
}

const lastMessage = ChatMessage.findOne(lastInvisibleMessageOnScreen.id);
if (lastMessage == null) {
return template.unreadCount.set(0);
}

const subscription = ChatSubscription.findOne({ rid: template.data._id }, {reactive: false});
const count = ChatMessage.find({ rid: template.data._id, ts: { $lte: lastMessage.ts, $gt: subscription && subscription.ls } }).count();
template.unreadCount.set(count);
}, 300);

readMessage.onRead(function(rid) {
Expand Down