Adding exclusive lists feature

Major new feature, currently testing in a branch right now. Fixes #1
This commit is contained in:
Darius Kazemi
2019-07-26 01:51:20 -07:00
parent dc15521b3a
commit bfc0fbab2c
14 changed files with 76 additions and 23 deletions

View File

@ -10,9 +10,10 @@ export const LISTS_FETCH_REQUEST = 'LISTS_FETCH_REQUEST';
export const LISTS_FETCH_SUCCESS = 'LISTS_FETCH_SUCCESS';
export const LISTS_FETCH_FAIL = 'LISTS_FETCH_FAIL';
export const LIST_EDITOR_TITLE_CHANGE = 'LIST_EDITOR_TITLE_CHANGE';
export const LIST_EDITOR_RESET = 'LIST_EDITOR_RESET';
export const LIST_EDITOR_SETUP = 'LIST_EDITOR_SETUP';
export const LIST_EDITOR_TITLE_CHANGE = 'LIST_EDITOR_TITLE_CHANGE';
export const LIST_EDITOR_IS_EXCLUSIVE_CHANGE = 'LIST_EDITOR_IS_EXCLUSIVE_CHANGE';
export const LIST_EDITOR_RESET = 'LIST_EDITOR_RESET';
export const LIST_EDITOR_SETUP = 'LIST_EDITOR_SETUP';
export const LIST_CREATE_REQUEST = 'LIST_CREATE_REQUEST';
export const LIST_CREATE_SUCCESS = 'LIST_CREATE_SUCCESS';
@ -100,13 +101,14 @@ export const fetchListsFail = error => ({
});
export const submitListEditor = shouldReset => (dispatch, getState) => {
const listId = getState().getIn(['listEditor', 'listId']);
const title = getState().getIn(['listEditor', 'title']);
const listId = getState().getIn(['listEditor', 'listId']);
const title = getState().getIn(['listEditor', 'title']);
const isExclusive = getState().getIn(['listEditor', 'isExclusive']);
if (listId === null) {
dispatch(createList(title, shouldReset));
} else {
dispatch(updateList(listId, title, shouldReset));
dispatch(updateList(listId, title, shouldReset, isExclusive));
}
};
@ -124,6 +126,11 @@ export const changeListEditorTitle = value => ({
value,
});
export const changeListEditorIsExclusive = value => ({
type: LIST_EDITOR_IS_EXCLUSIVE_CHANGE,
value,
});
export const createList = (title, shouldReset) => (dispatch, getState) => {
dispatch(createListRequest());
@ -150,10 +157,10 @@ export const createListFail = error => ({
error,
});
export const updateList = (id, title, shouldReset) => (dispatch, getState) => {
export const updateList = (id, title, shouldReset, isExclusive) => (dispatch, getState) => {
dispatch(updateListRequest(id));
api(getState).put(`/api/v1/lists/${id}`, { title }).then(({ data }) => {
api(getState).put(`/api/v1/lists/${id}`, { title, is_exclusive: !!isExclusive }).then(({ data }) => {
dispatch(updateListSuccess(data));
if (shouldReset) {