Skip to content

Commit c104ea6

Browse files
authored
reset state when changing teams (codesandbox#4023)
1 parent aea223a commit c104ea6

File tree

1 file changed

+16
-2
lines changed
  • packages/app/src/app/overmind/namespaces/dashboard

1 file changed

+16
-2
lines changed

packages/app/src/app/overmind/namespaces/dashboard/actions.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ export const setActiveTeam: Action<{
3939
}> = ({ state, effects }, { id }) => {
4040
state.dashboard.activeTeam = id;
4141
effects.browser.storage.set(TEAM_ID_LOCAL_STORAGE, id);
42+
state.dashboard.sandboxes = {
43+
...state.dashboard.sandboxes,
44+
DRAFTS: null,
45+
TEMPLATES: null,
46+
RECENT: null,
47+
SEARCH: null,
48+
ALL: null,
49+
};
4250
};
4351

4452
export const dragChanged: Action<{ isDragging: boolean }> = (
@@ -129,15 +137,21 @@ export const getRecentSandboxes: AsyncAction = withLoadApp(
129137
const { dashboard } = state;
130138
try {
131139
const data = await effects.gql.queries.recentSandboxes({
132-
limit: 50,
140+
limit: 200,
133141
orderField: dashboard.orderBy.field,
134142
orderDirection: dashboard.orderBy.order.toUpperCase() as Direction,
135143
});
136144
if (!data || !data.me) {
137145
return;
138146
}
139147

140-
dashboard.sandboxes[sandboxesTypes.RECENT] = data.me.sandboxes;
148+
dashboard.sandboxes[sandboxesTypes.RECENT] = data.me.sandboxes
149+
.filter(
150+
sandbox =>
151+
(sandbox.collection || { collection: {} }).teamId ===
152+
state.dashboard.activeTeam
153+
)
154+
.slice(0, 50);
141155
} catch (error) {
142156
effects.notificationToast.error(
143157
'There was a problem getting your recent Sandboxes'

0 commit comments

Comments
 (0)