Skip to content

Commit

Permalink
Camera emoji rendered for notifs having media present (#46)
Browse files Browse the repository at this point in the history
* feat:emoji rendered with notif

* fix:changed origin
  • Loading branch information
route-2 authored Feb 6, 2024
1 parent 55a1d7d commit 19d3ae5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion snap/dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/ethereum-push-notification-service/push-protocol-snaps"
},
"source": {
"shasum": "3h8QmRFISxpD5m+g41R5ZvNlMFMSe14ITrjkVnLwI9M=",
"shasum": "E92WYxVcFeu9gtJzbctpTdjxmBwVajf+4747fGIma6o=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
23 changes: 17 additions & 6 deletions snap/src/utils/notifs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const getNotifications = async (address: string) => {
return feeds.feeds;
} else {
console.warn(`Invalid Ethereum address: ${address}`);
throw Error(`Error in getNotifications for ${address}: Invalid Ethereum address`);
throw Error(
`Error in getNotifications for ${address}: Invalid Ethereum address`
);
}
} catch (err) {
console.error(`Error in getNotifications for ${address}:`, err);
Expand All @@ -36,22 +38,32 @@ export const filterNotifications = async (
try {
const fetchedNotifications = await getNotifications(address);
let notiffeeds: string[] = [];
let msg;
const currentEpoch: number = Math.floor(Date.now() / 1000);

if (fetchedNotifications.length > 0) {
for (let i = 0; i < fetchedNotifications.length; i++) {
const feedEpoch = Number(fetchedNotifications[i].payload.data.epoch);
const feedepoch = Number(fetchedNotifications[i].payload.data.epoch);
const aimg = fetchedNotifications[i].payload.data.aimg;
let emoji;

if (feedEpoch > currentEpoch - 60) {
const msg =
if (feedepoch > currentEpoch - 60) {
if (aimg) {
emoji = `📸`;
} else {
emoji = `🔔`;
}

msg =
emoji +
fetchedNotifications[i].payload.data.app +
" : " +
convertText(fetchedNotifications[i].payload.data.amsg);

notiffeeds.push(msg);
}
}
}

notiffeeds = notiffeeds.reverse();
return notiffeeds;
} catch (error) {
Expand Down Expand Up @@ -116,4 +128,3 @@ const convertText = (text: string): string => {
throw error;
}
};

3 changes: 1 addition & 2 deletions snap/src/utils/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export const popupHelper = (notifs: string[]): string[] => {
// Format each notification for display
if (notifs.length > 0) {
notifs.forEach((notif) => {
const str = `\n🔔` + notif + "\n";
msg.push(str);
msg.push(notif);
});
}

Expand Down

0 comments on commit 19d3ae5

Please sign in to comment.