client/src/selectors/syncSelectors.js
author ymh <ymh.work@gmail.com>
Mon, 08 Oct 2018 18:35:47 +0200
changeset 168 ea92f4fe783d
parent 134 be36eed5e6e0
permissions -rw-r--r--
- move SlateEditor and dependencies to its own folder - remove Immutable - remove redux-persist-immutable - remobe redux-immutable - update libraries - added tests on store manipulations (accessor and reducers)

// selectors linked to syncronization status
import * as R from 'ramda';

import { ActionEnum } from '../constants';

export const getLastSync = R.pathOr(0, ['authStatus', 'lastSync']);

export const isSynchronizing = R.path(['status', 'isSynchronizing']);

const isAllActionNone = R.all(R.propEq('action', ActionEnum.NONE))
const notesIsAllActionNone = R.compose(isAllActionNone, R.prop('notes'));
const sessionsIsAllActionNone = R.compose(isAllActionNone, R.prop('sessions'));

export const isSynchronized = R.converge(R.and, [notesIsAllActionNone, sessionsIsAllActionNone])

// export const isSynchronized = state =>
//     state['notes'].every((n) => n['action']===ActionEnum.NONE) &&
//     state['sessions'].every((n) => n['action']===ActionEnum.NONE)