From 36654c941763e5f61de433990899b81a9b84be20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Thu, 15 Feb 2018 17:01:29 +0100 Subject: [PATCH] Don't sync if we don't have accounts --- src/actions/accounts.js | 9 ++++++++- src/index.ejs | 17 ++++++++++++----- src/renderer/events.js | 6 ++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/actions/accounts.js b/src/actions/accounts.js index 8820f771..e9cfb408 100644 --- a/src/actions/accounts.js +++ b/src/actions/accounts.js @@ -6,6 +6,8 @@ import sortBy from 'lodash/sortBy' import type { Dispatch } from 'redux' import type { Account } from 'types/common' +import { startSyncAccounts } from 'renderer/events' + function sortAccounts(accounts, orderAccounts) { const accountsSorted = sortBy(accounts, a => { if (orderAccounts === 'balance') { @@ -36,12 +38,17 @@ export const updateOrderAccounts: UpdateOrderAccounts = (orderAccounts: string) export type AddAccount = Account => (Function, Function) => void export const addAccount: AddAccount = payload => (dispatch, getState) => { - const { settings: { orderAccounts } } = getState() + const { settings: { orderAccounts }, accounts } = getState() dispatch({ type: 'ADD_ACCOUNT', payload, }) dispatch(updateOrderAccounts(orderAccounts)) + + // Start sync accounts the first time you add an account + if (accounts.length === 0) { + startSyncAccounts([payload]) + } } export type RemoveAccount = Account => { type: string, payload: Account } diff --git a/src/index.ejs b/src/index.ejs index 79ee58a7..00fa4d52 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -45,7 +45,7 @@ position: fixed; right: 0; top: 0; - transition: opacity 0.6s ease-in-out; + transition: opacity 0.4s ease-in-out; z-index: 100; } #preload video { @@ -81,11 +81,18 @@ const preloadEl = document.getElementById('preload') const appEl = document.getElementById('app') - const initApp = () => { + const initApp = (options = {}) => { + const { force = false } = options + appEl.style.display = 'flex' - preloadEl.style.opacity = 0 - preloadEl.addEventListener('transitionend', () => preloadEl.remove()) + if (force) { + preloadEl.remove() + } else { + preloadEl.style.opacity = 0 + + preloadEl.addEventListener('transitionend', () => preloadEl.remove()) + } } if (name === 'MainWindow') { @@ -103,7 +110,7 @@ setTimeout(initApp, delay > 0 ? delay : 1) } } else { - initApp() + initApp({ force: true }) } diff --git a/src/renderer/events.js b/src/renderer/events.js index 04172842..8c998f78 100644 --- a/src/renderer/events.js +++ b/src/renderer/events.js @@ -179,8 +179,10 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => { if (!locked && !DISABLED_SYNC) { const accounts = getAccounts(store.getState()) - // Start accounts sync - startSyncAccounts(accounts) + // Start accounts sync only if we have accounts + if (accounts.length > 0) { + startSyncAccounts(accounts) + } } if (__PROD__) {