Fix: make codeIsUpdated flag work properly
This commit is contained in:
		
							parent
							
								
									e7eb38bba9
								
							
						
					
					
						commit
						4b2f7a1a46
					
				
							
								
								
									
										16
									
								
								edit/edit.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								edit/edit.js
									
									
									
									
									
								
							|  | @ -1365,17 +1365,21 @@ function setStyleMeta(style) { | ||||||
|   $('#url').href = style.url || ''; |   $('#url').href = style.url || ''; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function initWithStyle({style}) { | function initWithStyle(request) { | ||||||
|   // FIXME: what does codeIsUpdated do?
 |  | ||||||
|   if (!style.usercss) { |   if (!style.usercss) { | ||||||
|     initWithSectionStyle({style}); |     initWithSectionStyle(request); | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (editor) { |   if (!editor) { | ||||||
|     editor.replaceStyle(style); |     editor = createSourceEditor(request.style); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   if (request.codeIsUpdated === false) { | ||||||
|  |     editor.updateStyleMeta(request.style); | ||||||
|   } else { |   } else { | ||||||
|     editor = createSourceEditor(style); |     editor.replaceStyle(request.style); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -95,6 +95,11 @@ function createSourceEditor(style) { | ||||||
|     dirty.clear(); |     dirty.clear(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   function updateStyleMeta(_style) { | ||||||
|  |     dirty.modify('enabled', style.enabled, _style.enabled); | ||||||
|  |     style.enabled = _style.enabled; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   function toggleStyle() { |   function toggleStyle() { | ||||||
|     const value = !style.enabled; |     const value = !style.enabled; | ||||||
|     dirty.modify('enabled', style.enabled, value); |     dirty.modify('enabled', style.enabled, value); | ||||||
|  | @ -132,5 +137,5 @@ function createSourceEditor(style) { | ||||||
|       }); |       }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return {replaceStyle, save, toggleStyle}; |   return {replaceStyle, save, toggleStyle, updateStyleMeta}; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user