mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Fix time travel by adding new near: operator.
(imported from commit 727a68016090164b586cbe59e692676a00e8cd3a)
This commit is contained in:
		@@ -119,6 +119,9 @@ Filter.prototype = {
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case 'near':
 | 
			
		||||
                    return true;
 | 
			
		||||
 | 
			
		||||
                case 'stream':
 | 
			
		||||
                    if (message.type !== 'stream')
 | 
			
		||||
                        return false;
 | 
			
		||||
@@ -333,6 +336,7 @@ exports.activate = function (operators, opts) {
 | 
			
		||||
    if (operators.length === 0) {
 | 
			
		||||
        return exports.deactivate();
 | 
			
		||||
    }
 | 
			
		||||
    var filter = new Filter(operators);
 | 
			
		||||
 | 
			
		||||
    opts = _.defaults({}, opts, {
 | 
			
		||||
        then_select_id: home_msg_list.selected_id(),
 | 
			
		||||
@@ -340,6 +344,10 @@ exports.activate = function (operators, opts) {
 | 
			
		||||
        change_hash: true,
 | 
			
		||||
        trigger: 'unknown'
 | 
			
		||||
    });
 | 
			
		||||
    if (filter.has_operator("near")) {
 | 
			
		||||
        opts.then_select_id = filter.operands("near")[0];
 | 
			
		||||
        opts.select_first_unread = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (opts.then_select_id === -1) {
 | 
			
		||||
        // If we're loading the page via a narrowed URL, we may not
 | 
			
		||||
@@ -366,7 +374,7 @@ exports.activate = function (operators, opts) {
 | 
			
		||||
        message_tour.start_tour(current_msg_list.selected_id());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    current_filter = new Filter(operators);
 | 
			
		||||
    current_filter = filter;
 | 
			
		||||
 | 
			
		||||
    // Save how far from the pointer the top of the message list was.
 | 
			
		||||
    if (current_msg_list.selected_id() !== -1) {
 | 
			
		||||
@@ -504,7 +512,7 @@ exports.by_recipient = function (target_id, opts) {
 | 
			
		||||
 | 
			
		||||
exports.by_time_travel = function (target_id, opts) {
 | 
			
		||||
    opts = _.defaults({}, opts, {then_select_id: target_id});
 | 
			
		||||
    narrow.activate([], opts);
 | 
			
		||||
    narrow.activate([["near", target_id]], opts);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.deactivate = function () {
 | 
			
		||||
 
 | 
			
		||||
@@ -68,6 +68,9 @@ function describe(operators) {
 | 
			
		||||
        case 'stream':
 | 
			
		||||
            return 'Narrow to stream ' + operand;
 | 
			
		||||
 | 
			
		||||
        case 'near':
 | 
			
		||||
            return 'Narrow to messages around ' + operand;
 | 
			
		||||
 | 
			
		||||
        case 'topic':
 | 
			
		||||
            return 'Narrow to topic ' + operand;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,8 @@ function make_tab_data() {
 | 
			
		||||
 | 
			
		||||
        } else if (filter.has_operand("is", "starred")) {
 | 
			
		||||
            tabs.push(make_tab("Starred", hashed));
 | 
			
		||||
        } else if (filter.has_operator("near")) {
 | 
			
		||||
            tabs.push(make_tab("Near " + filter.operands("near")[0], hashed));
 | 
			
		||||
        } else if (filter.has_operand("is", "mentioned")) {
 | 
			
		||||
            tabs.push(make_tab("Mentions", hashed));
 | 
			
		||||
        } else if (filter.has_operator("sender")) {
 | 
			
		||||
 
 | 
			
		||||
@@ -713,6 +713,9 @@ class NarrowBuilder(object):
 | 
			
		||||
    def by_sender(self, operand):
 | 
			
		||||
        return self.pQ(sender__email__iexact=operand)
 | 
			
		||||
 | 
			
		||||
    def by_near(self, operand):
 | 
			
		||||
        return Q()
 | 
			
		||||
 | 
			
		||||
    def by_pm_with(self, operand):
 | 
			
		||||
        if ',' in operand:
 | 
			
		||||
            # Huddle
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user