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) => {
|
export const markPostRead = (post, token) => {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const { rules } = getState();
|
const { rules } = getState();
|
||||||
|
const { selected } = getState();
|
||||||
|
|
||||||
const url = `/api/posts/${post.id}/`;
|
const url = `/api/posts/${post.id}/`;
|
||||||
const options = {
|
const options = {
|
||||||
|
|
@ -38,10 +39,7 @@ export const markPostRead = (post, token) => {
|
||||||
body: JSON.stringify({ read: true }),
|
body: JSON.stringify({ read: true }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const section = {
|
const section = { ...selected.item };
|
||||||
...rules.items[post.rule],
|
|
||||||
type: RULE_TYPE,
|
|
||||||
};
|
|
||||||
|
|
||||||
return fetch(url, options)
|
return fetch(url, options)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,16 @@ export const categories = (state = { ...defaultState }, action) => {
|
||||||
isFetching: true,
|
isFetching: true,
|
||||||
};
|
};
|
||||||
case MARK_POST_READ:
|
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 {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export const rules = (state = { ...defaultState }, action) => {
|
||||||
isFetching: false,
|
isFetching: false,
|
||||||
};
|
};
|
||||||
case MARK_POST_READ:
|
case MARK_POST_READ:
|
||||||
const rule = { ...state.items[action.section.id] };
|
const rule = { ...state.items[action.post.rule] };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue