0.2.3 #99
3 changed files with 13 additions and 6 deletions
|
|
@ -27,6 +27,7 @@ export const postRead = (post, section) => ({
|
|||
export const markPostRead = (post, token) => {
|
||||
return (dispatch, getState) => {
|
||||
const { rules } = getState();
|
||||
const { selected } = getState();
|
||||
|
||||
const url = `/api/posts/${post.id}/`;
|
||||
const options = {
|
||||
|
|
@ -38,10 +39,7 @@ export const markPostRead = (post, token) => {
|
|||
body: JSON.stringify({ read: true }),
|
||||
};
|
||||
|
||||
const section = {
|
||||
...rules.items[post.rule],
|
||||
type: RULE_TYPE,
|
||||
};
|
||||
const section = { ...selected.item };
|
||||
|
||||
return fetch(url, options)
|
||||
.then(response => response.json())
|
||||
|
|
|
|||
|
|
@ -46,7 +46,16 @@ export const categories = (state = { ...defaultState }, action) => {
|
|||
isFetching: true,
|
||||
};
|
||||
case MARK_POST_READ:
|
||||
let category = { ...state.items[action.section.category] };
|
||||
let category = {};
|
||||
|
||||
switch (action.section.type) {
|
||||
case CATEGORY_TYPE:
|
||||
category = { ...state.items[action.section.id] };
|
||||
break;
|
||||
case RULE_TYPE:
|
||||
category = { ...state.items[action.section.category] };
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export const rules = (state = { ...defaultState }, action) => {
|
|||
isFetching: false,
|
||||
};
|
||||
case MARK_POST_READ:
|
||||
const rule = { ...state.items[action.section.id] };
|
||||
const rule = { ...state.items[action.post.rule] };
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue