mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	message_edit: Add util.get_edit_event_orig_topic().
This extracts this bit of parsing logic for message_edit events.
This commit is contained in:
		@@ -126,6 +126,10 @@ run_test('dumb_strcmp', () => {
 | 
			
		||||
    assert.equal(strcmp('z', 'y'), 1);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
run_test('get_edit_event_orig_topic', () => {
 | 
			
		||||
    assert.equal(util.get_edit_event_orig_topic({orig_subject: 'lunch'}), 'lunch');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
run_test('is_mobile', () => {
 | 
			
		||||
    global.window.navigator = { userAgent: "Android" };
 | 
			
		||||
    assert(util.is_mobile());
 | 
			
		||||
 
 | 
			
		||||
@@ -159,10 +159,11 @@ exports.update_messages = function update_messages(events) {
 | 
			
		||||
 | 
			
		||||
            var stream_name = stream_data.get_sub_by_id(event.stream_id).name;
 | 
			
		||||
            var compose_stream_name = compose_state.stream_name();
 | 
			
		||||
            var orig_topic = util.get_edit_event_orig_topic(event);
 | 
			
		||||
 | 
			
		||||
            if (going_forward_change && stream_name && compose_stream_name) {
 | 
			
		||||
                if (stream_name.toLowerCase() === compose_stream_name.toLowerCase()) {
 | 
			
		||||
                    if (event.orig_subject === compose_state.topic()) {
 | 
			
		||||
                    if (orig_topic === compose_state.topic()) {
 | 
			
		||||
                        changed_compose = true;
 | 
			
		||||
                        compose_state.topic(event.subject);
 | 
			
		||||
                        compose_fade.set_focused_recipient("stream");
 | 
			
		||||
@@ -177,7 +178,7 @@ exports.update_messages = function update_messages(events) {
 | 
			
		||||
                if (selection_changed_topic) {
 | 
			
		||||
                    var current_filter = narrow_state.filter();
 | 
			
		||||
                    if (current_filter && stream_name) {
 | 
			
		||||
                        if (current_filter.has_topic(stream_name, event.orig_subject)) {
 | 
			
		||||
                        if (current_filter.has_topic(stream_name, orig_topic)) {
 | 
			
		||||
                            var new_filter = current_filter.filter_with_new_topic(event.subject);
 | 
			
		||||
                            var operators = new_filter.operators();
 | 
			
		||||
                            var opts = {
 | 
			
		||||
 
 | 
			
		||||
@@ -322,6 +322,10 @@ exports.get_message_topic = function (obj) {
 | 
			
		||||
    return obj.topic;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.get_edit_event_orig_topic = function (obj) {
 | 
			
		||||
    return obj.orig_subject;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.is_topic_synonym = function (operator) {
 | 
			
		||||
    return operator === 'subject';
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user