diff --git a/app/index.js b/app/index.js index 906c765..52aa38c 100644 --- a/app/index.js +++ b/app/index.js @@ -2,6 +2,7 @@ import { app, dialog, shell } from 'electron' import { autoUpdater } from 'electron-updater' import { join as pathJoin } from 'path' import pjson from '../package.json' +import Settings from 'electron-settings' import './report' import rootDir from 'app-root-dir' import setupTrayIcon from './setup-tray-icon' @@ -24,6 +25,7 @@ import { import LoadingWindow from './windows/Loading/window' import StorageWindow from './windows/Storage/window' +import WelcomeWindow from './windows/Welcome/window' // Let's create the main window app.mainWindow = null @@ -72,7 +74,18 @@ function askWhichNodeToUse (apiVersion) { return btnId === 1 } -app.on('ready', () => { +/** + * This method will: + * 1. setup the tray icon (except on macOS) + * 2. check for updates + * 3. show loading window + * 4. check if an API is already running + * 5. start the daemon if not + * 6. connect to the API + * 7. connect to the Siderus peers (and add them as bootstrap nodes) + * 8. show storage window + */ +function startOrion () { // On MacOS it's expected for the app not to close, and to re-open it from Launchpad if (process.platform !== 'darwin') { setupTrayIcon() @@ -238,6 +251,28 @@ app.on('ready', () => { app.quit() }) }) +} + +app.on('start-orion', () => { + startOrion() +}) + +app.on('ready', () => { + const userAgreement = Settings.getSync('userAgreement') + + if (userAgreement) { + startOrion() + } else { + // If the user did not accept our ToS, show the welcome window + const welcomeWindow = WelcomeWindow.create(app) + welcomeWindow.on('closed', () => { + // If the user did not accept ToS, but closed the welcome window, quit (don't run the the bg) + const userAgreement = Settings.getSync('userAgreement') + if (!userAgreement) { + app.quit() + } + }) + } }) app.on('activate', () => { diff --git a/app/windows/Welcome/Components/TermsOfServicePage.jsx b/app/windows/Welcome/Components/TermsOfServicePage.jsx new file mode 100644 index 0000000..56d7673 --- /dev/null +++ b/app/windows/Welcome/Components/TermsOfServicePage.jsx @@ -0,0 +1,89 @@ +import React from 'react' +import styled from 'styled-components' +import ToS from './ToS' +import { shell } from 'electron' + +import { + Window, + Content, + Toolbar, + Actionbar, + Button, + CheckBox +} from 'react-photonkit' + +const StyledContent = styled.div` + h1:first-child { + margin-top: 0px; + } +` + +const TermsSection = styled.section` + background: white; + height: calc(100vh - 250px); + overflow: auto; + padding: 0px 10px; +` + +const ToSLink = shell.openExternal('https://siderus.io/tos.html')} href='#'>Siderus Terms of Service +const PrivacyLink = shell.openExternal('https://siderus.io/privacy')} href='#'>Privacy policy +const checkboxLabel = I have read and I agree to {ToSLink} and {PrivacyLink} + +class TermsOfServicePage extends React.Component { + state = { + checked: false + } + + handleCheckChange = () => { + this.setState(prevState => ({ checked: !prevState.checked })) + } + + handleSubmit = (event) => { + event.preventDefault() + if (!this.state.checked) return + + this.props.onAccept() + } + + render () { + const { onQuit } = this.props + const { checked } = this.state + + return ( +
+ + + +

Terms of Service

+

In order to continue, you need to accept the Terms of Service:

+ + + + +
+
+ + +