client/src/selectors/syncSelectors.js
author ymh <ymh.work@gmail.com>
Fri, 30 Nov 2018 10:53:15 +0100
changeset 183 f8f3af9e5c83
parent 168 ea92f4fe783d
permissions -rw-r--r--
Change the settings to avoid using Session authentication for rest framework as it raise exceptions in case client and backend are on the same domain On the filter, adapt to take into account new version of django_filters
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
134
be36eed5e6e0 add menu to change current group and create a new group
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
// selectors linked to syncronization status
168
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
     2
import * as R from 'ramda';
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
     3
134
be36eed5e6e0 add menu to change current group and create a new group
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
import { ActionEnum } from '../constants';
be36eed5e6e0 add menu to change current group and create a new group
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
168
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
     6
export const getLastSync = R.pathOr(0, ['authStatus', 'lastSync']);
134
be36eed5e6e0 add menu to change current group and create a new group
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
168
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
     8
export const isSynchronizing = R.path(['status', 'isSynchronizing']);
134
be36eed5e6e0 add menu to change current group and create a new group
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
168
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    10
const isAllActionNone = R.all(R.propEq('action', ActionEnum.NONE))
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    11
const notesIsAllActionNone = R.compose(isAllActionNone, R.prop('notes'));
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    12
const sessionsIsAllActionNone = R.compose(isAllActionNone, R.prop('sessions'));
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    13
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    14
export const isSynchronized = R.converge(R.and, [notesIsAllActionNone, sessionsIsAllActionNone])
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    15
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    16
// export const isSynchronized = state =>
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    17
//     state['notes'].every((n) => n['action']===ActionEnum.NONE) &&
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents: 134
diff changeset
    18
//     state['sessions'].every((n) => n['action']===ActionEnum.NONE)