mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	refactor(logo-customization): simplified updateProjectSettings service function signature
This commit is contained in:
		
							parent
							
								
									5fde7a23d0
								
							
						
					
					
						commit
						ba8cb27bb1
					
				| @ -61,7 +61,7 @@ module.exports = { | ||||
|     const formatedFiles = await projectSettingsService.parseFilesData(files); | ||||
|     await validateUpdateProjectSettingsImagesDimensions(formatedFiles); | ||||
| 
 | ||||
|     return projectSettingsService.updateProjectSettings({ body, files: formatedFiles }); | ||||
|     return projectSettingsService.updateProjectSettings({ ...body, ...formatedFiles }); | ||||
|   }, | ||||
| 
 | ||||
|   async information() { | ||||
|  | ||||
| @ -75,7 +75,11 @@ const getProjectSettings = async () => { | ||||
| 
 | ||||
| const uploadFiles = async (files = {}) => { | ||||
|   // Call the provider upload function for each file
 | ||||
|   return Promise.all(Object.values(files).map(strapi.plugin('upload').provider.uploadStream)); | ||||
|   return Promise.all( | ||||
|     Object.values(files) | ||||
|       .filter(file => file.stream instanceof fs.ReadStream) | ||||
|       .map(strapi.plugin('upload').provider.uploadStream) | ||||
|   ); | ||||
| }; | ||||
| 
 | ||||
| const deleteOldFiles = async ({ previousSettings, newSettings }) => { | ||||
| @ -106,17 +110,13 @@ const deleteOldFiles = async ({ previousSettings, newSettings }) => { | ||||
|   ); | ||||
| }; | ||||
| 
 | ||||
| const updateProjectSettings = async ({ body, files }) => { | ||||
| const updateProjectSettings = async newSettings => { | ||||
|   const store = strapi.store({ type: 'core', name: 'admin' }); | ||||
|   const previousSettings = await store.get({ key: 'project-settings' }); | ||||
|   const files = pick(newSettings, PROJECT_SETTINGS_FILE_INPUTS); | ||||
| 
 | ||||
|   await uploadFiles(files); | ||||
| 
 | ||||
|   const newSettings = { | ||||
|     ...body, | ||||
|     ...files, | ||||
|   }; | ||||
| 
 | ||||
|   PROJECT_SETTINGS_FILE_INPUTS.forEach(inputName => { | ||||
|     // If the user input exists but is not a formdata "file" remove it
 | ||||
|     if (newSettings[inputName] !== undefined && !(typeof newSettings[inputName] === 'object')) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 vincentbpro
						vincentbpro