fix: do not save old follow lists

This commit is contained in:
Martti Malmi 2023-08-22 22:15:00 +03:00
parent b5bdddc403
commit 1e0edbb497
2 changed files with 7 additions and 8 deletions

View File

@ -131,14 +131,12 @@ const Events = {
this.likesByMessageId.get(id)?.add(event.pubkey);
EventDB.insert(event);
},
handleFollow(event: Event) {
const existing = EventDB.findOne({ kinds: [3], authors: [event.pubkey] });
if (existing && existing.created_at >= event.created_at) {
handleFollowList(event: Event) {
const existing = SocialNetwork.followListTimestamps.get(ID(event.pubkey));
if (existing && existing >= event.created_at) {
return;
}
if (existing) {
//EventDB.findAndRemove({ kinds: [3], authors: [event.pubkey] });
}
SocialNetwork.followListTimestamps.set(ID(event.pubkey), event.created_at);
// no need to store follow events in memory because they're already in SocialNetwork.
// when we start doing p2p, we can perhaps keep them in memory or just ask from dexie
//EventDB.insert(event);
@ -236,7 +234,7 @@ const Events = {
if (existing) {
//EventDB.findAndRemove({ authors: [event.pubkey], kinds: [0] });
}
// same as handleFollow, no need to store in memory for now
// same as handleFollowList, no need to store in memory for now
//EventDB.insert(event);
const profile = JSON.parse(event.content);
// if we have previously deleted our account, log out. appease app store.
@ -510,7 +508,7 @@ const Events = {
return false;
}
this.maybeAddNotification(event);
this.handleFollow(event);
this.handleFollowList(event);
break;
}
case 6:

View File

@ -15,6 +15,7 @@ export default {
followersByUser: new Map<UID, Set<UID>>(),
blockedUsers: new Set<UID>(),
flaggedUsers: new Set<UID>(),
followListTimestamps: new Map<UID, number>(), // timestamp of last follow list update
isFollowing: function (follower: string, followedUser: string): boolean {
const followedUserId = ID(followedUser);