Skip to content

Commit e321633

Browse files
author
Roshan Jossy
authored
Merge pull request #21 from firstcontributions/reactions
2 parents cda6538 + 944150b commit e321633

12 files changed

+665
-90
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
"multiparty": "^4.2.3",
3030
"next": "^12.1.6",
3131
"node-fetch": "^3.2.0",
32-
"react": "17.0.2",
33-
"react-dom": "17.0.2",
32+
"react": "^18.2.0",
33+
"react-dom": "^18.2.0",
34+
"react-error-boundary": "^3.1.4",
3435
"react-relay": "^13.0.2",
3536
"relay-nextjs": "^0.6.0",
3637
"relay-runtime": "^13.0.2",

schema/schema.graphql

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ schema {
44
mutation: Mutation
55
}
66
scalar Time
7+
8+
enum SortOrder {
9+
asc,
10+
desc,
11+
}
12+
713
type Query {
814
viewer: User
915

@@ -12,7 +18,8 @@ type Query {
1218
# The ID of an object
1319
id: ID!
1420
): Node
15-
feeds(first: Int, last: Int, after: String, before: String): StoriesConnection!
21+
feeds(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): StoriesConnection!
22+
user(handle: String): User!
1623
}
1724

1825
interface Node {
@@ -39,19 +46,23 @@ type Badge implements Node {
3946
type BadgesConnection {
4047
edges: [BadgeEdge]!
4148
pageInfo: PageInfo!
49+
totalCount: Int!
4250
}
4351

4452
type BadgeEdge {
4553
node: Badge!
4654
cursor: String!
55+
}
56+
57+
enum BadgeSortBy {
58+
time_created,
4759
}
4860

4961
type Comment implements Node {
5062
abstractContent: String!
5163
contentJson: String!
5264
createdBy: User!
5365
id: ID!
54-
reactions(first: Int, last: Int, after: String, before: String): ReactionsConnection!
5566
timeCreated: Time!
5667
timeUpdated: Time!
5768
}
@@ -68,11 +79,17 @@ input UpdateCommentInput {
6879
type CommentsConnection {
6980
edges: [CommentEdge]!
7081
pageInfo: PageInfo!
82+
totalCount: Int!
83+
hasViewerAssociation: Boolean!
7184
}
7285

7386
type CommentEdge {
7487
node: Comment!
7588
cursor: String!
89+
}
90+
91+
enum CommentSortBy {
92+
time_created,
7693
}
7794

7895
type GitContributionStats {
@@ -101,11 +118,16 @@ type Issue implements Node {
101118
type IssuesConnection {
102119
edges: [IssueEdge]!
103120
pageInfo: PageInfo!
121+
totalCount: Int!
104122
}
105123

106124
type IssueEdge {
107125
node: Issue!
108126
cursor: String!
127+
}
128+
129+
enum IssueSortBy {
130+
time_created,
109131
}
110132

111133
type Reaction implements Node {
@@ -116,7 +138,6 @@ type Reaction implements Node {
116138
}
117139

118140
input ReactionInput {
119-
commentID: ID!
120141
storyID: ID!
121142
}
122143
input UpdateReactionInput {
@@ -126,11 +147,17 @@ input UpdateReactionInput {
126147
type ReactionsConnection {
127148
edges: [ReactionEdge]!
128149
pageInfo: PageInfo!
150+
totalCount: Int!
151+
hasViewerAssociation: Boolean!
129152
}
130153

131154
type ReactionEdge {
132155
node: Reaction!
133156
cursor: String!
157+
}
158+
159+
enum ReactionSortBy {
160+
time_created,
134161
}
135162

136163
type Reputation {
@@ -143,11 +170,11 @@ input ReputationInput {
143170

144171
type Story implements Node {
145172
abstractContent: String!
146-
comments(first: Int, last: Int, after: String, before: String): CommentsConnection!
173+
comments(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): CommentsConnection!
147174
contentJson: String!
148175
createdBy: User!
149176
id: ID!
150-
reactions(first: Int, last: Int, after: String, before: String): ReactionsConnection!
177+
reactions(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): ReactionsConnection!
151178
thumbnail: String!
152179
timeCreated: Time!
153180
timeUpdated: Time!
@@ -169,26 +196,32 @@ input UpdateStoryInput {
169196
type StoriesConnection {
170197
edges: [StoryEdge]!
171198
pageInfo: PageInfo!
199+
totalCount: Int!
200+
hasViewerAssociation: Boolean!
172201
}
173202

174203
type StoryEdge {
175204
node: Story!
176205
cursor: String!
206+
}
207+
208+
enum StorySortBy {
209+
time_created,
177210
}
178211

179212
type User implements Node {
180213
avatar: String!
181-
badges(first: Int, last: Int, after: String, before: String): BadgesConnection!
214+
badges(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): BadgesConnection!
182215
bio: String!
183216
gitContributionStats: GitContributionStats!
184217
handle: String!
185218
id: ID!
186-
issuesFromLastRepo(first: Int, last: Int, after: String, before: String): IssuesConnection!
187-
issuesFromOtherRecentRepos(first: Int, last: Int, after: String, before: String): IssuesConnection!
219+
issuesFromLastRepo(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): IssuesConnection!
220+
issuesFromOtherRecentRepos(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): IssuesConnection!
188221
name: String!
189-
relevantIssues(first: Int, last: Int, after: String, before: String): IssuesConnection!
222+
relevantIssues(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): IssuesConnection!
190223
reputation: Reputation!
191-
stories(first: Int, last: Int, after: String, before: String): StoriesConnection!
224+
stories(first: Int, last: Int, after: String, before: String, sortBy: String, sortOrder: SortOrder): StoriesConnection!
192225
timeCreated: Time!
193226
timeUpdated: Time!
194227
}
@@ -208,6 +241,21 @@ input UpdateUserInput {
208241
gitContributionStats: GitContributionStatsInput
209242
name: String
210243
reputation: ReputationInput
244+
}
245+
246+
type UsersConnection {
247+
edges: [UserEdge]!
248+
pageInfo: PageInfo!
249+
totalCount: Int!
250+
}
251+
252+
type UserEdge {
253+
node: User!
254+
cursor: String!
255+
}
256+
257+
enum UserSortBy {
258+
time_created,
211259
}
212260

213261
type Mutation {

src/components/ErrorFallback.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
type ErrorFallbackProps = {
2+
error: Error
3+
resetErrorBoundary: () => void
4+
}
5+
6+
export default function ErrorFallback({
7+
error,
8+
resetErrorBoundary,
9+
}: ErrorFallbackProps) {
10+
return (
11+
<div role="alert">
12+
<p>Something went wrong:</p>
13+
<pre>{error.message}</pre>
14+
<button onClick={resetErrorBoundary}>Try again</button>
15+
</div>
16+
)
17+
}

src/components/feed/StoryPreview.tsx

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import StoryPreviewFooter from './StoryPreviewFooter'
44
import UserSnippet from './UserSnippet'
55
import { GoKebabVertical } from '@react-icons/all-files/go/GoKebabVertical'
66
import Link from 'next/link'
7+
import { ErrorBoundary } from 'react-error-boundary'
8+
import ErrorFallback from '../ErrorFallback'
79

810
type StoryPreviewProps = {
911
story: StoryPreview_node$key
@@ -22,61 +24,64 @@ const StoryPreview = ({ story }: StoryPreviewProps) => {
2224
createdBy {
2325
...UserSnippet_user
2426
}
27+
...StoryPreviewFooter_story
2528
}
2629
`,
2730
story
2831
)
2932

3033
return (
31-
<div className="my-8 flex flex-col bg-white dark:bg-dark-700 rounded-lg">
32-
<div>
33-
{data.thumbnail ? (
34-
<img className="cover-image" src={data.thumbnail} alt="" />
35-
) : (
36-
<div className="image-placeholder bg-gray-100 dark:bg-dark-500"></div>
37-
)}
38-
</div>
39-
<div className="px-4 pb-4">
40-
<div className="flex flex-row justify-between">
41-
<UserSnippet user={data.createdBy} />
42-
<GoKebabVertical className="mt-4" />
34+
<ErrorBoundary FallbackComponent={ErrorFallback}>
35+
<div className="my-8 flex flex-col bg-white dark:bg-dark-700 rounded-lg">
36+
<div>
37+
{data.thumbnail ? (
38+
<img className="cover-image" src={data.thumbnail} alt="" />
39+
) : (
40+
<div className="image-placeholder bg-gray-100 dark:bg-dark-500"></div>
41+
)}
4342
</div>
44-
<div className="prose dark:text-gray-100">
45-
<Link href={`/story/${data.id}___${data.urlSuffix}`}>
46-
<a>
47-
<h3 className="dark:text-gray-200">{data.title}</h3>
48-
</a>
49-
</Link>
50-
<p className="abstract-content">{data.abstractContent}</p>
43+
<div className="px-4 pb-4">
44+
<div className="flex flex-row justify-between">
45+
<UserSnippet user={data.createdBy} />
46+
<GoKebabVertical className="mt-4" />
47+
</div>
48+
<div className="prose dark:text-gray-100">
49+
<Link href={`/story/${data.id}___${data.urlSuffix}`}>
50+
<a>
51+
<h3 className="dark:text-gray-200">{data.title}</h3>
52+
</a>
53+
</Link>
54+
<p className="abstract-content">{data.abstractContent}</p>
55+
</div>
5156
</div>
52-
</div>
53-
<StoryPreviewFooter />
54-
<style jsx>
55-
{`
56-
.image-placeholder {
57-
border-radius: 0.5rem 0.5rem 0 0;
58-
content: '';
59-
height: 4rem;
60-
}
61-
.cover-image {
62-
border-radius: 0.5rem 0.5rem 0 0;
63-
max-height: 10rem;
64-
width: 100%;
65-
object-fit: cover;
66-
}
57+
<StoryPreviewFooter story={data} />
58+
<style jsx>
59+
{`
60+
.image-placeholder {
61+
border-radius: 0.5rem 0.5rem 0 0;
62+
content: '';
63+
height: 4rem;
64+
}
65+
.cover-image {
66+
border-radius: 0.5rem 0.5rem 0 0;
67+
max-height: 10rem;
68+
width: 100%;
69+
object-fit: cover;
70+
}
6771
68-
.abstract-content {
69-
text-overflow: ellipsis;
70-
overflow: hidden;
71-
// Addition lines for 2 line or multiline ellipsis
72-
display: -webkit-box !important;
73-
-webkit-line-clamp: 4;
74-
-webkit-box-orient: vertical;
75-
white-space: normal;
76-
}
77-
`}
78-
</style>
79-
</div>
72+
.abstract-content {
73+
text-overflow: ellipsis;
74+
overflow: hidden;
75+
// Addition lines for 2 line or multiline ellipsis
76+
display: -webkit-box !important;
77+
-webkit-line-clamp: 4;
78+
-webkit-box-orient: vertical;
79+
white-space: normal;
80+
}
81+
`}
82+
</style>
83+
</div>
84+
</ErrorBoundary>
8085
)
8186
}
8287

0 commit comments

Comments
 (0)