diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..8a3ae17d7 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,4 @@ +{ + "asi": true, + "esnext": true +} diff --git a/browser/app/js/actions.js b/browser/app/js/actions.js index a39113dc6..7147ec0fe 100644 --- a/browser/app/js/actions.js +++ b/browser/app/js/actions.js @@ -26,6 +26,8 @@ export const SET_BUCKETS = 'SET_BUCKETS' export const ADD_BUCKET = 'ADD_BUCKET' export const SET_VISIBLE_BUCKETS = 'SET_VISIBLE_BUCKETS' export const SET_OBJECTS = 'SET_OBJECTS' +export const APPEND_OBJECTS = 'APPEND_OBJECTS' +export const RESET_OBJECTS = 'RESET_OBJECTS' export const SET_STORAGE_INFO = 'SET_STORAGE_INFO' export const SET_SERVER_INFO = 'SET_SERVER_INFO' export const SHOW_MAKEBUCKET_MODAL = 'SHOW_MAKEBUCKET_MODAL' @@ -240,15 +242,28 @@ export const setVisibleBuckets = visibleBuckets => { } } -export const setObjects = (objects, marker, istruncated) => { +const appendObjects = (objects, marker, istruncated) => { return { - type: SET_OBJECTS, + type: APPEND_OBJECTS, objects, marker, istruncated } } +export const setObjects = (objects) => { + return { + type: SET_OBJECTS, + objects, + } +} + +export const resetObjects = () => { + return { + type: RESET_OBJECTS + } +} + export const setCurrentBucket = currentBucket => { return { type: SET_CURRENT_BUCKET, @@ -316,7 +331,7 @@ export const listObjects = () => { object.name = object.name.replace(`${currentPath}`, ''); return object }) - dispatch(setObjects(objects, res.nextmarker, res.istruncated)) + dispatch(appendObjects(objects, res.nextmarker, res.istruncated)) dispatch(setPrefixWritable(res.writable)) dispatch(setLoadBucket('')) dispatch(setLoadPath('')) @@ -337,7 +352,7 @@ export const listObjects = () => { export const selectPrefix = prefix => { return (dispatch, getState) => { const {currentBucket, web} = getState() - dispatch(setObjects([], "", false)) + dispatch(resetObjects()) dispatch(setLoadPath(prefix)) web.ListObjects({ bucketName: currentBucket, @@ -352,7 +367,7 @@ export const selectPrefix = prefix => { object.name = object.name.replace(`${prefix}`, ''); return object }) - dispatch(setObjects( + dispatch(appendObjects( objects, res.nextmarker, res.istruncated diff --git a/browser/app/js/reducers.js b/browser/app/js/reducers.js index c8c21db9b..618dddacb 100644 --- a/browser/app/js/reducers.js +++ b/browser/app/js/reducers.js @@ -77,16 +77,18 @@ export default (state = { case actions.SET_CURRENT_BUCKET: newState.currentBucket = action.currentBucket break + case actions.APPEND_OBJECTS: + newState.objects = [...newState.objects, ...action.objects] + newState.marker = action.marker + newState.istruncated = action.istruncated + break case actions.SET_OBJECTS: - if (!action.objects.length) { - newState.objects = [] - newState.marker = "" - newState.istruncated = action.istruncated - } else { - newState.objects = [...action.objects] - newState.marker = action.marker - newState.istruncated = action.istruncated - } + newState.objects = [...action.objects] + break + case action.RESET_OBJECTS: + newState.objects = [] + newState.marker = "" + newState.istruncated = false break case actions.SET_CURRENT_PATH: newState.currentPath = action.currentPath diff --git a/hound.yml b/hound.yml new file mode 100644 index 000000000..f8d08d551 --- /dev/null +++ b/hound.yml @@ -0,0 +1,3 @@ +jshint: + enabled: false +