|
|
@ -138,31 +138,62 @@ export const entries = handleAction(
|
|
|
|
Map({})
|
|
|
|
Map({})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const journals = handleAction(
|
|
|
|
const journals = handleActions(
|
|
|
|
actions.fetchJournals,
|
|
|
|
{
|
|
|
|
(state: JournalsTypeImmutable, action: any) => {
|
|
|
|
[actions.fetchJournals.toString()]: (state: JournalsTypeImmutable, action: any) => {
|
|
|
|
const newState = fetchTypeIdentityReducer(state, action);
|
|
|
|
const newState = fetchTypeIdentityReducer(state, action);
|
|
|
|
// Compare the states and see if they are really different
|
|
|
|
// Compare the states and see if they are really different
|
|
|
|
const oldJournals = state.get('value', null);
|
|
|
|
const oldJournals = state.get('value', null);
|
|
|
|
const newJournals = newState.get('value', null);
|
|
|
|
const newJournals = newState.get('value', null);
|
|
|
|
|
|
|
|
|
|
|
|
if (!oldJournals || !newJournals || (oldJournals.size !== newJournals.size)) {
|
|
|
|
if (!oldJournals || !newJournals || (oldJournals.size !== newJournals.size)) {
|
|
|
|
return newState;
|
|
|
|
return newState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let oldJournalHash = {};
|
|
|
|
let oldJournalHash = {};
|
|
|
|
oldJournals.forEach((x) => {
|
|
|
|
oldJournals.forEach((x) => {
|
|
|
|
oldJournalHash[x.uid] = x.serialize();
|
|
|
|
oldJournalHash[x.uid] = x.serialize();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (newJournals.every((journal: EteSync.Journal) => (
|
|
|
|
if (newJournals.every((journal: EteSync.Journal) => (
|
|
|
|
(journal.uid in oldJournalHash) &&
|
|
|
|
(journal.uid in oldJournalHash) &&
|
|
|
|
(journal.serialize().content === oldJournalHash[journal.uid].content)
|
|
|
|
(journal.serialize().content === oldJournalHash[journal.uid].content)
|
|
|
|
))) {
|
|
|
|
))) {
|
|
|
|
return state;
|
|
|
|
return state;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return newState;
|
|
|
|
return newState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
[actions.createJournal.toString()]: (state: JournalsTypeImmutable, _action: any) => {
|
|
|
|
|
|
|
|
const action = { ..._action };
|
|
|
|
|
|
|
|
if (action.payload) {
|
|
|
|
|
|
|
|
action.payload = (action.meta === undefined) ? action.payload : action.meta.journal;
|
|
|
|
|
|
|
|
action.payload = [ action.payload ];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const newState = fetchTypeIdentityReducer(state, action, true);
|
|
|
|
|
|
|
|
// Compare the states and see if they are really different
|
|
|
|
|
|
|
|
const oldJournals = state.get('value', null);
|
|
|
|
|
|
|
|
const newJournals = newState.get('value', null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!oldJournals || !newJournals || (oldJournals.size !== newJournals.size)) {
|
|
|
|
|
|
|
|
return newState;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let oldJournalHash = {};
|
|
|
|
|
|
|
|
oldJournals.forEach((x) => {
|
|
|
|
|
|
|
|
oldJournalHash[x.uid] = x.serialize();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newJournals.every((journal: EteSync.Journal) => (
|
|
|
|
|
|
|
|
(journal.uid in oldJournalHash) &&
|
|
|
|
|
|
|
|
(journal.serialize().content === oldJournalHash[journal.uid].content)
|
|
|
|
|
|
|
|
))) {
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return newState;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new JournalsFetchRecord(),
|
|
|
|
new JournalsFetchRecord(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|