Skip to content

Commit 2b373e1

Browse files
committed
feat: move to recent on workspace change and reset state data
1 parent af1fb98 commit 2b373e1

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,13 @@ export const setActiveTeam = async (
516516

517517
state.activeTeam = id;
518518
effects.browser.storage.set(TEAM_ID_LOCAL_STORAGE, id);
519-
state.dashboard.sandboxes = DEFAULT_DASHBOARD_SANDBOXES;
519+
520+
// Clear sandboxes and repositories
521+
state.dashboard.sandboxes = {
522+
...DEFAULT_DASHBOARD_SANDBOXES,
523+
};
524+
state.dashboard.contributions = null;
525+
state.dashboard.repositories = null;
520526

521527
actions.internal.replaceWorkspaceParameterInUrl();
522528

packages/app/src/app/pages/Dashboard/Sidebar/index.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,21 @@ export const Sidebar: React.FC<SidebarProps> = ({
4848
onSidebarToggle,
4949
...props
5050
}) => {
51+
const history = useHistory();
5152
const state = useAppState();
5253
const actions = useActions();
5354
const [activeAccount, setActiveAccount] = useState<{
5455
id: string;
5556
name: string;
5657
avatarUrl: string;
5758
} | null>(null);
58-
const { dashboard, activeTeam, activeTeamInfo, user } = state;
59+
const {
60+
dashboard,
61+
activeTeam,
62+
activeTeamInfo,
63+
user,
64+
personalWorkspaceId,
65+
} = state;
5966

6067
React.useEffect(() => {
6168
actions.dashboard.getAllFolders();
@@ -65,7 +72,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
6572
if (state.activeTeam) {
6673
const team = dashboard.teams.find(({ id }) => id === state.activeTeam);
6774
if (team) {
68-
const isPersonalWorkspace = team.id === state.personalWorkspaceId;
75+
const isPersonalWorkspace = team.id === personalWorkspaceId;
6976
setActiveAccount({
7077
id: team.id,
7178
name: team.name,
@@ -152,6 +159,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
152159
actions.setActiveTeam({
153160
id: workspace.id,
154161
});
162+
163+
history.replace(dashboardUrls.recent(workspace.id));
155164
}}
156165
activeAccount={activeAccount}
157166
/>
@@ -199,12 +208,14 @@ export const Sidebar: React.FC<SidebarProps> = ({
199208
Repositories
200209
</Text>
201210
</Element>
202-
<RowItem
203-
name="My contributions"
204-
page="my-contributions"
205-
path={dashboardUrls.myContributions(activeTeam)}
206-
icon="contribution"
207-
/>
211+
{activeTeam === personalWorkspaceId && (
212+
<RowItem
213+
name="My contributions"
214+
page="my-contributions"
215+
path={dashboardUrls.myContributions(activeTeam)}
216+
icon="contribution"
217+
/>
218+
)}
208219
<RowItem
209220
name="All repositories"
210221
page="repositories"

0 commit comments

Comments
 (0)