Skip to content

Commit

Permalink
refactor(dcellar-web-ui): rename variable from _path to _completeComm…
Browse files Browse the repository at this point in the history
…onPrefix
  • Loading branch information
devinxl committed Apr 10, 2024
1 parent 4c42da6 commit 847b10d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/dcellar-web-ui/src/store/slices/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,18 @@ export const setupDummyFolder =
};

export const setupListObjects =
(params: Partial<ListObjectsParams>, _path?: string) =>
(params: Partial<ListObjectsParams>, _completeCommonPrefix?: string) =>
async (dispatch: AppDispatch, getState: GetState) => {
const { objectCommonPrefix, currentBucketName, completeCommonPrefix, objectListPageRestored } =
getState().object;
const { loginAccount: address } = getState().persist;
const _query = new URLSearchParams(params.query?.toString() || '');
_query.append('max-keys', '1000');
_query.append('delimiter', '/');
const prefix = _path ? _path.split('/').slice(1).join('/') : objectCommonPrefix;
if (prefix) _query.append('prefix', prefix);
const commonPrefix = _completeCommonPrefix
? _completeCommonPrefix.split('/').slice(1).join('/')
: objectCommonPrefix;
if (commonPrefix) _query.append('prefix', commonPrefix);
// support any path list objects, bucketName & _path
const payload = {
bucketName: currentBucketName,
Expand All @@ -502,8 +504,10 @@ export const setupListObjects =
toast.error({ description: error });
return;
}
dispatch(setObjectListTruncated({ path: _path || completeCommonPrefix, truncate }));
dispatch(setObjectList({ path: _path || completeCommonPrefix, list: res! }));
dispatch(
setObjectListTruncated({ path: _completeCommonPrefix || completeCommonPrefix, truncate }),
);
dispatch(setObjectList({ path: _completeCommonPrefix || completeCommonPrefix, list: res! }));
dispatch(setObjectListPageRestored(true));
if (!objectListPageRestored) {
dispatch(setObjectListPage({ path: completeCommonPrefix, current: 0 }));
Expand Down

0 comments on commit 847b10d

Please sign in to comment.