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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
24 additions and
8 deletions
-
src/actions/accounts.js
-
src/index.ejs
-
src/renderer/events.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 } |
|
|
|
|
|
@ -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 }) |
|
|
|
} |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
|
|
@ -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__) { |
|
|
|