Page MenuHomePhabricator

D13003.diff
No OneTemporary

D13003.diff

diff --git a/desktop/flow-typed/npm/electron_v22.0.0.js b/desktop/flow-typed/npm/electron_v22.0.0.js
--- a/desktop/flow-typed/npm/electron_v22.0.0.js
+++ b/desktop/flow-typed/npm/electron_v22.0.0.js
@@ -12,6 +12,24 @@
setName: (name: string) => void,
setAppUserModelId: (id: string) => void,
getVersion: () => string,
+ getPath: (name:
+ | 'home'
+ | 'appData'
+ | 'userData'
+ | 'sessionData'
+ | 'temp'
+ | 'exe'
+ | 'module'
+ | 'desktop'
+ | 'documents'
+ | 'downloads'
+ | 'music'
+ | 'pictures'
+ | 'videos'
+ | 'recent'
+ | 'logs'
+ | 'crashDumps'
+ ) => string,
dock: Dock,
isPackaged: boolean,
name: string,
@@ -404,6 +422,13 @@
type: Type,
): $ElementType<UserDefaultTypes, Type>,
};
+
+ declare export var dialog: Dialog;
+ declare type Dialog = {
+ +showErrorBox: (title: string, content: string) => void;
+ ...
+ };
+
declare export type UserDefaultTypes = {
string: string,
boolean: boolean,
@@ -494,6 +519,7 @@
declare export {
app,
BrowserWindow,
+ dialog,
shell,
Menu,
ipcMain,
diff --git a/desktop/src/handle-squirrel-event.js b/desktop/src/handle-squirrel-event.js
--- a/desktop/src/handle-squirrel-event.js
+++ b/desktop/src/handle-squirrel-event.js
@@ -1,7 +1,8 @@
// @flow
import { spawn, execSync } from 'child_process';
-import { app } from 'electron';
+import { app, dialog } from 'electron';
+import fs from 'fs';
import path from 'path';
// Squirrel will start the app with additional flags during installing,
@@ -21,6 +22,8 @@
};
const squirrelEvent = process.argv[1];
+ app.setName('Comm');
+
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
@@ -32,6 +35,16 @@
case '--squirrel-uninstall':
spawnUpdate(['--removeShortcut', commExeName]);
+ try {
+ fs.rmdirSync(app.getPath('userData'), { recursive: true });
+ } catch (e) {
+ dialog.showErrorBox(
+ 'Failed to remove folder!',
+ `You might need to manually remove ${app.getPath(
+ 'userData',
+ )} folder.`,
+ );
+ }
return true;
case '--squirrel-obsolete':

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 4:01 AM (14 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587684
Default Alt Text
D13003.diff (2 KB)

Event Timeline