Skip to content

Commit

Permalink
fix: profile page crash (#8596)
Browse files Browse the repository at this point in the history
* fix: profile page crash

* fix: update
  • Loading branch information
alexnm authored Sep 9, 2024
1 parent 94e7994 commit 3e9d4e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
18 changes: 16 additions & 2 deletions packages/app/src/app/overmind/namespaces/profile/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ export const profileMounted = withLoadApp(

state.profile.profiles[profile.id] = profile;
state.profile.currentProfileId = profile.id;

if (profile.showcasedSandboxShortid) {
try {
state.profile.showcasedSandbox = await effects.api.getSandbox(
profile.showcasedSandboxShortid
);
} catch (e) {
// Ignore it
}
}

state.profile.isLoadingProfile = false;
}
);
Expand Down Expand Up @@ -136,8 +147,11 @@ export const newSandboxShowcaseSelected = async (
return;
}

await effects.api.updateShowcasedSandbox(state.user.username, id);

const sandbox = await effects.api.updateShowcasedSandbox(
state.user.username,
id
);
state.profile.showcasedSandbox = sandbox as Sandbox;
state.profile.isLoadingProfile = false;
};

Expand Down
7 changes: 2 additions & 5 deletions packages/app/src/app/overmind/namespaces/profile/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const state: State = {
currentSortDirection: 'desc',
contextMenu: { sandboxId: null, sandboxType: null, position: null },
collections: [],
showcasedSandbox: null,
isProfileCurrentUser: derived(
(currentState: State, rootState: Context['state']) =>
Boolean(
Expand All @@ -83,11 +84,7 @@ export const state: State = {
? currentState.profiles[currentState.currentProfileId]
: null
),
showcasedSandbox: derived((currentState: State) =>
currentState.current && currentState.current.showcasedSandboxShortid
? currentState.sandboxes.all[currentState.current.showcasedSandboxShortid]
: null
),

currentLikedSandboxes: derived((currentState: State) =>
currentState.current
? currentState.likedSandboxes[currentState.current.username]
Expand Down

0 comments on commit 3e9d4e5

Please sign in to comment.