Skip to content

Commit

Permalink
Merge pull request #57 from appodeal/develop
Browse files Browse the repository at this point in the history
Release 0.1.15
  • Loading branch information
alex-skakun authored May 15, 2019
2 parents 7a564fe + 3bd1369 commit f3c9597
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"repository": "https://github.com/appodeal/admob-sync-app",
"description": "Appodeal AdMob Sync application",
"private": true,
"version": "0.1.14",
"version": "0.1.15",
"scripts": {
"start": "webpack --watch --progress --config=webpack/development.ts",
"test": "jest",
Expand Down
10 changes: 10 additions & 0 deletions src/core/accounts-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export class AccountsConnector extends Connector {
this.store.removeAccountSetup(payload.adMobAccount.id);
}
return this.store.setupState(payload.adMobAccount.id, {visible: false, mode: null});
case ActionTypes.adMobShowSetup:
let currentSetup = this.setups.get(payload.adMobAccount.id);
if (currentSetup) {
if (currentSetup.window.isVisible()) {
currentSetup.window.hide();
} else {
currentSetup.window.show();
}
}
break;
case ActionTypes.openAdmobPage:
return AdMobSessions.openAdmob(payload.adMobAccount);
case ActionTypes.manageAppodealAccounts:
Expand Down
4 changes: 2 additions & 2 deletions src/core/admob-api/account-setup.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ALLOWED_CALLBACKS = setupOptions.allowedCallbacks;


export class AccountSetup extends EventEmitter {
private window: BrowserWindow;
window: BrowserWindow;
private debug: Debug;
private account: AdMobAccount;
private runner = new TaskRunner();
Expand Down Expand Up @@ -292,7 +292,7 @@ export class AccountSetup extends EventEmitter {

// create client
this.runner.createTask(() => this.debug.click(dropDownBtn), 'createClient');
this.runner.createTask(() => this.debug.waitElementVisible(oAuthItem).catch(() => this.runner.returnTo('createClient')));
this.runner.createTask(() => this.debug.waitElementVisible(oAuthItem, 2000).catch(() => this.runner.returnTo('createClient')));
this.runner.createTask(() => this.debug.click(oAuthItem));
this.runner.createTask(() => this.debug.waitElementVisible(webInput));
this.runner.createTask(() => this.debug.click(webInput));
Expand Down
9 changes: 9 additions & 0 deletions src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface AccountSetupState {
}

export interface AppState {
devMode: boolean;
selectedAccount: {
account: AdMobAccount;
}
Expand All @@ -60,6 +61,7 @@ type AccountID = string;
export class Store {

@observable readonly state: AppState = {
devMode: !!environment.development,
selectedAccount: {
account: null
},
Expand Down Expand Up @@ -89,6 +91,8 @@ export class Store {
switch (action.type) {
case ActionTypes.getStore:
return this.emitState();
case ActionTypes.toggleDevMode:
return this.toggleDevMode();
}
});
observe(this.state, () => this.emitState());
Expand Down Expand Up @@ -537,4 +541,9 @@ Do you what to add new Account (${resultAccount.email})?`
}));
}

@action
toggleDevMode () {
set<AppState>(this.state, 'devMode', !this.state.devMode);
}

}
2 changes: 2 additions & 0 deletions src/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum ActionTypes {
adMobSetupAccount = 'adMobSetupAccount',
adMobSetupState = 'adMobSetupState',
adMobCancelSetup = 'adMobCancelSetup',
adMobShowSetup = 'adMobShowSetup',
runSync = 'RunSync',
openAdmobPage = 'openAdmobPage',
selectAccount = 'selectAdmobAccount',
Expand All @@ -22,6 +23,7 @@ export enum ActionTypes {
openLogFile = 'openLogFile',
submitLogToAppodeal = 'submitLogToAppodeal',
getStore = 'getStore',
toggleDevMode = 'toggleDevMode',
checkUpdates = 'checkUpdates',
downloadDist = 'downloadDist',
getDist = 'getDist',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function AdMobAccountSetup ({setupProgress, setupState, account, appodeal
{(visible || !account.isReadyForReports) && <div className={style.setupRequired}>
<h1>
Setup is required
{DEV_MODE && isSetupStarted(setupState) &&
<button type="button" onClick={() => showDebugWindow(account)}>Toggle setup window</button>}
{(account.isReadyForReports || isSetupStarted(setupState)) &&
<button type="button" onClick={() => closeSetup(account)}>{
isSetupStarted(setupState) ? 'Cancel' : 'Close'
Expand Down Expand Up @@ -151,3 +153,9 @@ function viewTutorial (event: React.MouseEvent) {
event.preventDefault();
sendToMain('accounts', action(ActionTypes.adMobSetupTutorial));
}

function showDebugWindow (adMobAccount: AdMobAccount) {
sendToMain('accounts', action(ActionTypes.adMobShowSetup, {
adMobAccount
}));
}
2 changes: 1 addition & 1 deletion src/ui/components/admob-account/AdmobAccountComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class AdmobAccountComponent extends Component<AdmobAccountComponentProps,
<div>
{
// make public when open admob safe browsing admob is implemented
environment.development &&
DEV_MODE &&
<div style={{marginBottom: '10px'}}>
<button type="button" onClick={singleEvent(this.openAdMob, this)}>Open Admob (For developers only)</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/root/RootComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RootComponent extends React.Component<RootComponentProps, RootCompo
tab: this.tabs[0].id
};

if (environment.development) {
if (DEV_MODE) {
this.tabs.push({id: 'development', label: 'Development', isDisabled: () => false});
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/ui/settings/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Sentry from '@sentry/browser';
import {AppState} from 'core/store';
import {remote} from 'electron';
import {action, ActionTypes} from 'lib/actions';
import {onMessageFromMain, sendToMain} from 'lib/messages';
Expand All @@ -10,8 +11,18 @@ import '../style.scss';
import './settings.scss';


document.addEventListener('keydown', (event: KeyboardEvent) => {
if (event.key.toLowerCase() === 'd' && (event.metaKey || event.ctrlKey) && event.shiftKey) {
sendToMain('store', action(ActionTypes.toggleDevMode))
.then(() => {
location.reload();
});
}
});

onMessageFromMain<string>('store', storeJSON => {
let store = JSON.parse(storeJSON);
let store = JSON.parse(storeJSON) as AppState;
window['DEV_MODE'] = store.devMode;
ReactDOM.render(<RootComponent store={store}/>, document.getElementById('content'));
});
sendToMain('store', action(ActionTypes.getStore));
Expand Down
2 changes: 2 additions & 0 deletions typings/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ declare interface Environment {
}

declare const environment: Environment;

declare const DEV_MODE: boolean;

0 comments on commit f3c9597

Please sign in to comment.