Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit 453c8aa

Browse files
committed
Complete user history
1 parent 0abd42d commit 453c8aa

File tree

6 files changed

+68
-11
lines changed

6 files changed

+68
-11
lines changed

velog-frontend/src/components/user/UserHistory/UserHistory.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const HistoryItem = onlyUpdateForKeys(['item', 'username'])(
4343
<Link to={url}>{item.post.title}</Link>
4444
</h4>
4545
<p>
46-
{item.post.short_description.slice(0, 150)}
47-
{item.post.short_description.length >= 150 && '...'}
46+
{item.post.short_description && item.post.short_description.slice(0, 150)}
47+
{item.post.short_description && item.post.short_description.length >= 150 && '...'}
4848
</p>
4949
</div>
5050
</div>
@@ -59,7 +59,7 @@ const HistoryItem = onlyUpdateForKeys(['item', 'username'])(
5959
},
6060
);
6161

62-
HistoryItem.Placeholder = () => {
62+
const HistoryItemPlaceholder = () => {
6363
return (
6464
<div className="HistoryItem placeholder">
6565
<div className="message gray-box" style={{ width: '60%' }} />
@@ -103,10 +103,10 @@ class UserHistory extends Component<Props> {
103103
{this.renderList()}
104104
{this.props.loading && (
105105
<Fragment>
106-
<HistoryItem.Placeholder />
107-
<HistoryItem.Placeholder />
108-
<HistoryItem.Placeholder />
109-
<HistoryItem.Placeholder />
106+
<HistoryItemPlaceholder />
107+
<HistoryItemPlaceholder />
108+
<HistoryItemPlaceholder />
109+
<HistoryItemPlaceholder />
110110
</Fragment>
111111
)}
112112
</div>

velog-frontend/src/components/user/UserHistory/UserHistory.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
.UserHistory {
33
width: 768px;
44
margin: 0 auto;
5+
@include media("<large") {
6+
width: 100%;
7+
}
58
.no-history {
69
color: $oc-gray-6;
710
font-size: 1.125rem;
@@ -41,6 +44,10 @@
4144
border-radius: 16px;
4245
overflow: hidden;
4346
border: 1px solid $oc-gray-3;
47+
@include media("<large") {
48+
width: 96px;
49+
height: 96px;
50+
}
4451
img {
4552
width: 100%;
4653
height: 100%;
@@ -55,6 +62,10 @@
5562
height: 96px;
5663
margin-left: 1rem;
5764
margin-right: 1rem;
65+
@include media("<large") {
66+
margin-left: 0.5rem;
67+
margin-right: 0.5rem;
68+
}
5869
}
5970
.post-info {
6071
h4 {
@@ -66,6 +77,14 @@
6677
color: $oc-gray-7;
6778
margin-bottom: 0;
6879
}
80+
@include media("<large") {
81+
h4 {
82+
font-size: 0.875rem;
83+
}
84+
p {
85+
font-size: 0.75rem;
86+
}
87+
}
6988
}
7089
}
7190
.comment-block {
@@ -83,6 +102,10 @@
83102
font-family: "Noto Serif KR", sans-serif;
84103
padding-top: 0.5rem;
85104
padding-left: 1.5rem;
105+
white-space: pre-wrap;
106+
@include media("<large") {
107+
font-size: 0.875rem;
108+
}
86109
}
87110
}
88111
&.placeholder {

velog-frontend/src/lib/defaultClient.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ import axios, { type Axios } from 'axios';
44

55
axios.defaults.withCredentials = true;
66

7+
const baseURL = (() => {
8+
if (process.env.NODE_ENV === 'development') return '/';
9+
if (process.env.APP_ENV === 'server') return 'http://localhost:4000/';
10+
return 'https://api.velog.io';
11+
})();
12+
713
const defaultClient: Axios = axios.create({
8-
baseURL: process.env.NODE_ENV === 'development' ? '/' : 'https://api.velog.io',
14+
baseURL,
915
withCredentials: true,
1016
});
1117

velog-frontend/src/routeConfig.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ const routes = [
108108
},
109109
stop: true,
110110
},
111+
{
112+
path: '/@:username/history',
113+
exact: true,
114+
preload: async (ctx: any, { dispatch, getState }: any, match: Match) => {
115+
const { username } = match.params;
116+
const ProfileActions = bindActionCreators(profileActions, dispatch);
117+
const FollowActions = bindActionCreators(followActions, dispatch);
118+
if (!username) return null;
119+
await ProfileActions.getProfile(username);
120+
const state: State = getState();
121+
const { profile } = state.profile;
122+
const promises = [
123+
ProfileActions.getUserTags(username),
124+
ProfileActions.getUserHistory({ username }),
125+
];
126+
if (profile) {
127+
if (ctx.state.logged) {
128+
promises.push(FollowActions.getUserFollow(profile.id));
129+
}
130+
}
131+
return Promise.all(promises);
132+
},
133+
stop: true,
134+
},
111135
{
112136
path: '/@:username/:urlSlug',
113137
component: Post,

velog-ssr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"dev": "NODE_PATH=dist nodemon dist/local.js --watch ./dist",
9-
"deploy:local": ". ./scripts/loadenv sls deploy",
9+
"deploy:local": "./scripts/loadenv && sls deploy",
1010
"deploy": "sls deploy"
1111
},
1212
"dependencies": {

velog-ssr/src/ssr/rules.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ const rules = [
2525
path: '/@:username/tags/:tag',
2626
maxAge: 60 * 10,
2727
},
28+
{
29+
path: '/@:username/history',
30+
maxAge: 60 * 60 * 3,
31+
},
2832
{
2933
path: '/@:username/:urlSlug',
3034
maxAge: 60 * 60 * 3,
3135
},
32-
]
36+
];
3337

3438
export function check(path) {
3539
return rules.find(r => pathToRegexp(r.path).exec(path) !== null);
36-
}
40+
}

0 commit comments

Comments
 (0)