Skip to content

Commit

Permalink
Merge pull request #245 from node-real/fix/bucket-meta-field-type
Browse files Browse the repository at this point in the history
fix: primary id type compare
  • Loading branch information
aiden-cao authored Nov 3, 2023
2 parents ca644ac + 4904c02 commit 8bb8d86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions apps/dcellar-web-ui/src/store/slices/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const bucketSlice = createSlice({
const info = state.bucketInfo[bucketName];
const newInfo = {
...info,
...bucket
...bucket,
};
state.bucketInfo[bucketName] = newInfo;
state.owner = address === newInfo.Owner;
Expand Down Expand Up @@ -118,11 +118,11 @@ export const selectHasDiscontinue = (address: string) => (root: AppState) =>

export const setupBucket =
(bucketName: string, address?: string) => async (dispatch: AppDispatch, getState: GetState) => {
const [res, error] = await getUserBucketMeta(bucketName, '')
const [res, error] = await getUserBucketMeta(bucketName, '');
if (error || isEmpty(res?.body)) return 'Bucket no exist';
const bucket = {
...res?.body?.GfSpGetBucketMetaResponse.Bucket,
...res?.body?.GfSpGetBucketMetaResponse.Bucket.BucketInfo
...res?.body?.GfSpGetBucketMetaResponse.Bucket.BucketInfo,
} as AllBucketInfo;
const { loginAccount } = getState().persist;
dispatch(setBucketInfo({ address: address || loginAccount, bucket: bucket }));
Expand Down Expand Up @@ -161,7 +161,7 @@ export const setupBuckets =

const bucketSpInfo = bucketList.map((b) => ({
bucketName: b.BucketInfo.BucketName,
sp: find<SpItem>(allSps, (sp) => sp.id === b.Vgf.PrimarySpId)!,
sp: find<SpItem>(allSps, (sp) => String(sp.id) === String(b.Vgf.PrimarySpId))!,
}));

dispatch(setPrimarySpInfos(bucketSpInfo));
Expand Down
4 changes: 2 additions & 2 deletions apps/dcellar-web-ui/src/store/slices/sp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const spSlice = createSlice({

export const selectBucketSp = (bucket: AllBucketInfo) => (state: RootState) => {
const { allSps } = state.sp;
return find<SpItem>(allSps, (sp) => sp.id === bucket.Vgf.PrimarySpId);
return find<SpItem>(allSps, (sp) => String(sp.id) === String(bucket.Vgf.PrimarySpId));
};

export const { setStorageProviders, setPrimarySpInfo, setPrimarySpInfos, updateSps, setSpMeta } =
Expand Down Expand Up @@ -147,7 +147,7 @@ export const getPrimarySpInfo =
const [data, error] = await getVirtualGroupFamily({ familyId });
if (error) return null;
const sp = allSps.find(
(item) => item.id === data?.globalVirtualGroupFamily?.primarySpId,
(item) => String(item.id) === String(data?.globalVirtualGroupFamily?.primarySpId),
) as SpItem;
if (!sp) return null;
dispatch(setPrimarySpInfo({ bucketName, sp }));
Expand Down

0 comments on commit 8bb8d86

Please sign in to comment.