-
Notifications
You must be signed in to change notification settings - Fork 5
REP/NIC Notifications + Push Notifications Settings + Drag to refresh for mobile #1764
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b8a6642
REP/NIC Notifications + Push Notifications Settings + Drag to refres…
prxt6529 d2a088f
Merge branch 'main' into cic-rep-notifications
prxt6529 ed1ea6e
WIP
prxt6529 ab694c6
WIP
prxt6529 1a58335
WIP
prxt6529 35c9049
WIP
prxt6529 374a914
WIP
prxt6529 0d50fb1
Merge branch 'main' into cic-rep-notifications
prxt6529 45070e4
WIP
prxt6529 52a8f50
Merge branch 'main' into cic-rep-notifications
prxt6529 6e5cd75
WIP
prxt6529 64e13d6
Merge branch 'main' into cic-rep-notifications
prxt6529 5c731d6
WIP
prxt6529 5cc2370
WIP
prxt6529 0881b25
WIP
prxt6529 4024073
WIP
prxt6529 86fa5cf
Merge branch 'main' into cic-rep-notifications
prxt6529 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
components/brain/notifications/generic/NotificationGeneric.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import type { INotificationGeneric } from "@/types/feed.types"; | ||
| import NotificationHeader from "../subcomponents/NotificationHeader"; | ||
| import NotificationTimestamp from "../subcomponents/NotificationTimestamp"; | ||
|
|
||
| function formatCause(cause: string): string { | ||
| return cause | ||
| .replaceAll("_", " ") | ||
| .toLowerCase() | ||
| .replaceAll(/\b\w/g, (c) => c.toUpperCase()); | ||
| } | ||
|
|
||
| function formatContextValue(value: unknown): string | null { | ||
| if (value === null || value === undefined) return null; | ||
| if (typeof value === "string") return value; | ||
| if (typeof value === "number" || typeof value === "boolean") { | ||
| return String(value); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| function ContextDetails({ | ||
| context, | ||
| }: { | ||
| readonly context: Record<string, unknown> | undefined; | ||
| }) { | ||
| if (!context || Object.keys(context).length === 0) return null; | ||
|
|
||
| const displayableEntries = Object.entries(context) | ||
| .map(([key, value]) => [key, formatContextValue(value)] as const) | ||
| .filter((entry): entry is [string, string] => entry[1] !== null); | ||
|
|
||
| if (displayableEntries.length === 0) return null; | ||
|
|
||
| return ( | ||
| <> | ||
| <span className="tw-mr-1 tw-text-xs tw-font-bold tw-text-iron-400"> | ||
| • | ||
| </span> | ||
| <div className="tw-flex tw-flex-wrap tw-gap-x-3 tw-gap-y-1"> | ||
| {displayableEntries.map(([key, value]) => ( | ||
| <span key={key} className="tw-text-xs tw-text-iron-500"> | ||
| <span className="tw-text-iron-600">{key}:</span> {value} | ||
| </span> | ||
| ))} | ||
| </div> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| function NotificationContent({ | ||
| causeLabel, | ||
| createdAt, | ||
| context, | ||
| }: { | ||
| readonly causeLabel: string; | ||
| readonly createdAt: number; | ||
| readonly context: Record<string, unknown> | undefined; | ||
| }) { | ||
| return ( | ||
| <> | ||
| <span className="tw-text-sm tw-font-normal tw-text-iron-400"> | ||
| {causeLabel} | ||
| </span> | ||
| <NotificationTimestamp createdAt={createdAt} /> | ||
| <ContextDetails context={context} /> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default function NotificationGeneric({ | ||
| notification, | ||
| }: { | ||
| readonly notification: INotificationGeneric; | ||
| }) { | ||
| const causeLabel = formatCause(notification.cause); | ||
|
|
||
| if (notification.related_identity) { | ||
| return ( | ||
| <div className="tw-w-full"> | ||
| <NotificationHeader author={notification.related_identity}> | ||
| <NotificationContent | ||
| causeLabel={causeLabel} | ||
| createdAt={notification.created_at} | ||
| context={notification.additional_context} | ||
| /> | ||
| </NotificationHeader> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="tw-w-full tw-py-2"> | ||
| <div className="tw-flex tw-flex-wrap tw-items-center tw-gap-x-2"> | ||
| <span className="tw-text-sm tw-font-medium tw-text-iron-300"> | ||
| {causeLabel} | ||
| </span> | ||
| <NotificationTimestamp createdAt={notification.created_at} /> | ||
| </div> | ||
| <ContextDetails context={notification.additional_context} /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.