mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	blueslip: Protect against drafts pitfall for rows.id.
If folks use an overly broad selector for message rows, they will accidentally include drafts from the drafts dialog, which won't have zids. More specific selectors will be more efficient and possibly prevent strange behaviors. For testing convenience, we extract the message.
This commit is contained in:
		@@ -14,6 +14,8 @@ set_global('popovers', {
 | 
			
		||||
    hide_all: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
rows.is_draft_row = () => false;
 | 
			
		||||
 | 
			
		||||
set_global('$', global.make_zjquery());
 | 
			
		||||
 | 
			
		||||
run_test('pan_and_zoom', () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,16 @@ exports.last_visible = function () {
 | 
			
		||||
    return $('.focused_table .selectable_row').last();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.is_draft_row = function (row) {
 | 
			
		||||
    return row.find('.restore-draft').length >= 1;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.id = function (message_row) {
 | 
			
		||||
    if (exports.is_draft_row(message_row)) {
 | 
			
		||||
        blueslip.error('Drafts have no zid');
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
        For blueslip errors, don't return early, since
 | 
			
		||||
        we may have some code now that actually relies
 | 
			
		||||
@@ -49,6 +58,7 @@ exports.id = function (message_row) {
 | 
			
		||||
        that up in the future, but we mainly just want
 | 
			
		||||
        more data now.
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    if (message_row.length !== 1) {
 | 
			
		||||
        blueslip.error("Caller should pass in a single row.");
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user