Browse Source

Don't sync if we don't have accounts

master
Loëck Vézien 7 years ago
parent
commit
36654c9417
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 9
      src/actions/accounts.js
  2. 17
      src/index.ejs
  3. 6
      src/renderer/events.js

9
src/actions/accounts.js

@ -6,6 +6,8 @@ import sortBy from 'lodash/sortBy'
import type { Dispatch } from 'redux' import type { Dispatch } from 'redux'
import type { Account } from 'types/common' import type { Account } from 'types/common'
import { startSyncAccounts } from 'renderer/events'
function sortAccounts(accounts, orderAccounts) { function sortAccounts(accounts, orderAccounts) {
const accountsSorted = sortBy(accounts, a => { const accountsSorted = sortBy(accounts, a => {
if (orderAccounts === 'balance') { if (orderAccounts === 'balance') {
@ -36,12 +38,17 @@ export const updateOrderAccounts: UpdateOrderAccounts = (orderAccounts: string)
export type AddAccount = Account => (Function, Function) => void export type AddAccount = Account => (Function, Function) => void
export const addAccount: AddAccount = payload => (dispatch, getState) => { export const addAccount: AddAccount = payload => (dispatch, getState) => {
const { settings: { orderAccounts } } = getState() const { settings: { orderAccounts }, accounts } = getState()
dispatch({ dispatch({
type: 'ADD_ACCOUNT', type: 'ADD_ACCOUNT',
payload, payload,
}) })
dispatch(updateOrderAccounts(orderAccounts)) 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 } export type RemoveAccount = Account => { type: string, payload: Account }

17
src/index.ejs

@ -45,7 +45,7 @@
position: fixed; position: fixed;
right: 0; right: 0;
top: 0; top: 0;
transition: opacity 0.6s ease-in-out; transition: opacity 0.4s ease-in-out;
z-index: 100; z-index: 100;
} }
#preload video { #preload video {
@ -81,11 +81,18 @@
const preloadEl = document.getElementById('preload') const preloadEl = document.getElementById('preload')
const appEl = document.getElementById('app') const appEl = document.getElementById('app')
const initApp = () => { const initApp = (options = {}) => {
const { force = false } = options
appEl.style.display = 'flex' 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') { if (name === 'MainWindow') {
@ -103,7 +110,7 @@
setTimeout(initApp, delay > 0 ? delay : 1) setTimeout(initApp, delay > 0 ? delay : 1)
} }
} else { } else {
initApp() initApp({ force: true })
} }
</script> </script>
</body> </body>

6
src/renderer/events.js

@ -179,8 +179,10 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => {
if (!locked && !DISABLED_SYNC) { if (!locked && !DISABLED_SYNC) {
const accounts = getAccounts(store.getState()) const accounts = getAccounts(store.getState())
// Start accounts sync // Start accounts sync only if we have accounts
startSyncAccounts(accounts) if (accounts.length > 0) {
startSyncAccounts(accounts)
}
} }
if (__PROD__) { if (__PROD__) {

Loading…
Cancel
Save