mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	typeahead: Show only users in silent mentions typeahead.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							69c16ab90d
						
					
				
				
					commit
					c504fa98aa
				
			@@ -316,7 +316,7 @@ run_test('content_typeahead_selected', () => {
 | 
			
		||||
    var document_stub_trigger1_called = false;
 | 
			
		||||
    $('document-stub').trigger = function (event, params) {
 | 
			
		||||
        assert.equal(event, 'usermention_completed.zulip');
 | 
			
		||||
        assert.deepEqual(params, { mentioned: othello });
 | 
			
		||||
        assert.deepEqual(params, { mentioned: othello, is_silent: false });
 | 
			
		||||
        document_stub_trigger1_called = true;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@@ -349,7 +349,7 @@ run_test('content_typeahead_selected', () => {
 | 
			
		||||
    var document_stub_trigger3_called = false;
 | 
			
		||||
    $('document-stub').trigger = function (event, params) {
 | 
			
		||||
        assert.equal(event, 'usermention_completed.zulip');
 | 
			
		||||
        assert.deepEqual(params, { mentioned: hamlet });
 | 
			
		||||
        assert.deepEqual(params, { mentioned: hamlet, is_silent: true });
 | 
			
		||||
        document_stub_trigger3_called = true;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@@ -1134,7 +1134,8 @@ run_test('begins_typeahead', () => {
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    var people_with_all = global.people.get_realm_persons().concat(all_items);
 | 
			
		||||
    var people_only = global.people.get_realm_persons();
 | 
			
		||||
    var people_with_all = people_only.concat(all_items);
 | 
			
		||||
    var all_mentions = people_with_all.concat(global.user_groups.get_realm_user_groups());
 | 
			
		||||
    var lang_list = Object.keys(pygments_data.langs);
 | 
			
		||||
 | 
			
		||||
@@ -1156,11 +1157,11 @@ run_test('begins_typeahead', () => {
 | 
			
		||||
    assert_typeahead_equals(" @", false);
 | 
			
		||||
    assert_typeahead_equals(" @_", false);
 | 
			
		||||
    assert_typeahead_equals("test @**o", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_**o", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_**o", people_only);
 | 
			
		||||
    assert_typeahead_equals("test @*o", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_*k", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_*k", people_only);
 | 
			
		||||
    assert_typeahead_equals("test @*h", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_*h", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_*h", people_only);
 | 
			
		||||
    assert_typeahead_equals("test @", false);
 | 
			
		||||
    assert_typeahead_equals("test @_", false);
 | 
			
		||||
    assert_typeahead_equals("test no@o", false);
 | 
			
		||||
@@ -1172,19 +1173,19 @@ run_test('begins_typeahead', () => {
 | 
			
		||||
    assert_typeahead_equals("@** ", false);
 | 
			
		||||
    assert_typeahead_equals("@_** ", false);
 | 
			
		||||
    assert_typeahead_equals("test\n@i", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test\n@_i", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test\n@_i", people_only);
 | 
			
		||||
    assert_typeahead_equals("test\n @l", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test\n @_l", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test\n @_l", people_only);
 | 
			
		||||
    assert_typeahead_equals("@zuli", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("@_zuli", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("@_zuli", people_only);
 | 
			
		||||
    assert_typeahead_equals("@ zuli", false);
 | 
			
		||||
    assert_typeahead_equals("@_ zuli", false);
 | 
			
		||||
    assert_typeahead_equals(" @zuli", all_mentions);
 | 
			
		||||
    assert_typeahead_equals(" @_zuli", all_mentions);
 | 
			
		||||
    assert_typeahead_equals(" @_zuli", people_only);
 | 
			
		||||
    assert_typeahead_equals("test @o", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_o", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_o", people_only);
 | 
			
		||||
    assert_typeahead_equals("test @z", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_z", all_mentions);
 | 
			
		||||
    assert_typeahead_equals("test @_z", people_only);
 | 
			
		||||
 | 
			
		||||
    assert_typeahead_equals(":", false);
 | 
			
		||||
    assert_typeahead_equals(": ", false);
 | 
			
		||||
 
 | 
			
		||||
@@ -343,20 +343,26 @@ exports.tokenize_compose_str = function (s) {
 | 
			
		||||
    return '';
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function get_mention_candidates_data() {
 | 
			
		||||
    var all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
 | 
			
		||||
        return {
 | 
			
		||||
            special_item_text: i18n.t("__wildcard_mention_token__ (Notify stream)",
 | 
			
		||||
                                      {wildcard_mention_token: mention}),
 | 
			
		||||
            email: mention,
 | 
			
		||||
            // Always sort above, under the assumption that names will
 | 
			
		||||
            // be longer and only contain "all" as a substring.
 | 
			
		||||
            pm_recipient_count: Infinity,
 | 
			
		||||
            full_name: mention,
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
function get_mention_candidates_data(is_silent) {
 | 
			
		||||
    var all_items = [];
 | 
			
		||||
    var groups = [];
 | 
			
		||||
 | 
			
		||||
    if (!is_silent) {
 | 
			
		||||
        all_items = _.map(['all', 'everyone', 'stream'], function (mention) {
 | 
			
		||||
            return {
 | 
			
		||||
                special_item_text: i18n.t("__wildcard_mention_token__ (Notify stream)",
 | 
			
		||||
                                          {wildcard_mention_token: mention}),
 | 
			
		||||
                email: mention,
 | 
			
		||||
                // Always sort above, under the assumption that names will
 | 
			
		||||
                // be longer and only contain "all" as a substring.
 | 
			
		||||
                pm_recipient_count: Infinity,
 | 
			
		||||
                full_name: mention,
 | 
			
		||||
            };
 | 
			
		||||
        });
 | 
			
		||||
        groups = user_groups.get_realm_user_groups();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var persons = people.get_realm_persons();
 | 
			
		||||
    var groups = user_groups.get_realm_user_groups();
 | 
			
		||||
    return [].concat(persons, all_items, groups);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -442,8 +448,10 @@ exports.compose_content_begins_typeahead = function (query) {
 | 
			
		||||
        current_token = current_token.substring(1);
 | 
			
		||||
        this.completing = 'mention';
 | 
			
		||||
        // Silent mentions
 | 
			
		||||
        var is_silent = false;
 | 
			
		||||
        if (current_token.startsWith('_')) {
 | 
			
		||||
            this.completing = 'silent_mention';
 | 
			
		||||
            is_silent = true;
 | 
			
		||||
            current_token = current_token.substring(1);
 | 
			
		||||
        }
 | 
			
		||||
        current_token = filter_mention_name(current_token);
 | 
			
		||||
@@ -452,7 +460,7 @@ exports.compose_content_begins_typeahead = function (query) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        this.token = current_token;
 | 
			
		||||
        return get_mention_candidates_data();
 | 
			
		||||
        return get_mention_candidates_data(is_silent);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (this.options.completions.stream && current_token[0] === '#') {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user