import { API } from 'api' export class Sync { static async tree() { let oldMax = 0 nodeStore.getAppState('latest_sync') .then(state => { if (state !== null) { oldMax = state.value return state.value } return 0 }) .then(sequence => API.query('POST', `/node/tree/${sequence}`, {})) .then(res => nodeStore.updateTreeRecords(res.Nodes)) .then(newMax => nodeStore.setAppState('latest_sync', Math.max(oldMax, newMax))) .catch(e => alert(e)) } }