Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitf81c7e5

Browse files
committed
refactor(UserPublished): support videos/jobs/repos
1 parentacceb48 commitf81c7e5

File tree

10 files changed

+291
-31
lines changed

10 files changed

+291
-31
lines changed

‎components/JobItem/styles/company_info.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const Footer = styled.div`
3131
color:${theme('thread.articleDigest')};
3232
`
3333
exportconstTitle=styled.div`
34+
color:${theme('thread.articleTitle')};
3435
font-size: 1rem;
3536
`
3637
exportconstStatesWrapper=styled.div`

‎components/JobItem/styles/job_info.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ export const Middle = styled.div`
1515
padding: 5px 0;
1616
margin-bottom: 2px;
1717
`
18-
exportconstFooter=styled.div``
18+
exportconstFooter=styled.div`
19+
color:${theme('thread.articleDigest')};
20+
`
1921

2022
exportconstTitle=styled.div`
23+
color:${theme('thread.articleTitle')};
2124
font-size: 1rem;
2225
width: 90%;
2326
`

‎containers/UserPublished/PublishedContents.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@ import React from 'react'
22

33
// import { Wrapper } from './styles'
44
importPublishedPostsfrom'./PublishedPosts'
5+
importPublishedJobsfrom'./PublishedJobs'
6+
importPublishedVideosfrom'./PublishedVideos'
7+
importPublishedReposfrom'./PublishedRepos'
58

69
import{THREAD}from'../../utils'
710

811
constPublishedContents=({ thread, curView, entries})=>{
912
switch(thread){
10-
caseTHREAD.POST:{
11-
return<PublishedPostsentries={entries}curView={curView}/>
13+
caseTHREAD.JOB:{
14+
return<PublishedJobsentries={entries}curView={curView}/>
15+
}
16+
caseTHREAD.VIDEO:{
17+
return<PublishedVideosentries={entries}curView={curView}/>
18+
}
19+
caseTHREAD.REPO:{
20+
return<PublishedReposentries={entries}curView={curView}/>
1221
}
1322
default:{
14-
return<h3>other published contents</h3>
23+
return<PublishedPostsentries={entries}curView={curView}/>
1524
}
1625
}
1726
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
importReactfrom'react'
2+
3+
import{JobItemLoading,JobItem}from'../../components'
4+
5+
import{uid,TYPE}from'../../utils'
6+
7+
constPublishedJobs=({ entries, curView, active})=>{
8+
switch(curView){
9+
caseTYPE.RESULT:{
10+
return(
11+
<React.Fragment>
12+
{entries.map(entry=>(
13+
<JobItem
14+
key={uid.gen()}
15+
entry={entry}
16+
active={active}
17+
onTitleSelect={console.log}
18+
/>
19+
))}
20+
</React.Fragment>
21+
)
22+
}
23+
default:
24+
return<JobItemLoadingnum={4}/>
25+
}
26+
}
27+
28+
exportdefaultPublishedJobs
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
importReactfrom'react'
2+
3+
import{RepoItemLoading,RepoItem}from'../../components'
4+
5+
import{uid,TYPE}from'../../utils'
6+
7+
constPublishedRepos=({ entries, curView, active})=>{
8+
switch(curView){
9+
caseTYPE.RESULT:{
10+
return(
11+
<React.Fragment>
12+
{entries.map(entry=>(
13+
<RepoItem
14+
key={uid.gen()}
15+
entry={entry}
16+
active={active}
17+
onTitleSelect={console.log}
18+
/>
19+
))}
20+
</React.Fragment>
21+
)
22+
}
23+
default:
24+
return<RepoItemLoadingnum={4}/>
25+
}
26+
}
27+
28+
exportdefaultPublishedRepos
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
importReactfrom'react'
2+
3+
import{VideoItemLoading,VideoItem}from'../../components'
4+
5+
import{uid,TYPE}from'../../utils'
6+
7+
constPublishedVideos=({ entries, curView, active})=>{
8+
switch(curView){
9+
caseTYPE.RESULT:{
10+
return(
11+
<React.Fragment>
12+
{entries.map(entry=>(
13+
<VideoItem
14+
key={uid.gen()}
15+
entry={entry}
16+
active={active}
17+
onTitleSelect={console.log}
18+
/>
19+
))}
20+
</React.Fragment>
21+
)
22+
}
23+
default:
24+
return<VideoItemLoadingnum={4}/>
25+
}
26+
}
27+
28+
exportdefaultPublishedVideos

‎containers/UserPublished/index.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class UserPublishedContainer extends React.Component {
2727

2828
render(){
2929
const{ userPublished}=this.props
30-
const{pagedPostsData, curView, curThread}=userPublished
30+
const{pagedData, curView, curThread}=userPublished
3131

32-
const{ entries, totalCount, pageNumber, pageSize}=pagedPostsData
32+
const{ entries, totalCount, pageNumber, pageSize}=pagedData
3333

3434
return(
3535
<div>
@@ -41,17 +41,19 @@ class UserPublishedContainer extends React.Component {
4141
lookLike="box"
4242
/>
4343
</ThreadWrapper>
44+
4445
<PublishedContents
4546
entries={entries}
4647
curView={curView}
4748
thread={curThread}
4849
/>
50+
4951
<Pagi
5052
left="-20px"
5153
pageNumber={pageNumber}
5254
pageSize={pageSize}
5355
totalCount={totalCount}
54-
onChange={logic.onPageChange}
56+
onChange={logic.reload}
5557
/>
5658
</div>
5759
)

‎containers/UserPublished/logic.js‎

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,44 @@ const debug = makeDebugger('L:UserPublished')
2323

2424
letstore=null
2525

26-
exportconstloadPosts=(page=1)=>{
27-
constargs={
26+
constbeforeQuery=page=>{
27+
store.markState({curView:TYPE.LOADING})
28+
// args
29+
return{
2830
userId:store.viewingUser.id,
2931
filter:pagedFilter(page),
3032
}
31-
32-
store.markState({curView:TYPE.LOADING})
33+
}
34+
exportconstloadPosts=(page=1)=>{
35+
constargs=beforeQuery(page)
3336
sr71$.query(S.publishedPosts,args)
3437
}
3538

36-
exportfunctiononPageChange(page){
39+
exportconstloadJobs=(page=1)=>{
40+
constargs=beforeQuery(page)
41+
sr71$.query(S.publishedJobs,args)
42+
}
43+
44+
exportconstloadVideos=(page=1)=>{
45+
constargs=beforeQuery(page)
46+
sr71$.query(S.publishedVideos,args)
47+
}
48+
49+
exportconstloadRepos=(page=1)=>{
50+
constargs=beforeQuery(page)
51+
sr71$.query(S.publishedRepos,args)
52+
}
53+
54+
exportfunctionreload(page){
3755
switch(store.curThread){
3856
caseTHREAD.JOB:{
39-
returndebug('load job')
57+
returnloadJobs(page)
58+
}
59+
caseTHREAD.VIDEO:{
60+
returnloadVideos(page)
61+
}
62+
caseTHREAD.REPO:{
63+
returnloadRepos(page)
4064
}
4165
default:{
4266
returnloadPosts(page)
@@ -47,6 +71,7 @@ export function onPageChange(page) {
4771
exportfunctiononThreadChange(curThread){
4872
// TODO: markRoute
4973
store.markState({ curThread})
74+
reload()
5075
}
5176

5277
// ###############################
@@ -56,13 +81,19 @@ export function onThreadChange(curThread) {
5681
constDataSolver=[
5782
{
5883
match:asyncRes('publishedPosts'),
59-
action:({publishedPosts:pagedPosts})=>{
60-
letcurView=TYPE.RESULT
61-
if(pagedPosts.entries.length===0){
62-
curView=TYPE.RESULT_EMPTY
63-
}
64-
store.markState({ curView, pagedPosts})
65-
},
84+
action:({ publishedPosts})=>store.markPagedData(publishedPosts),
85+
},
86+
{
87+
match:asyncRes('publishedJobs'),
88+
action:({ publishedJobs})=>store.markPagedData(publishedJobs),
89+
},
90+
{
91+
match:asyncRes('publishedVideos'),
92+
action:({ publishedVideos})=>store.markPagedData(publishedVideos),
93+
},
94+
{
95+
match:asyncRes('publishedRepos'),
96+
action:({ publishedRepos})=>store.markPagedData(publishedRepos),
6697
},
6798
]
6899
constErrSolver=[

‎containers/UserPublished/schema.js‎

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
importgqlfrom'graphql-tag'
22

3-
constsimpleMutation=gql`
4-
mutation($id: ID!) {
5-
post(id: $id) {
6-
id
7-
}
8-
}
9-
`
103
constpublishedPosts=gql`
114
query($userId: ID!, $filter: PagedFilter!) {
125
publishedPosts(userId: $userId, filter: $filter) {
@@ -36,10 +29,105 @@ const publishedPosts = gql`
3629
}
3730
}
3831
`
32+
constpublishedJobs=gql`
33+
query($userId: ID!, $filter: PagedFilter!) {
34+
publishedJobs(userId: $userId, filter: $filter) {
35+
entries {
36+
id
37+
title
38+
company
39+
companyLogo
40+
tags {
41+
id
42+
title
43+
color
44+
}
45+
author {
46+
id
47+
nickname
48+
avatar
49+
}
50+
views
51+
insertedAt
52+
updatedAt
53+
}
54+
totalPages
55+
totalCount
56+
pageSize
57+
pageNumber
58+
}
59+
}
60+
`
61+
constpublishedVideos=gql`
62+
query($userId: ID!, $filter: PagedFilter!) {
63+
publishedVideos(userId: $userId, filter: $filter) {
64+
entries {
65+
id
66+
title
67+
poster
68+
desc
69+
duration
70+
source
71+
views
72+
originalAuthor
73+
originalAuthorLink
74+
author {
75+
id
76+
avatar
77+
nickname
78+
}
79+
insertedAt
80+
publishAt
81+
}
82+
totalPages
83+
totalCount
84+
pageSize
85+
pageNumber
86+
}
87+
}
88+
`
89+
constpublishedRepos=gql`
90+
query($userId: ID!, $filter: PagedFilter!) {
91+
publishedRepos(userId: $userId, filter: $filter) {
92+
entries {
93+
id
94+
title
95+
ownerName
96+
desc
97+
license
98+
releaseTag
99+
contributors {
100+
avatar
101+
htmlUrl
102+
nickname
103+
}
104+
starCount
105+
forkCount
106+
primaryLanguage {
107+
name
108+
color
109+
}
110+
views
111+
author {
112+
id
113+
avatar
114+
nickname
115+
}
116+
insertedAt
117+
}
118+
totalPages
119+
totalCount
120+
pageSize
121+
pageNumber
122+
}
123+
}
124+
`
39125

40126
constschema={
41-
simpleMutation,
42127
publishedPosts,
128+
publishedJobs,
129+
publishedVideos,
130+
publishedRepos,
43131
}
44132

45133
exportdefaultschema

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp