Skip to content

Commit fca54d7

Browse files
committed
🚧 Progress Commit
🚧 Progress Commit
1 parent e41dc6d commit fca54d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1062
-1139
lines changed

β€Žpackages/app/scripts/start.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const { staticAssets } = require('../config/build');
2020

2121
// Tools like Cloud9 rely on this.
2222
var DEFAULT_PORT = process.env.PORT || 3000;
23-
const PROXY_DOMAIN = 'https://codesandbox.io';
23+
const PROXY_DOMAIN = 'https://codesandbox.stream';
2424
var compiler;
2525
var handleCompile;
2626
var compileStart;

β€Žpackages/app/src/app/overmind/effects/api/index.tsβ€Ž

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,16 @@ export default {
349349
},
350350
});
351351
},
352-
getProfile(username: string): Promise<Profile> {
352+
getProfile(
353+
username: string
354+
): Promise<
355+
Profile & {
356+
avatarUrl: Profile['avatar'];
357+
showcasedSandboxShortid: Profile['featuredSandbox'];
358+
featuredSandboxes: Profile['pinnedSandboxes'];
359+
subscriptionSince: string | null;
360+
}
361+
> {
353362
return api.get(`/users/${username}`);
354363
},
355364
getUserSandboxes(

β€Žpackages/app/src/app/overmind/namespaces/profile/actions.tsβ€Ž

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
import { Sandbox } from '@codesandbox/common/lib/types';
22
import { Action, AsyncAction } from 'app/overmind';
33
import { withLoadApp } from 'app/overmind/factories';
4+
import { Profile } from '@codesandbox/common/lib/types';
45

56
export const profileMounted: AsyncAction<{
67
username: string;
78
}> = withLoadApp(async ({ state, effects }, { username }) => {
89
state.profile.isLoadingProfile = true;
910
state.profile.notFound = false;
1011

11-
const profile = await effects.api.getProfile(username);
12-
13-
state.profile.profiles[profile.id] = profile;
12+
const { avatarUrl: avatar, featuredSandboxes: pinnedSandboxes, showcasedSandboxShortid: featuredSandbox, ...profile } = await effects.api.getProfile(username);
13+
14+
state.profile.profiles[profile.id] = {
15+
...profile,
16+
avatar,
17+
isContributor: state.contributors[profile.username],
18+
isPro: !!profile.subscriptionSince,
19+
// TODO: This needs to be replaced once Team Profiles can be supported!
20+
associations: [],
21+
pinnedSandboxes,
22+
featuredSandbox,
23+
// TODO: These properties are likely going to be supplied by Algolia
24+
sandboxes: [],
25+
templates: [],
26+
likes: [],
27+
};
1428
state.profile.currentProfileId = profile.id;
1529

1630
if (
17-
profile.showcasedSandboxShortid &&
18-
!state.editor.sandboxes[profile.showcasedSandboxShortid]
31+
featuredSandbox &&
32+
!state.editor.sandboxes[featuredSandbox]
1933
) {
2034
state.editor.sandboxes[
21-
profile.showcasedSandboxShortid
22-
] = await effects.api.getSandbox(profile.showcasedSandboxShortid);
35+
featuredSandbox
36+
] = await effects.api.getSandbox(featuredSandbox);
2337
}
2438

2539
state.profile.isLoadingProfile = false;
2640
});
2741

42+
export const editProfile: AsyncAction<Profile> = async ({ state, effects }, changes) => {
43+
state.profile.isLoadingSandboxes = true;
44+
45+
state.profile.profiles[changes.id] = changes
46+
47+
state.profile.isLoadingProfile = false;
48+
}
49+
2850
export const sandboxesPageChanged: AsyncAction<{
2951
page: number;
3052
force?: boolean;
@@ -73,16 +95,6 @@ export const likedSandboxesPageChanged: AsyncAction<{
7395
state.profile.isLoadingSandboxes = false;
7496
};
7597

76-
export const selectSandboxClicked: AsyncAction = async ({ state, effects }) => {
77-
state.currentModal = 'selectSandbox';
78-
79-
if (!state.profile.userSandboxes.length) {
80-
state.profile.isLoadingSandboxes = true;
81-
state.profile.userSandboxes = await effects.api.getSandboxes();
82-
state.profile.isLoadingSandboxes = false;
83-
}
84-
};
85-
8698
export const newSandboxShowcaseSelected: AsyncAction<string> = async (
8799
{ state, effects },
88100
id
@@ -106,7 +118,7 @@ export const newSandboxShowcaseSelected: AsyncAction<string> = async (
106118
};
107119

108120
export const deleteSandboxClicked: Action<{
109-
id;
121+
id: string;
110122
}> = ({ state }, { id }) => {
111123
state.profile.sandboxToDeleteId = id;
112124
state.currentModal = 'deleteProfileSandbox';

β€Žpackages/app/src/app/overmind/namespaces/profile/state.tsβ€Ž

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ import { Sandbox, UserSandbox, Profile } from '@codesandbox/common/lib/types';
22
import { Derive } from 'app/overmind';
33

44
type State = {
5+
/**
6+
* A hash of all previously loaded profiles
7+
*/
58
profiles: {
69
[profileId: string]: Profile;
710
};
11+
/**
12+
* Used to retrieve a previously loaded profile, is
13+
* automatically set to the last profile which was loaded
14+
* upon navigating to the profiles route
15+
*/
816
currentProfileId: string;
917
notFound: boolean;
1018
isLoadingProfile: boolean;
@@ -44,17 +52,13 @@ export const state: State = {
4452
currentLikedSandboxesPage: 1,
4553
isLoadingSandboxes: false,
4654
sandboxToDeleteId: null,
47-
isProfileCurrentUser: (currentState, rootState) =>
48-
rootState.user && rootState.user.id === currentState.currentProfileId,
49-
current: currentState => currentState.profiles[currentState.currentProfileId],
50-
showcasedSandbox: (currentState, rootState) =>
51-
currentState.current &&
52-
currentState.current.showcasedSandboxShortid &&
53-
rootState.editor.sandboxes[currentState.current.showcasedSandboxShortid],
54-
currentLikedSandboxes: currentState =>
55-
currentState.current &&
56-
currentState.likedSandboxes[currentState.current.username],
57-
currentSandboxes: currentState =>
58-
currentState.current &&
59-
currentState.sandboxes[currentState.current.username],
55+
isProfileCurrentUser: ({ currentProfileId }, { user }) =>
56+
user?.id === currentProfileId,
57+
current: ({ profiles, currentProfileId }) => profiles[currentProfileId],
58+
showcasedSandbox: ({ current }, { editor }) =>
59+
current?.featuredSandbox && editor.sandboxes[current.featuredSandbox],
60+
currentLikedSandboxes: ({ current, likedSandboxes }) =>
61+
current && likedSandboxes[current.username],
62+
currentSandboxes: ({ current, sandboxes }) =>
63+
current && sandboxes[current.username],
6064
};

β€Žpackages/app/src/app/pages/Profile/DELETEME.tsβ€Ž

Lines changed: 0 additions & 212 deletions
This file was deleted.

β€Žpackages/app/src/app/pages/Profile/FeaturedSandbox/FeaturedSandbox.tsxβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import React from 'react';
33
import { Container, HeroImage } from './elements';
44

55
interface IFeaturedSandboxProps {
6-
heroImage: string;
6+
id: string;
77
}
88

99
export const FeaturedSandbox: React.FC<IFeaturedSandboxProps> = ({
10-
heroImage,
10+
id,
1111
}) => {
1212
// eslint-disable-line
1313
// TODO:
1414
// - Make Hero Image a Live Sandbox Preview?
1515
return (
1616
<Container>
17-
<HeroImage src={heroImage} />
17+
<HeroImage src={`/api/v1/sandboxes/${id}/screenshot.png`} />
1818
</Container>
1919
);
2020
};

0 commit comments

Comments
Β (0)