diff --git a/packages/site/.env.development b/packages/site/.env.development index 51d4564..7ef2996 100644 --- a/packages/site/.env.development +++ b/packages/site/.env.development @@ -2,4 +2,4 @@ * To use this, rename to $(.env.production) and set the production SNAP_ORIGIN here */ SNAP_ORIGIN=local:http://localhost:8080 -ENVIRONMENT=production +ENVIRONMENT=development diff --git a/packages/site/src/pages/monitor/list.tsx b/packages/site/src/pages/monitor/list.tsx index 1b1317b..d6703c9 100644 --- a/packages/site/src/pages/monitor/list.tsx +++ b/packages/site/src/pages/monitor/list.tsx @@ -30,7 +30,7 @@ const MonitorList = () => { const [monitorList, setMonitorList] = useState([]); const handleGetState = async () => { const snapState = await sendGetState(); - // console.log(snapState); + console.log(snapState); }; useEffect(() => { diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index c67a6e9..a9302a8 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/NaturalSelectionLabs/RSS3-Social-Notifier-Snap.git" }, "source": { - "shasum": "UQMSWUeez7d4pWGO4PTKV0FEFuWExXKgWHgpWIjIDnQ=", + "shasum": "JzJh23BBGdsijFOEAQw8fREDnXCr9VJDCVESa8+qMX0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/fetch.ts b/packages/snap/src/fetch.ts index cb30f18..b22b0b2 100644 --- a/packages/snap/src/fetch.ts +++ b/packages/snap/src/fetch.ts @@ -14,10 +14,10 @@ export const getSocialActivitiesUrl = (address: string) => `https://testnet.rss3.io/data/accounts/${address}/activities?tag=social&direction=out`; /** - * Get social count by rss3. + * Get social activities by rss3. * * @param address - The wallet address. - * @returns The social count. + * @returns The social activities. */ export async function getSocialActivities(address: string) { const resp = await fetch(getSocialActivitiesUrl(address)); diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index c67aeb4..a112400 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -351,6 +351,8 @@ export const onCronjob: OnCronjobHandler = async ({ request }) => { ); const socialActivities = await Promise.all(resultPromise); + // remove duplicates by following list address + // filter the changed social count const changedSocialCounts = socialActivities.filter((activity) => state.socialActivities.find( diff --git a/packages/snap/src/utils/activitiy.ts b/packages/snap/src/utils/activitiy.ts index 4783397..3c518b4 100644 --- a/packages/snap/src/utils/activitiy.ts +++ b/packages/snap/src/utils/activitiy.ts @@ -56,8 +56,27 @@ export async function buildNeedToNotifyContents() { (item) => item.watchedProfiles ?? [], ); + const tempAddresses = new Set(); + const filteredProfiles = watchedProfiles + .map((profile) => { + const filteredFollowing = + profile.following?.filter((item) => { + const { address } = item; + if (!tempAddresses.has(address)) { + tempAddresses.add(address); + return true; + } + return false; + }) || []; + + return filteredFollowing.length > 0 + ? { ...profile, following: filteredFollowing } + : null; + }) + .filter(Boolean) as TSocialGraphResult[]; + const AllContents: Component[][] = []; - const contentPromises = watchedProfiles.flatMap(async (profile) => { + const contentPromises = filteredProfiles.flatMap(async (profile) => { const latestActivities = profile.following?.flatMap((fProfile) => fProfile.lastActivities ?? []) ?? []; @@ -127,7 +146,7 @@ export function getExecuteHandler(profile: Profile): ExecuteHandler { export async function addWatchedProfilesToState() { const state = await getState(); const monitorsPromises = state.monitor.flatMap(async (monitor) => { - monitor.latestUpdateTime = moment().format('YYYY/MM/DD hh:mm:ss'); + monitor.latestUpdateTime = moment().format('YYYY/MM/DD HH:mm:ss'); const profilesPromises = monitor.profiles.flatMap(async (rss3Profile) => { const { handle, execute } = getExecuteHandler(rss3Profile); return handle ? await execute(rss3Profile.handle, monitor) : undefined;