diff --git a/src/store/activity/actions.js b/src/store/activity/actions.js index 6eac5a87..4f6fc061 100644 --- a/src/store/activity/actions.js +++ b/src/store/activity/actions.js @@ -24,11 +24,17 @@ import { formatCirclesValue } from '~/utils/format'; const { ActivityTypes, ActivityFilterTypes } = core.activity; -export const PAGE_SIZE = 2; +export const PAGE_SIZE = 10; + +// function generateHash(activity) { +// const date = activity.createdAt || activity.date; +// const value = `${date}${activity.message.en}`; +// return web3.utils.sha3(value); +// } function generateHash(activity) { - const date = activity.createdAt || activity.date; - const value = `${date}${activity.message.en}`; + const hash = activity?.txHash || activity?.createdAt || activity?.date; + const value = `${hash}${activity.type?.toString()}`; return web3.utils.sha3(value); } @@ -384,7 +390,7 @@ export function loadMoreActivitiesNews(options = {}) { function checkForDuplicates(item) { for (const newsItem of currentNews) { - if (newsItem.hash === item.hash) { + if (newsItem.data.id === item.id) { return false; // value is duplicate we do not want it } } @@ -418,7 +424,7 @@ export function loadMoreActivitiesNews(options = {}) { if (data.length === 0) { noMoreRecords = true; - return; + break; } // we want only values till present time not future @@ -426,17 +432,21 @@ export function loadMoreActivitiesNews(options = {}) { // add hash to items so we can filter for duplicates for (const filteredNewsDataItem of filteredNewsData) { - if (!filteredNewsDataItem.hash) { - filteredNewsDataItem.hash = generateHash(filteredNewsDataItem); + if (!filteredNewsDataItem.id) { + // filteredNewsDataItem.hash = generateHash(filteredNewsDataItem); + filteredNewsDataItem.id = filteredNewsDataItem.date; } } console.log('filteredNewsData', filteredNewsData); // we have some values in table as well and we do not want duplicates so we filter filterDuplicateNewsData = filteredNewsData.filter(checkForDuplicates); - debugger; + console.log('filterDuplicateNewsData', filterDuplicateNewsData); + console.log('currentNews', currentNews); + // we have values till present which are not duplicates - we add them to newsData which we want to display - newsData.push(...filterDuplicateNewsData); + newsData.push(...filteredNewsData); + // newsData.push(...filterDuplicateNewsData); console.log('newsData', newsData); offset += PAGE_SIZE; loopCounter += 1; @@ -461,6 +471,8 @@ export function loadMoreActivitiesNews(options = {}) { console.log('liveRefresh', liveRefresh); console.log('currentOffset', currentOffset); + // debugger; + dispatch({ type: ActionTypes.ACTIVITIES_NEWS_LOAD_MORE_SUCCESS, meta: { diff --git a/src/store/activity/reducers.js b/src/store/activity/reducers.js index a11a177a..f207a88a 100644 --- a/src/store/activity/reducers.js +++ b/src/store/activity/reducers.js @@ -82,7 +82,7 @@ function mergeActivities(currentActivities, newActivities) { }); // Generate a hash so we can compare it - newActivity.hash = generateHash(newActivity); + // newActivity.hash = generateHash(newActivity); // Check if item already exists (maybe we've added it manually as a // pending task and now it got mined!