Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notifications: add and emit viewnotificationsfeed event #4570

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions client/CLIENT_EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ createComment.error
- <a href="#viewNewComments">viewNewComments</a>
- <a href="#viewNewCommentsNetwork">viewNewCommentsNetwork</a>
- <a href="#viewNewRepliesNetwork">viewNewRepliesNetwork</a>
- <a href="#viewNotificationsFeed">viewNotificationsFeed</a>

### Events
- <a id="addACommentButton">**addACommentButton**</a>: This event is emitted when the viewer clicks the add a comment button in alternate oldest view.
Expand Down Expand Up @@ -729,4 +730,10 @@ createComment.error
};
}
```
- <a id="viewNotificationsFeed">**viewNotificationsFeed**</a>: This event is emitted when the viewer clicks to view their notifications feed.
```ts
{
userID?: string | undefined;
}
```
<!-- END docs:events -->
7 changes: 7 additions & 0 deletions client/src/core/client/stream/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ export const ViewConversationEvent = createViewerEvent<{
commentID: string;
}>("viewConversation");

/**
* This event is emitted when the viewer clicks to view their notifications feed.
*/
export const ViewNotificationsFeedEvent = createViewerEvent<{
userID?: string;
}>("viewNotificationsFeedEvent");

/**
* This event is emitted when the viewer clicks
* on a username which shows the user popover.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import cn from "classnames";
import React, {
FunctionComponent,
useCallback,
useEffect,
useMemo,
useState,
} from "react";
import { graphql, RelayPaginationProp } from "react-relay";

import { useViewerEvent } from "coral-framework/lib/events";
import {
useLocal,
useRefetch,
Expand All @@ -19,6 +21,7 @@ import {
} from "coral-framework/schema";
import CLASSES from "coral-stream/classes";
import Spinner from "coral-stream/common/Spinner";
import { ViewNotificationsFeedEvent } from "coral-stream/events";
import { Flex } from "coral-ui/components/v2";
import { Button } from "coral-ui/components/v3";

Expand All @@ -40,6 +43,13 @@ interface Props {

const NotificationsPaginator: FunctionComponent<Props> = (props) => {
const [disableLoadMore, setDisableLoadMore] = useState(false);
const emitViewNotificationsFeedEvent = useViewerEvent(
ViewNotificationsFeedEvent
);

useEffect(() => {
emitViewNotificationsFeedEvent({ userID: props.viewerID });
}, []);

const [{ hasNewNotifications }, setLocal] =
useLocal<NotificationsPaginatorLocal>(graphql`
Expand Down
Loading