mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	compose: Fix stale preview rendering after exiting preview mode.
If the user exits preview mode before the render response arrives, the render is still applied to the hidden preview element, causing a stale preview to appear when switching back to preview mode. This commit adds a check to ensure the render is only applied if the user is still in preview mode when the render response is received.
This commit is contained in:
		@@ -1354,8 +1354,12 @@ export function render_and_show_preview(
 | 
			
		||||
            url: "/json/messages/render",
 | 
			
		||||
            data: {content},
 | 
			
		||||
            success(response_data) {
 | 
			
		||||
                if (preview_render_count !== compose_state.get_preview_render_count()) {
 | 
			
		||||
                    // The compose input has already been updated with new raw Markdown
 | 
			
		||||
                if (
 | 
			
		||||
                    preview_render_count !== compose_state.get_preview_render_count() ||
 | 
			
		||||
                    !$("#compose").hasClass("preview_mode")
 | 
			
		||||
                ) {
 | 
			
		||||
                    // The user is no longer in preview mode or the compose
 | 
			
		||||
                    // input has already been updated with new raw Markdown
 | 
			
		||||
                    // since this rendering request was sent off to the server, so
 | 
			
		||||
                    // there's nothing to do.
 | 
			
		||||
                    return;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user