Disable image preload
This commit is contained in:
		
					parent
					
						
							
								6154b83720
							
						
					
				
			
			
				commit
				
					
						00349b5b33
					
				
			
		
					 5 changed files with 0 additions and 58 deletions
				
			
		|  | @ -3,8 +3,6 @@ | ||||||
| 
 | 
 | ||||||
| import { join, relative, normalize } from 'path'; | import { join, relative, normalize } from 'path'; | ||||||
| import fastGlob from 'fast-glob'; | import fastGlob from 'fast-glob'; | ||||||
| import glob from 'glob'; |  | ||||||
| import pify from 'pify'; |  | ||||||
| import fse from 'fs-extra'; | import fse from 'fs-extra'; | ||||||
| import { map, isString } from 'lodash'; | import { map, isString } from 'lodash'; | ||||||
| import normalizePath from 'normalize-path'; | import normalizePath from 'normalize-path'; | ||||||
|  | @ -113,16 +111,6 @@ export const getAllDraftAttachments = async ( | ||||||
|   return map(files, file => relative(dir, file)); |   return map(files, file => relative(dir, file)); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const getBuiltInImages = async (): Promise<ReadonlyArray<string>> => { |  | ||||||
|   const dir = join(__dirname, '../images'); |  | ||||||
|   const pattern = join(dir, '**', '*.svg'); |  | ||||||
| 
 |  | ||||||
|   // Note: we cannot use fast-glob here because, inside of .asar files, readdir will not
 |  | ||||||
|   //   honor the withFileTypes flag: https://github.com/electron/electron/issues/19074
 |  | ||||||
|   const files = await pify(glob)(pattern, { nodir: true }); |  | ||||||
|   return map(files, file => relative(dir, file)); |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| export const clearTempPath = (userDataPath: string): Promise<void> => { | export const clearTempPath = (userDataPath: string): Promise<void> => { | ||||||
|   const tempPath = getTempPath(userDataPath); |   const tempPath = getTempPath(userDataPath); | ||||||
|   return fse.emptyDir(tempPath); |   return fse.emptyDir(tempPath); | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								app/main.ts
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								app/main.ts
									
										
									
									
									
								
							|  | @ -2222,27 +2222,6 @@ ipc.on('delete-all-data', () => { | ||||||
|   } |   } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| ipc.on('get-built-in-images', async () => { |  | ||||||
|   if (!mainWindow) { |  | ||||||
|     getLogger().warn('ipc/get-built-in-images: No mainWindow!'); |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   try { |  | ||||||
|     const images = await attachments.getBuiltInImages(); |  | ||||||
|     mainWindow.webContents.send('get-success-built-in-images', null, images); |  | ||||||
|   } catch (error) { |  | ||||||
|     if (mainWindow && mainWindow.webContents) { |  | ||||||
|       mainWindow.webContents.send('get-success-built-in-images', error.message); |  | ||||||
|     } else { |  | ||||||
|       getLogger().error( |  | ||||||
|         'Error handling get-built-in-images:', |  | ||||||
|         Errors.toLogFormat(error) |  | ||||||
|       ); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| }); |  | ||||||
| 
 |  | ||||||
| ipc.on('get-config', async event => { | ipc.on('get-config', async event => { | ||||||
|   const theme = await getResolvedThemeSetting(); |   const theme = await getResolvedThemeSetting(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -543,19 +543,6 @@ export async function startApp(): Promise<void> { | ||||||
| 
 | 
 | ||||||
|   startInteractionMode(); |   startInteractionMode(); | ||||||
| 
 | 
 | ||||||
|   // Load these images now to ensure that they don't flicker on first use
 |  | ||||||
|   window.preloadedImages = []; |  | ||||||
|   function preload(list: ReadonlyArray<string>) { |  | ||||||
|     for (let index = 0, max = list.length; index < max; index += 1) { |  | ||||||
|       const image = new Image(); |  | ||||||
|       image.src = `./images/${list[index]}`; |  | ||||||
|       window.preloadedImages.push(image); |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   const builtInImages = await window.IPC.getBuiltInImages(); |  | ||||||
|   preload(builtInImages); |  | ||||||
| 
 |  | ||||||
|   // We add this to window here because the default Node context is erased at the end
 |   // We add this to window here because the default Node context is erased at the end
 | ||||||
|   //   of preload.js processing
 |   //   of preload.js processing
 | ||||||
|   window.setImmediate = window.nodeSetImmediate; |   window.setImmediate = window.nodeSetImmediate; | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								ts/window.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								ts/window.d.ts
									
										
									
									
										vendored
									
									
								
							|  | @ -70,7 +70,6 @@ export type IPCType = { | ||||||
|   }; |   }; | ||||||
|   drawAttention: () => void; |   drawAttention: () => void; | ||||||
|   getAutoLaunch: () => Promise<boolean>; |   getAutoLaunch: () => Promise<boolean>; | ||||||
|   getBuiltInImages: () => Promise<Array<string>>; |  | ||||||
|   getMediaCameraPermissions: () => Promise<boolean>; |   getMediaCameraPermissions: () => Promise<boolean>; | ||||||
|   getMediaPermissions: () => Promise<boolean>; |   getMediaPermissions: () => Promise<boolean>; | ||||||
|   logAppLoadedEvent?: (options: { processedCount?: number }) => void; |   logAppLoadedEvent?: (options: { processedCount?: number }) => void; | ||||||
|  |  | ||||||
|  | @ -83,17 +83,6 @@ const IPC: IPCType = { | ||||||
|     ipc.send('draw-attention'); |     ipc.send('draw-attention'); | ||||||
|   }, |   }, | ||||||
|   getAutoLaunch: () => ipc.invoke('get-auto-launch'), |   getAutoLaunch: () => ipc.invoke('get-auto-launch'), | ||||||
|   getBuiltInImages: () => |  | ||||||
|     new Promise((resolve, reject) => { |  | ||||||
|       ipc.once('get-success-built-in-images', (_event, error, value) => { |  | ||||||
|         if (error) { |  | ||||||
|           return reject(new Error(error)); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         return resolve(value); |  | ||||||
|       }); |  | ||||||
|       ipc.send('get-built-in-images'); |  | ||||||
|     }), |  | ||||||
|   getMediaPermissions: () => ipc.invoke('settings:get:mediaPermissions'), |   getMediaPermissions: () => ipc.invoke('settings:get:mediaPermissions'), | ||||||
|   getMediaCameraPermissions: () => |   getMediaCameraPermissions: () => | ||||||
|     ipc.invoke('settings:get:mediaCameraPermissions'), |     ipc.invoke('settings:get:mediaCameraPermissions'), | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fedor Indutny
				Fedor Indutny