Commiting

This commit is contained in:
mgabdev
2020-11-15 12:48:32 -06:00
parent 62515bbaee
commit fb612f60c8
1011 changed files with 3507 additions and 49604 deletions

View File

@@ -13,116 +13,104 @@ export const SHORTCUTS_REMOVE_REQUEST = 'SHORTCUTS_REMOVE_REQUEST'
export const SHORTCUTS_REMOVE_SUCCESS = 'SHORTCUTS_REMOVE_SUCCESS'
export const SHORTCUTS_REMOVE_FAIL = 'SHORTCUTS_REMOVE_FAIL'
export function fetchShortcuts() {
return (dispatch, getState) => {
if (!me) return
/**
*
*/
export const fetchShortcuts = () => (dispatch, getState) => {
if (!me) return
const isFetched = getState().getIn(['shortcuts', 'isFetched'], false)
if (isFetched) return
dispatch(fetchShortcutsRequest())
dispatch(fetchShortcutsRequest())
api(getState).get('/api/v1/shortcuts').then(response => {
dispatch(fetchShortcutsSuccess(response.data))
}).catch(error => dispatch(fetchShortcutsFail(error)))
}
api(getState).get('/api/v1/shortcuts').then(response => {
dispatch(fetchShortcutsSuccess(response.data))
}).catch(error => dispatch(fetchShortcutsFail(error)))
}
export function fetchShortcutsRequest() {
return {
type: SHORTCUTS_FETCH_REQUEST,
}
const fetchShortcutsRequest = () => ({
type: SHORTCUTS_FETCH_REQUEST,
})
const fetchShortcutsSuccess = (shortcuts) => ({
type: SHORTCUTS_FETCH_SUCCESS,
shortcuts,
})
const fetchShortcutsFail = (error) => ({
type: SHORTCUTS_FETCH_FAIL,
error,
})
/**
*
*/
export const addShortcut = (shortcutType, shortcutId) => (dispatch, getState) => {
if (!me) return
dispatch(addShortcutsRequest())
api(getState).post('/api/v1/shortcuts', {
shortcut_type: shortcutType,
shortcut_id: shortcutId,
}).then(response => {
dispatch(addShortcutsSuccess(response.data))
}).catch(error => dispatch(addShortcutsFail(error)))
}
export function fetchShortcutsSuccess(shortcuts) {
return {
shortcuts,
type: SHORTCUTS_FETCH_SUCCESS,
}
}
const addShortcutsRequest = () => ({
type: SHORTCUTS_ADD_REQUEST,
})
export function fetchShortcutsFail(error) {
return {
error,
type: SHORTCUTS_FETCH_FAIL,
}
}
const addShortcutsSuccess = (shortcut) => ({
type: SHORTCUTS_ADD_SUCCESS,
shortcut,
})
export function addShortcut(shortcutType, shortcutId) {
return (dispatch, getState) => {
if (!me) return
const addShortcutsFail = (error) => ({
type: SHORTCUTS_ADD_FAIL,
error,
})
dispatch(addShortcutsRequest())
api(getState).post('/api/v1/shortcuts', {
shortcut_type: shortcutType,
shortcut_id: shortcutId,
}).then(response => {
dispatch(addShortcutsSuccess(response.data))
}).catch(error => dispatch(addShortcutsFail(error)))
}
}
export function addShortcutsRequest() {
return {
type: SHORTCUTS_ADD_REQUEST,
}
}
export function addShortcutsSuccess(shortcut) {
return {
shortcut,
type: SHORTCUTS_ADD_SUCCESS,
}
}
export function addShortcutsFail(error) {
return {
error,
type: SHORTCUTS_ADD_FAIL,
}
}
export function removeShortcut(shortcutObjectId, shortcutType, shortcutId) {
return (dispatch, getState) => {
if (!me) return
let id
if (shortcutObjectId) {
id = shortcutObjectId
} else if (shortcutType && shortcutId) {
const shortcuts = getState().getIn(['shortcuts', 'items'])
const shortcut = shortcuts.find((s) => {
return s.get('shortcut_id') == shortcutId && s.get('shortcut_type') === shortcutType
})
if (!!shortcut) {
id = shortcut.get('id')
}
/**
*
*/
export const removeShortcut = (shortcutObjectId, shortcutType, shortcutId) => (dispatch, getState) => {
if (!me) return
let id
if (shortcutObjectId) {
id = shortcutObjectId
} else if (shortcutType && shortcutId) {
const shortcuts = getState().getIn(['shortcuts', 'items'])
const shortcut = shortcuts.find((s) => {
return s.get('shortcut_id') == shortcutId && s.get('shortcut_type') === shortcutType
})
if (!!shortcut) {
id = shortcut.get('id')
}
if (!id) return
dispatch(removeShortcutsRequest())
api(getState).delete(`/api/v1/shortcuts/${id}`).then(response => {
dispatch(removeShortcutsSuccess(response.data.id))
}).catch(error => dispatch(removeShortcutsFail(error)))
}
if (!id) return
dispatch(removeShortcutsRequest())
api(getState).delete(`/api/v1/shortcuts/${id}`).then(response => {
dispatch(removeShortcutsSuccess(response.data.id))
}).catch(error => dispatch(removeShortcutsFail(error)))
}
export function removeShortcutsRequest() {
return {
type: SHORTCUTS_REMOVE_REQUEST,
}
}
const removeShortcutsRequest = () => ({
type: SHORTCUTS_REMOVE_REQUEST,
})
export function removeShortcutsSuccess(shortcutId) {
return {
shortcutId,
type: SHORTCUTS_REMOVE_SUCCESS,
}
}
const removeShortcutsSuccess = (shortcutId) => ({
type: SHORTCUTS_REMOVE_SUCCESS,
shortcutId,
})
export function removeShortcutsFail(error) {
return {
error,
type: SHORTCUTS_REMOVE_FAIL,
}
}
const removeShortcutsFail = (error) => ({
type: SHORTCUTS_REMOVE_FAIL,
error,
})