Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
Removed the unread message counter from the sidebar, only highlights …
Browse files Browse the repository at this point in the history
…/ privmsgs are displayed. Unread info now changes the style on the link so it's noticable. Closes #20
  • Loading branch information
rickihastings committed Mar 4, 2014
1 parent 5850c1c commit 19e9940
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
15 changes: 11 additions & 4 deletions client/js/controllers/messages.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ App.MessagesController = Ember.ArrayController.extend({
var self = this,
tab = this.get('socket.tabs').findBy('_id', id),
events = this.get('content').filterProperty('unread', true),
counter = 0;
highlightCounter = 0,
counter = 0,
docs = [];

if (!tab) {
Expand All @@ -145,12 +146,14 @@ App.MessagesController = Ember.ArrayController.extend({
var topOffset = el[0].offsetTop;

if ((top === 0 || top < topOffset && topOffset < bottom) && App.get('isActive')) {
// XXX - Handle highlights

item.set('unread', false);
if (self.readDocs.indexOf(item._id) === -1) {
self.readDocs.push(item._id);
counter++;

if (item.extra.highlight) {
highlightCounter++;
}
}
}
}
Expand All @@ -159,7 +162,11 @@ App.MessagesController = Ember.ArrayController.extend({
var unread = tab.get('unread') - counter;
unread = (unread <= 0) ? 0 : unread;
tab.set('unread', unread);
// update the icon

var highlights = tab.get('highlights') - highlightCounter;
highlights = (highlights <= 0) ? 0 : highlights;
tab.set('highlights', highlights);
// update the icon(s)

if (this.get('timeout')) {
return false;
Expand Down
12 changes: 10 additions & 2 deletions client/js/views/sidebaritem.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ App.SidebaritemView = Ember.View.extend({
tab.set('selected', false);
}

if (tab.type !== 'network') {
if (tab.get('type') !== 'network') {
classes.push('child');
}

if (tab.get('unread') > 0) {
classes.push('unread');
}

return classes.join(' ');
}.property('controller.parentController.user.selectedTab').cacheable(),
}.property('controller.parentController.user.selectedTab', 'controller.content.selected', 'controller.content.unread').cacheable(),

getClass: function() {
var classNames = [''],
Expand All @@ -40,6 +44,10 @@ App.SidebaritemView = Ember.View.extend({
return classNames.join(' ');
}.property('controller.content').cacheable(),

isPrivmsg: function() {
return (this.get('controller.content.type') === 'query');
}.property('controller.content.type').cacheable(),

url: function() {
var split = this.get('controller.content.url').split('/');

Expand Down
11 changes: 10 additions & 1 deletion client/less/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,16 @@ div.sidebar {
}
}

.child:not(.selected) {
.unread {
width: 210px;
z-index: 7000;

a {
border-left: 5px solid #225FA3;
}
}

.child:not(.selected,.unread) {
span.link {
padding-left: 6px;
}
Expand Down
9 changes: 7 additions & 2 deletions client/templates/sidebaritem.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<a {{bind-attr href=view.url title=title}}>
<span {{bind-attr class=":link view.getClass"}}>
{{#if highlights}}<span class="alert highlight" {{action "markAsRead" _id bubbles=false}}>{{highlights}}</span>{{/if}}
{{#if unread}}<span class="alert unread" {{action "markAsRead" _id bubbles=false}}>{{unread}}</span>{{/if}}
{{#if view.isPrivmsg}}
{{#if unread}}
<span class="alert highlight" {{action "markAsRead" _id bubbles=false}}>{{unread}}</span>
{{/if}}
{{else}}
{{#if highlights}}<span class="alert highlight" {{action "markAsRead" _id bubbles=false}}>{{highlights}}</span>{{/if}}
{{/if}}
{{view.title}}
</span>
</a>

0 comments on commit 19e9940

Please sign in to comment.