mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	Add potential workarounds for renderer crash
This commit is contained in:
		
							parent
							
								
									a531d4e30f
								
							
						
					
					
						commit
						5aefe765ec
					
				
					 4 changed files with 59 additions and 46 deletions
				
			
		|  | @ -21,6 +21,11 @@ import {createSplashWindow} from "./splash/main"; | ||||||
| export let iconPath: string; | export let iconPath: string; | ||||||
| export let settings: any; | export let settings: any; | ||||||
| export let customTitlebar: boolean; | export let customTitlebar: boolean; | ||||||
|  | app.on("render-process-gone", (event, webContents, details) => { | ||||||
|  |     if (details.reason == "crashed") { | ||||||
|  |         app.relaunch(); | ||||||
|  |     } | ||||||
|  | }); | ||||||
| async function args(): Promise<void> { | async function args(): Promise<void> { | ||||||
|     let argNum = 2; |     let argNum = 2; | ||||||
|     if (process.argv[0] == "electron") argNum++; |     if (process.argv[0] == "electron") argNum++; | ||||||
|  |  | ||||||
|  | @ -54,19 +54,21 @@ export function createSettingsWindow(): void { | ||||||
|             fs.writeFileSync(path.join(userDataPath, "/disabled.txt"), ""); |             fs.writeFileSync(path.join(userDataPath, "/disabled.txt"), ""); | ||||||
|         } |         } | ||||||
|         settingsWindow.webContents.on("did-finish-load", () => { |         settingsWindow.webContents.on("did-finish-load", () => { | ||||||
|             fs.readdirSync(themesFolder).forEach((file) => { |             if (!settingsWindow.webContents.isLoading()) { | ||||||
|                 try { |                 fs.readdirSync(themesFolder).forEach((file) => { | ||||||
|                     const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); |                     try { | ||||||
|                     let themeFile = JSON.parse(manifest); |                         const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); | ||||||
|                     settingsWindow.webContents.send( |                         let themeFile = JSON.parse(manifest); | ||||||
|                         "themeLoader", |                         settingsWindow.webContents.send( | ||||||
|                         fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8") |                             "themeLoader", | ||||||
|                     ); |                             fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8") | ||||||
|                     console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red"); |                         ); | ||||||
|                 } catch (err) { |                         console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red"); | ||||||
|                     console.error(err); |                     } catch (err) { | ||||||
|                 } |                         console.error(err); | ||||||
|             }); |                     } | ||||||
|  |                 }); | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
|         ipcMain.on("saveSettings", (_event, args: Settings) => { |         ipcMain.on("saveSettings", (_event, args: Settings) => { | ||||||
|             console.log(args); |             console.log(args); | ||||||
|  |  | ||||||
|  | @ -195,14 +195,16 @@ export function createTManagerWindow(): void { | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|         themeWindow.webContents.on("did-finish-load", () => { |         themeWindow.webContents.on("did-finish-load", () => { | ||||||
|             fs.readdirSync(themesFolder).forEach((file) => { |             if (!themeWindow.webContents.isLoading()) { | ||||||
|                 try { |                 fs.readdirSync(themesFolder).forEach((file) => { | ||||||
|                     const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); |                     try { | ||||||
|                     themeWindow.webContents.send("themeManifest", manifest); |                         const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); | ||||||
|                 } catch (err) { |                         themeWindow.webContents.send("themeManifest", manifest); | ||||||
|                     console.error(err); |                     } catch (err) { | ||||||
|                 } |                         console.error(err); | ||||||
|             }); |                     } | ||||||
|  |                 }); | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         managerLoadPage(); |         managerLoadPage(); | ||||||
|  |  | ||||||
|  | @ -198,28 +198,30 @@ async function doAfterDefiningTheWindow(): Promise<void> { | ||||||
|         fs.writeFileSync(path.join(userDataPath, "/disabled.txt"), ""); |         fs.writeFileSync(path.join(userDataPath, "/disabled.txt"), ""); | ||||||
|     } |     } | ||||||
|     mainWindow.webContents.on("did-finish-load", () => { |     mainWindow.webContents.on("did-finish-load", () => { | ||||||
|         fs.readdirSync(themesFolder).forEach((file) => { |         if (!mainWindow.webContents.isLoading()) { | ||||||
|             try { |             fs.readdirSync(themesFolder).forEach((file) => { | ||||||
|                 const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); |                 try { | ||||||
|                 let themeFile = JSON.parse(manifest); |                     const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); | ||||||
|                 if ( |                     let themeFile = JSON.parse(manifest); | ||||||
|                     fs |                     if ( | ||||||
|                         .readFileSync(path.join(userDataPath, "/disabled.txt")) |                         fs | ||||||
|                         .toString() |                             .readFileSync(path.join(userDataPath, "/disabled.txt")) | ||||||
|                         .includes(themeFile.name.replace(" ", "-")) |                             .toString() | ||||||
|                 ) { |                             .includes(themeFile.name.replace(" ", "-")) | ||||||
|                     console.log(`%cSkipped ${themeFile.name} made by ${themeFile.author}`, "color:red"); |                     ) { | ||||||
|                 } else { |                         console.log(`%cSkipped ${themeFile.name} made by ${themeFile.author}`, "color:red"); | ||||||
|                     mainWindow.webContents.send( |                     } else { | ||||||
|                         "themeLoader", |                         mainWindow.webContents.send( | ||||||
|                         fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8") |                             "themeLoader", | ||||||
|                     ); |                             fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8") | ||||||
|                     console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red"); |                         ); | ||||||
|  |                         console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red"); | ||||||
|  |                     } | ||||||
|  |                 } catch (err) { | ||||||
|  |                     console.error(err); | ||||||
|                 } |                 } | ||||||
|             } catch (err) { |             }); | ||||||
|                 console.error(err); |         } | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     }); |     }); | ||||||
|     await setMenu(); |     await setMenu(); | ||||||
|     mainWindow.on("close", async (e) => { |     mainWindow.on("close", async (e) => { | ||||||
|  | @ -370,9 +372,11 @@ export async function createInviteWindow(code: string): Promise<void> { | ||||||
|     }); |     }); | ||||||
|     inviteWindow.loadURL(formInviteURL); |     inviteWindow.loadURL(formInviteURL); | ||||||
|     inviteWindow.webContents.once("did-finish-load", () => { |     inviteWindow.webContents.once("did-finish-load", () => { | ||||||
|         inviteWindow.show(); |         if (!mainWindow.webContents.isLoading()) { | ||||||
|         inviteWindow.webContents.once("will-navigate", () => { |             inviteWindow.show(); | ||||||
|             inviteWindow.close(); |             inviteWindow.webContents.once("will-navigate", () => { | ||||||
|         }); |                 inviteWindow.close(); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue