Skip to content

Commit

Permalink
feat: notification store updated when new message arrive
Browse files Browse the repository at this point in the history
  • Loading branch information
sujal-into authored and sachin-into committed Mar 15, 2024
1 parent 19ef8c1 commit 4dafdb7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ substreams-*/target
/weshd/ios/Frameworks/
/weshd/android/libs/
/weshd/temp/
temp/

# eslint
/.eslintcache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ export default function MessengerNotificationCard({

// TODO: Change to appropriate routes
if (item.type === "message") {
navigation.navigate("MiniChats", {});
navigation.navigate("Conversation", {
conversationId: item?.id,
});
}

if (item.type === "contact-request") {
navigation.navigate("MiniChats", {});
navigation.navigate("MiniFriend");
}

if (item.type === "group-join") {
Expand Down Expand Up @@ -124,7 +126,7 @@ interface NotiCardContentProps {
id: string;
isRead: boolean;
title: string;
date: string;
date?: string;
desc: string;
link?: string;
user?: { userAvatar?: string; username: string; id: string };
Expand Down
3 changes: 0 additions & 3 deletions packages/store/slices/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ export const Notification = z.object({
timestamp: z.string().optional(),
avatar: z.string().optional(),
isRead: z.boolean(),
contactId: z.string().optional(),
rdvSeed: z.string().optional(),
name: z.string().optional(),
peerId: z.string().optional(),
});

export type TypeNotification = z.infer<typeof Notification>;
Expand Down
1 change: 1 addition & 0 deletions packages/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const rootPersistConfig = {
"marketplaceCartItemsUI",
"marketplaceFilters",
"marketplaceFilterUI",
"notifications",
],
blacklist: ["dAppsStore, marketplaceFilterUI", "message"],
};
Expand Down
10 changes: 10 additions & 0 deletions packages/weshnet/message/processEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { weshConfig } from "../config";
import { getConversationName } from "../messageHelpers";
import { decodeJSON, stringFromBytes } from "../utils";

import { setNotificationRequest } from "@/store/slices/notification";

export const processMessage = async (
data: GroupMessageEvent,
groupPk: string,
Expand Down Expand Up @@ -79,6 +81,14 @@ export const processMessage = async (
);
}

store.dispatch(
setNotificationRequest({
id: groupPk,
type: "group-join",
isRead: false,
}),
);

break;
}
case "group-join": {
Expand Down

0 comments on commit 4dafdb7

Please sign in to comment.