Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4180825

Browse files
committed
Add notifications
1 parent c74086d commit 4180825

22 files changed

+705
-163
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CreateCollection({
2+
name: "activities"
3+
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CreateCollection({
2+
name: "notifications"
3+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CreateIndex({
2+
name: "all_notifications_by_user",
3+
source: Collection("notifications"),
4+
terms: [{
5+
field: ["data", "user"]
6+
}]
7+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CreateCollection({
2+
name: 'activities'
3+
})
4+
5+
/**
6+
# "data": {
7+
# // this user performed this activity
8+
# "user": User,
9+
10+
# // This resource has been added/changed as a result of this action
11+
# "resource": User | UPDATE_LIKE | COMMENT_LIKE | UPDATE_COMMENT
12+
13+
# "type": "LIKED_UPDATE" | "LIKED_COMMENT" | "COMMENTED" | "FOLLOWED"
14+
15+
# "timestamps": {
16+
# "createdAt": Time,
17+
# "updatedAt": Time
18+
# }
19+
# }
20+
**/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CreateCollection({
2+
name: 'notifications'
3+
})
4+
5+
/**
6+
# "data": {
7+
# // this user will receive the notification
8+
# "user": User,
9+
# "activity": ACTIVITY
10+
# isRead: Boolean,
11+
# "timestamps": {
12+
# "createdAt": Time,
13+
# "updatedAt": Time
14+
# }
15+
# }
16+
**/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CreateIndex({
2+
name: 'all_notifications_by_user',
3+
source: Collection('notifications'),
4+
terms: [
5+
{
6+
field: ['data', 'user'],
7+
},
8+
],
9+
})

src/adapters/fauna/shell.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,19 @@ const client = new faunadb.Client({
99
})
1010

1111
async function main() {
12-
const response = client.query(q.Do())
12+
const response = await client.query(
13+
q.Do(
14+
q.Map(
15+
q.Paginate(q.Documents(q.Collection('notifications'))),
16+
(goalUpdate) => q.Delete(goalUpdate)
17+
),
18+
q.Map(q.Paginate(q.Documents(q.Collection('activities'))), (goalUpdate) =>
19+
q.Delete(goalUpdate)
20+
)
21+
)
22+
)
1323
console.log(JSON.stringify(response, null, 2))
24+
console.log('THE_END')
1425
}
1526

1627
main().catch((e) => console.error(e))

src/components/AppNavBar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const navbarItems = [
2424
value: 'our-chatroom',
2525
href: '/chat',
2626
},
27+
{
28+
title: 'Notifications',
29+
value: 'notifications',
30+
href: '/notifications',
31+
},
2732
]
2833

2934
export default function AppNavBar() {

src/components/HomePageFeed.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export function HomePageFeedUpdate({
166166
href={`/${postedBy.username}`}
167167
className="hover:underline"
168168
>
169-
{postedBy.name}
169+
{postedBy.account?.firstName}
170170
</A>
171171
</p>
172172
<p className="text-sm text-gray-500">
@@ -300,11 +300,7 @@ export function HomePageFeedUpdate({
300300
<UpdateComments>
301301
<UpdateCommentsList>
302302
{update.comments.data.map((comment, index) => (
303-
<UpdateComment
304-
updateId={update.id}
305-
key={comment.id}
306-
comment={comment}
307-
>
303+
<UpdateComment key={comment.id} comment={comment}>
308304
{comment.description}
309305
</UpdateComment>
310306
))}

src/components/goals/UpdateComment.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ export type GoalUpdateType = {
2323
}
2424

2525
export default function UpdateComment({
26-
updateId,
2726
comment,
2827
children,
2928
}: {
30-
updateId: string
3129
children: string
3230
comment: UpdateCommentType
3331
}) {
@@ -90,7 +88,7 @@ export default function UpdateComment({
9088
<li>
9189
{isInEditMode ? (
9290
<EditComment
93-
updateId={updateId}
91+
updateId={comment.updateId}
9492
comment={comment}
9593
cancelEditMode={() => setIsInEditMode(false)}
9694
/>

0 commit comments

Comments
 (0)