Skip to content

Commit 061f731

Browse files
arthurdennerCompuIves
authored andcommitted
fix(profile): Update sandboxes count after delete (codesandbox#1163)
* chore: Renaming variable and property used to delete a sandbox * fix(profile): Updating the sandboxes count after deleting a sandbox
1 parent c43717a commit 061f731

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

packages/app/src/app/pages/Profile/Sandboxes/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class Sandboxes extends React.Component {
5858
return Math.ceil(givenLikeCount / PER_PAGE_COUNT);
5959
};
6060

61-
deleteSandbox = index => {
62-
this.props.signals.profile.deleteSandboxClicked({ index });
61+
deleteSandbox = id => {
62+
this.props.signals.profile.deleteSandboxClicked({ id });
6363
};
6464

6565
render() {
@@ -82,8 +82,12 @@ class Sandboxes extends React.Component {
8282
<div>
8383
{isProfileCurrentUser && (
8484
<Notice>
85-
You{"'"}re viewing your own profile, so you can see your private and
86-
unlisted sandboxes. Others can{"'"}t.
85+
You
86+
{"'"}
87+
re viewing your own profile, so you can see your private and
88+
unlisted sandboxes. Others can
89+
{"'"}
90+
t.
8791
</Notice>
8892
)}
8993
<SandboxList

packages/app/src/app/store/modules/profile/actions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export function getUser({ api, props }) {
44

55
export function deleteSandbox({ api, state }) {
66
const sandboxId = state.get(`profile.sandboxToDeleteId`);
7+
const sandboxCount = state.get('profile.current.sandboxCount');
78

89
return api
910
.request({
@@ -13,7 +14,9 @@ export function deleteSandbox({ api, state }) {
1314
id: sandboxId,
1415
},
1516
})
16-
.then(() => state.set(`profile.current.sandboxCount - 1`));
17+
.then(() => {
18+
state.set(`profile.current.sandboxCount`, sandboxCount - 1);
19+
});
1720
}
1821

1922
export function getAllUserSandboxes({ api }) {

packages/app/src/app/store/modules/profile/sequences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const getShowcasedSandbox = sequence('getShowcasedSandbox', [
2222
]);
2323

2424
export const showDeleteSandboxModal = [
25-
set(state`profile.sandboxToDeleteId`, props`index`),
25+
set(state`profile.sandboxToDeleteId`, props`id`),
2626
set(state`currentModal`, 'deleteProfileSandbox'),
2727
];
2828

0 commit comments

Comments
 (0)