Skip to content

Commit

Permalink
Update spec and use promise.all instead of promise.allSettled
Browse files Browse the repository at this point in the history
  • Loading branch information
coskucinkilic committed Oct 1, 2024
1 parent d7eee5d commit fb0d26c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions frontend/src/lib/services/neurons.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ export const changeNeuronVisibility = async ({
neurons: NeuronInfo[];
makePublic: boolean;
}): Promise<{ success: boolean }> => {
const results = await Promise.allSettled(
const results = await Promise.all(
neurons.map(async (neuron) => {
try {
const identity: Identity = await getIdentityOfControllerByNeuronId(
Expand All @@ -1046,9 +1046,7 @@ export const changeNeuronVisibility = async ({
})
);

const failedCount = results.filter(
(result) => result.status === "rejected" || result.value === false
).length;
const failedCount = results.filter((result) => result === false).length;

if (failedCount === 0) {
return { success: true };
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tests/lib/services/neurons.services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@ describe("neurons-services", () => {
expect(spyChangeNeuronVisibility).toBeCalledTimes(2);
expect(spyGetNeuron).toBeCalledTimes(1);
expectToastError(
'1 of 2 neurons failed to update. Please try again later. You can always change neuron visibility settings under "Advanced Details & Settings".'
'1 out of 2 neurons have failed to update their visibility, please try again later. You can always change neuron visibility under "Advanced Details & Settings".'
);
});

Expand All @@ -1942,7 +1942,7 @@ describe("neurons-services", () => {
expect(spyChangeNeuronVisibility).toBeCalledTimes(1);
expect(spyGetNeuron).not.toBeCalled();
expectToastError(
'All neurons have failed to update their visibility. Please try again later. You can always change neuron visibility settings under "Advanced Details & Settings".'
'Your neurons have failed to update their visibility, please try again later. You can always change neuron visibility under "Advanced Details & Settings".'
);
});

Expand Down

0 comments on commit fb0d26c

Please sign in to comment.