Store actions: Rename createEntries -> addEntries.

master
Tom Hacohen 6 years ago
parent 49273fbc6f
commit 9b7f24eb8a

@ -1,7 +1,7 @@
import * as EteSync from './api/EteSync'; import * as EteSync from './api/EteSync';
import { CredentialsData, UserInfoData } from './store'; import { CredentialsData, UserInfoData } from './store';
import { createEntries } from './store/actions'; import { addEntries } from './store/actions';
export function createJournalEntry( export function createJournalEntry(
etesync: CredentialsData, etesync: CredentialsData,
@ -30,5 +30,5 @@ export function createJournalEntry(
const entry = new EteSync.Entry(); const entry = new EteSync.Entry();
entry.setSyncEntry(cryptoManager, syncEntry, prevUid); entry.setSyncEntry(cryptoManager, syncEntry, prevUid);
return createEntries(etesync, journal.uid, [entry], prevUid); return addEntries(etesync, journal.uid, [entry], prevUid);
} }

@ -96,7 +96,7 @@ export const deleteJournal = createAction(
} }
); );
export const { fetchEntries, createEntries } = createActions({ export const { fetchEntries, addEntries } = createActions({
FETCH_ENTRIES: [ FETCH_ENTRIES: [
(etesync: CredentialsData, journalUid: string, prevUid: string | null) => { (etesync: CredentialsData, journalUid: string, prevUid: string | null) => {
const creds = etesync.credentials; const creds = etesync.credentials;
@ -109,7 +109,7 @@ export const { fetchEntries, createEntries } = createActions({
return { journal: journalUid, prevUid }; return { journal: journalUid, prevUid };
}, },
], ],
CREATE_ENTRIES: [ ADD_ENTRIES: [
(etesync: CredentialsData, journalUid: string, newEntries: EteSync.Entry[], prevUid: string | null) => { (etesync: CredentialsData, journalUid: string, newEntries: EteSync.Entry[], prevUid: string | null) => {
const creds = etesync.credentials; const creds = etesync.credentials;
const apiBase = etesync.serviceApiUrl; const apiBase = etesync.serviceApiUrl;

@ -1,4 +1,4 @@
import { createEntries, fetchEntries } from './actions'; import { addEntries, fetchEntries } from './actions';
import { entries, EntriesTypeImmutable } from './reducers'; import { entries, EntriesTypeImmutable } from './reducers';
import { Map } from 'immutable'; import { Map } from 'immutable';
@ -43,7 +43,7 @@ it('Entries reducer', () => {
expect(journal.value.size).toBe(2); expect(journal.value.size).toBe(2);
// Creating entries should also work the same // Creating entries should also work the same
action.type = createEntries.toString(); action.type = addEntries.toString();
state = entries(state, action as any); state = entries(state, action as any);
journal = state.get(jId) as any; journal = state.get(jId) as any;
expect(journal.value.size).toBe(3); expect(journal.value.size).toBe(3);

@ -203,7 +203,7 @@ function fetchCreateEntriesReducer(state: EntriesTypeImmutable, action: any) {
export const entries = handleActions( export const entries = handleActions(
{ {
[actions.fetchEntries.toString()]: fetchCreateEntriesReducer, [actions.fetchEntries.toString()]: fetchCreateEntriesReducer,
[actions.createEntries.toString()]: fetchCreateEntriesReducer, [actions.addEntries.toString()]: fetchCreateEntriesReducer,
[actions.addJournal.toString()]: (state: EntriesTypeImmutable, action: any) => { [actions.addJournal.toString()]: (state: EntriesTypeImmutable, action: any) => {
const journal = action.meta.item.uid; const journal = action.meta.item.uid;
const prevState = state.get(journal); const prevState = state.get(journal);

Loading…
Cancel
Save