Browse Source

Merge pull request #136 from loeck/master

Don't sync if we don't have accounts
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
98fc65bb28
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/actions/accounts.js
  2. 13
      src/index.ejs
  3. 4
      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 }

13
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,12 +81,19 @@
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'
if (force) {
preloadEl.remove()
} else {
preloadEl.style.opacity = 0 preloadEl.style.opacity = 0
preloadEl.addEventListener('transitionend', () => preloadEl.remove()) preloadEl.addEventListener('transitionend', () => preloadEl.remove())
} }
}
if (name === 'MainWindow') { if (name === 'MainWindow') {
preloadEl.style.display = 'flex' preloadEl.style.display = 'flex'
@ -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>

4
src/renderer/events.js

@ -179,9 +179,11 @@ 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
if (accounts.length > 0) {
startSyncAccounts(accounts) startSyncAccounts(accounts)
} }
}
if (__PROD__) { if (__PROD__) {
// Start check of eventual updates // Start check of eventual updates

Loading…
Cancel
Save