mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-12 02:05:51 +00:00
fix friends feed duplicate
This commit is contained in:
parent
54f183778e
commit
6169da48a8
@ -134,7 +134,7 @@ class FriendsFeed extends connect(store)(LitElement) {
|
|||||||
this.endpointOffsets = Array(this.endpoints.length).fill(0);
|
this.endpointOffsets = Array(this.endpoints.length).fill(0);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const baseurl = `${this.nodeUrl}/arbitrary/resources/search?reverse=true&exactmatchnames=true&${names}`
|
const baseurl = `${this.nodeUrl}/arbitrary/resources/search?reverse=true&mode=ALL&exactmatchnames=true&${names}`
|
||||||
let formEndpoints = []
|
let formEndpoints = []
|
||||||
schemas.forEach((schema)=> {
|
schemas.forEach((schema)=> {
|
||||||
const feedData = schema.feed[0]
|
const feedData = schema.feed[0]
|
||||||
@ -350,7 +350,7 @@ this.getFeedOnInterval()
|
|||||||
|
|
||||||
// Merge new data with old data immutably
|
// Merge new data with old data immutably
|
||||||
this.feed = [...enhancedNewData, ...this.feed];
|
this.feed = [...enhancedNewData, ...this.feed];
|
||||||
|
this.feed = this.removeDuplicates(this.feed)
|
||||||
this.feed.sort((a, b) => new Date(b.created) - new Date(a.created)); // Sort by timestamp, most recent first
|
this.feed.sort((a, b) => new Date(b.created) - new Date(a.created)); // Sort by timestamp, most recent first
|
||||||
this.feed = this.trimDataToLimit(this.feed, maxResultsInMemory); // Trim to the maximum allowed in memory
|
this.feed = this.trimDataToLimit(this.feed, maxResultsInMemory); // Trim to the maximum allowed in memory
|
||||||
this.feedToRender = this.feed.slice(0, 20);
|
this.feedToRender = this.feed.slice(0, 20);
|
||||||
@ -365,6 +365,17 @@ this.getFeedOnInterval()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
removeDuplicates(array) {
|
||||||
|
const seenIds = new Set();
|
||||||
|
return array.filter(item => {
|
||||||
|
if (!seenIds.has(item.identifier)) {
|
||||||
|
seenIds.add(item.identifier);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async loadAndMergeData() {
|
async loadAndMergeData() {
|
||||||
let allData = this.feed
|
let allData = this.feed
|
||||||
@ -373,6 +384,7 @@ this.getFeedOnInterval()
|
|||||||
allData = this.mergeData(newData, allData);
|
allData = this.mergeData(newData, allData);
|
||||||
allData.sort((a, b) => new Date(b.created) - new Date(a.created)); // Sort by timestamp, most recent first
|
allData.sort((a, b) => new Date(b.created) - new Date(a.created)); // Sort by timestamp, most recent first
|
||||||
allData = this.trimDataToLimit(allData, maxResultsInMemory); // Trim to the maximum allowed in memory
|
allData = this.trimDataToLimit(allData, maxResultsInMemory); // Trim to the maximum allowed in memory
|
||||||
|
allData = this.removeDuplicates(allData)
|
||||||
this.feed = [...allData]
|
this.feed = [...allData]
|
||||||
this.feedToRender = this.feed.slice(0,20)
|
this.feedToRender = this.feed.slice(0,20)
|
||||||
this.hasInitialFetch = true
|
this.hasInitialFetch = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user