Compare commits

...
Author SHA1 Message Date
Samuel Attard dd5ca989be feat: handle incoming electron-fiddle://token/* launches 2019-06-07 16:25:54 -07:00
3 changed files with 24 additions and 2 deletions
+4 -2
View File
@@ -17,7 +17,8 @@ export enum IpcEvents {
FS_SAVE_FIDDLE_DIALOG = 'FS_SAVE_FIDDLE_DIALOG',
FS_SAVE_FIDDLE_ERROR = 'FS_SAVE_FIDDLE_ERROR',
SHOW_WARNING_DIALOG = 'SHOW_WARNING_DIALOG',
SHOW_WELCOME_TOUR = 'SHOW_WELCOME_TOUR'
SHOW_WELCOME_TOUR = 'SHOW_WELCOME_TOUR',
SET_GITHUB_TOKEN = 'SET_GITHUB_TOKEN'
}
export const ipcMainEvents = [
@@ -42,7 +43,8 @@ export const ipcRendererEvents = [
IpcEvents.FS_SAVE_FIDDLE_AS,
IpcEvents.FS_SAVE_FIDDLE_FORGE,
IpcEvents.FS_SAVE_FIDDLE_GIST,
IpcEvents.SHOW_WELCOME_TOUR
IpcEvents.SHOW_WELCOME_TOUR,
IpcEvents.SET_GITHUB_TOKEN
];
export const WEBCONTENTS_READY_FOR_IPC_SIGNAL = 'WEBCONTENTS_READY_FOR_IPC_SIGNAL';
+5
View File
@@ -52,6 +52,11 @@ const handlePotentialProtocolLaunch = (url: string) => {
return;
}
break;
case 'token':
if (pathParts.length === 1) {
// We have a token
ipcMainManager.send(IpcEvents.SET_GITHUB_TOKEN, [pathParts[0]]);
}
default:
return;
}
+15
View File
@@ -116,6 +116,7 @@ export class AppState {
this.pushError = this.pushError.bind(this);
this.pushOutput = this.pushOutput.bind(this);
this.removeVersion = this.removeVersion.bind(this);
this.setToken = this.setToken.bind(this);
this.setVersion = this.setVersion.bind(this);
this.showTour = this.showTour.bind(this);
this.signOutGitHub = this.signOutGitHub.bind(this);
@@ -126,6 +127,7 @@ export class AppState {
ipcRendererManager.on(IpcEvents.OPEN_SETTINGS, this.toggleSettings);
ipcRendererManager.on(IpcEvents.SHOW_WELCOME_TOUR, this.showTour);
ipcRendererManager.on(IpcEvents.SET_GITHUB_TOKEN, this.setToken);
// Setup auto-runs
autorun(() => this.save('theme', this.theme));
@@ -261,6 +263,19 @@ export class AppState {
this.resetView({ isTourShowing: true });
}
@action public async setToken(_: any, token: string) {
this.setWarningDialogTexts({
label: 'Do you want to sign in to Electron Fiddle using this token?',
ok: 'Yes',
cancel: 'No'
});
this.isWarningDialogShowing = true;
await when(() => !this.isWarningDialogShowing);
if (this.warningDialogLastResult) {
this.gitHubToken = token;
}
}
@action public setTheme(fileName?: string) {
this.theme = fileName || '';
activateTheme(undefined, undefined, fileName);