Add "Mentioning messages" to the upper left sidebar.

Treat "mentioned" messages like "starred" messages for narrowing.

Lots of ugly copy/paste here.  There might be opportunity for
some cleanup in places.

(imported from commit e7629890d42643c0000e1cc85422b2a0690f2cc4)
This commit is contained in:
Steve Howell
2013-05-28 18:33:03 -04:00
parent 1004178fe1
commit 3f1b3af002
8 changed files with 19 additions and 1 deletions

View File

@@ -80,6 +80,9 @@
<div id="empty_star_narrow_message" class="empty_feed_notice"> <div id="empty_star_narrow_message" class="empty_feed_notice">
<h4>You haven't starred anything yet!</h4> <h4>You haven't starred anything yet!</h4>
</div> </div>
<div id="empty_narrow_all_mentioned" class="empty_feed_notice">
<h4>You haven't been mentioned yet.</h4>
</div>
<div id="empty_search_narrow_message" class="empty_feed_notice"> <div id="empty_search_narrow_message" class="empty_feed_notice">
<h4>Nobody has talked about that yet!</h4> <h4>Nobody has talked about that yet!</h4>
</div> </div>

View File

@@ -18,6 +18,7 @@
<li data-name="all" class="hidden-filter"><i class="icon-vector-list"></i> <a href="#narrow/in/all">All messages <span class="count">(<span class="value"></span>)</span></a></li> <li data-name="all" class="hidden-filter"><i class="icon-vector-list"></i> <a href="#narrow/in/all">All messages <span class="count">(<span class="value"></span>)</span></a></li>
<li data-name="private-message"><i class="icon-vector-user"></i> <a href="#narrow/is/private-message">Private messages <span class="count">(<span class="value"></span>)</span></a></li> <li data-name="private-message"><i class="icon-vector-user"></i> <a href="#narrow/is/private-message">Private messages <span class="count">(<span class="value"></span>)</span></a></li>
<li data-name="starred"><i class="icon-vector-star"></i> <a href="#narrow/is/starred">Starred messages</a></li> <li data-name="starred"><i class="icon-vector-star"></i> <a href="#narrow/is/starred">Starred messages</a></li>
<li data-name="mentioned"><i class="icon-vector-tag"></i> <a href="#narrow/is/mentioned">Mentioning messages</a></li>
</ul> </ul>
<ul id="stream_filters" class="filters scrolling_list"></ul> <ul id="stream_filters" class="filters scrolling_list"></ul>
</div> </div>

View File

@@ -95,6 +95,10 @@ Filter.prototype = {
if (!message.starred) { if (!message.starred) {
return false; return false;
} }
} else if (operand === 'mentioned') {
if (!message.mentioned) {
return false;
}
} }
break; break;
@@ -224,6 +228,8 @@ exports.describe = function (operators) {
return 'Narrow to all private messages'; return 'Narrow to all private messages';
} else if (operand === 'starred') { } else if (operand === 'starred') {
return 'Narrow to starred messages'; return 'Narrow to starred messages';
} else if (operand === 'mentioned') {
return 'Narrow to mentioned messages';
} }
break; break;
@@ -564,6 +570,8 @@ function pick_empty_narrow_banner() {
if (first_operand === "starred") { if (first_operand === "starred") {
// You have no starred messages. // You have no starred messages.
return $("#empty_star_narrow_message"); return $("#empty_star_narrow_message");
} else if (first_operand === "mentioned") {
return $("#empty_narrow_all_mentioned");
} else if (first_operand === "private-message") { } else if (first_operand === "private-message") {
// You have no private messages. // You have no private messages.
return $("#empty_narrow_all_private_message"); return $("#empty_narrow_all_private_message");

View File

@@ -260,7 +260,7 @@ $(function () {
} }
var op_is = event.filter.operands('is'); var op_is = event.filter.operands('is');
if (op_is.length !== 0) { if (op_is.length !== 0) {
if (['private-message', 'starred'].indexOf(op_is[0]) !== -1) { if (['private-message', 'starred', 'mentioned'].indexOf(op_is[0]) !== -1) {
$("#global_filters li[data-name='" + op_is[0] + "']").addClass('active-filter'); $("#global_filters li[data-name='" + op_is[0] + "']").addClass('active-filter');
} }
} }

View File

@@ -55,6 +55,8 @@ function make_tab_data() {
} else if (operator === 'is' && operand === 'starred') { } else if (operator === 'is' && operand === 'starred') {
tabs.push(make_tab("Starred", hashed)); tabs.push(make_tab("Starred", hashed));
} else if (operator === 'is' && operand === 'mentioned') {
tabs.push(make_tab("Mentions", hashed));
} else if (operator === 'sender') { } else if (operator === 'sender') {
var sender = people_dict[operand].full_name; var sender = people_dict[operand].full_name;
tabs.push(make_tab("Sent by " + sender, hashed)); tabs.push(make_tab("Sent by " + sender, hashed));

View File

@@ -515,6 +515,7 @@ function add_message_metadata(message, dummy) {
message.historical = (message.flags !== undefined && message.historical = (message.flags !== undefined &&
message.flags.indexOf('historical') !== -1); message.flags.indexOf('historical') !== -1);
message.starred = message.flags.indexOf("starred") !== -1; message.starred = message.flags.indexOf("starred") !== -1;
message.mentioned = message.flags.indexOf("mentioned") !== -1;
message.collapsed = message.flags.indexOf("collapsed") !== -1; message.collapsed = message.flags.indexOf("collapsed") !== -1;
switch (message.type) { switch (message.type) {

View File

@@ -471,3 +471,4 @@ ul.icons li [class*=" icon-vector-"] {
.icon-vector-pencil:before { content: "\f040"; } .icon-vector-pencil:before { content: "\f040"; }
.icon-vector-eraser:before { content: "\f12d"; } .icon-vector-eraser:before { content: "\f12d"; }
.icon-vector-envelope:before { content: "\f003"; } .icon-vector-envelope:before { content: "\f003"; }
.icon-vector-tag:before { content: "\f02b"; }

View File

@@ -667,6 +667,8 @@ class NarrowBuilder(object):
self.pQ(recipient__type=Recipient.HUDDLE)) self.pQ(recipient__type=Recipient.HUDDLE))
elif operand == 'starred': elif operand == 'starred':
return Q(flags=UserMessage.flags.starred) return Q(flags=UserMessage.flags.starred)
elif operand == 'mentioned':
return Q(flags=UserMessage.flags.mentioned)
raise BadNarrowOperator("unknown 'is' operand " + operand) raise BadNarrowOperator("unknown 'is' operand " + operand)
def by_stream(self, operand): def by_stream(self, operand):