mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	edit_history: Refactor first entry's calculation of show_date_row.
Previously, the show_date_row flag for the first entry in the edit history modal was directly set to `true`, while in all other entries it was calculated with identical code. Though show_date_row for the first entry should indeed always be true, there's no need for it to be a special case. In preparation for factoring out the calculation of show_date_row, this commit nominally calculates the first entry's show_date_row with the same code that is used to calculate show_date_row for all other entries. Nominally, because it will still always end up being true.
This commit is contained in:
		@@ -6,7 +6,7 @@ exports.fetch_and_render_message_history = function (message) {
 | 
				
			|||||||
        data: {message_id: JSON.stringify(message.id)},
 | 
					        data: {message_id: JSON.stringify(message.id)},
 | 
				
			||||||
        success: function (data) {
 | 
					        success: function (data) {
 | 
				
			||||||
            const content_edit_history = [];
 | 
					            const content_edit_history = [];
 | 
				
			||||||
            let prev_timestamp;
 | 
					            let prev_timestamp = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (const [index, msg] of data.message_history.entries()) {
 | 
					            for (const [index, msg] of data.message_history.entries()) {
 | 
				
			||||||
                // Format timestamp nicely for display
 | 
					                // Format timestamp nicely for display
 | 
				
			||||||
@@ -23,7 +23,8 @@ exports.fetch_and_render_message_history = function (message) {
 | 
				
			|||||||
                if (index === 0) {
 | 
					                if (index === 0) {
 | 
				
			||||||
                    item.posted_or_edited = "Posted by";
 | 
					                    item.posted_or_edited = "Posted by";
 | 
				
			||||||
                    item.body_to_render = msg.rendered_content;
 | 
					                    item.body_to_render = msg.rendered_content;
 | 
				
			||||||
                    item.show_date_row = true;
 | 
					                    // This will always be true because of `prev_timestamp = null` above.
 | 
				
			||||||
 | 
					                    item.show_date_row = !moment(timestamp).isSame(prev_timestamp, 'day');
 | 
				
			||||||
                } else if (msg.prev_topic && msg.prev_content) {
 | 
					                } else if (msg.prev_topic && msg.prev_content) {
 | 
				
			||||||
                    item.posted_or_edited = "Edited by";
 | 
					                    item.posted_or_edited = "Edited by";
 | 
				
			||||||
                    item.body_to_render = msg.content_html_diff;
 | 
					                    item.body_to_render = msg.content_html_diff;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user