From 328c131d8bcb00284d1400f67735d23ff28f0076 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 3 May 2023 10:11:12 +1000 Subject: [PATCH] chore: cleanup commented caching code of some wrappers --- ts/models/conversation.ts | 63 ------------------- .../libsession_utils_user_groups.ts | 27 +------- 2 files changed, 2 insertions(+), 88 deletions(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 9f1766272..f2eba5dcc 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -349,56 +349,6 @@ export class ConversationModel extends Backbone.Model { toRet.isMarkedUnread = this.get('markedAsUnread'); } - // const foundCommunity = SessionUtilUserGroups.getCommunityByConvoIdCached(this.id); - // const foundLegacyGroup = SessionUtilUserGroups.getLegacyGroupCached(this.id); - // const foundVolatileInfo = SessionUtilConvoInfoVolatile.getVolatileInfoCached(this.id); - - // // rely on the wrapper values rather than the DB ones if they exist in the wrapper - // if (foundContact) { - // if (foundContact.name) { - // toRet.displayNameInProfile = foundContact.name; - // } - - // if (foundContact.nickname) { - // toRet.nickname = foundContact.nickname; - // } - - // if (foundContact.blocked) { - // toRet.isBlocked = foundContact.blocked; - // } - - // if (foundContact.approvedMe) { - // toRet.didApproveMe = foundContact.approvedMe; - // } - - // if (foundContact.approved) { - // toRet.isApproved = foundContact.approved; - // } - - // if (foundContact.priority) { - // toRet.priority = foundContact.priority; - // } - - // if (foundContact.expirationTimerSeconds > 0) { - // toRet.expireTimer = foundContact.expirationTimerSeconds; - // } - // } else { - - // // -- Handle the group fields from the wrapper and the database -- - // if (foundLegacyGroup) { - // toRet.members = foundLegacyGroup.members.map(m => m.pubkeyHex) || []; - // toRet.groupAdmins = - // foundLegacyGroup.members.filter(m => m.isAdmin).map(m => m.pubkeyHex) || []; - // toRet.displayNameInProfile = isEmpty(foundLegacyGroup.name) - // ? undefined - // : foundLegacyGroup.name; - // toRet.expireTimer = foundLegacyGroup.disappearingTimerSeconds; - - // if (foundLegacyGroup.priority) { - // toRet.priority = foundLegacyGroup.priority; - // } - // } - // those are values coming only from both the DB or the wrapper. Currently we display the data from the DB if (this.isClosedGroup()) { toRet.members = this.get('members') || []; @@ -420,19 +370,6 @@ export class ConversationModel extends Backbone.Model { } } - // -- Handle the communities fields from the wrapper and the database -- - // if (foundCommunity) { - // if (foundCommunity.priority) { - // toRet.priority = foundCommunity.priority; - // } // the priorty field is the only one currently in the wrapper community. and we already pre apply the one from the DB on the top of this function - // } - - // if (foundVolatileInfo) { - // if (foundVolatileInfo.unread) { - // toRet.isMarkedUnread = foundVolatileInfo.unread; - // } - // } - // -- Handle the field stored only in memory for all types of conversation-- const inMemoryConvoInfo = inMemoryConvoInfos.get(this.id); if (inMemoryConvoInfo) { diff --git a/ts/session/utils/libsession/libsession_utils_user_groups.ts b/ts/session/utils/libsession/libsession_utils_user_groups.ts index 6ef72206e..f5c4bb405 100644 --- a/ts/session/utils/libsession/libsession_utils_user_groups.ts +++ b/ts/session/utils/libsession/libsession_utils_user_groups.ts @@ -1,4 +1,4 @@ -import { CommunityInfo, LegacyGroupInfo, UserGroupsType } from 'libsession_util_nodejs'; +import { CommunityInfo, UserGroupsType } from 'libsession_util_nodejs'; import { Data } from '../../../data/data'; import { OpenGroupData } from '../../../data/opengroups'; import { ConversationModel } from '../../../models/conversation'; @@ -16,11 +16,6 @@ import { getConversationController } from '../../conversations'; */ const mappedCommunityWrapperValues = new Map(); -/** - * The key of this map is the convoId as stored in the database. So the legacy group 05 sessionID - */ -const mappedLegacyGroupWrapperValues = new Map(); - /** * Returns true if that conversation is an active group */ @@ -164,13 +159,6 @@ async function refreshCachedUserGroup(convoId: string, duringAppStart = false) { mappedCommunityWrapperValues.set(convoId, fromWrapper); } refreshed = true; - } else if (convoId.startsWith('05')) { - // currently this should only be a legacy group here - const fromWrapper = await UserGroupsWrapperActions.getLegacyGroup(convoId); - if (fromWrapper) { - mappedLegacyGroupWrapperValues.set(convoId, fromWrapper); - } - refreshed = true; } if (refreshed && !duringAppStart) { @@ -207,14 +195,6 @@ async function removeCommunityFromWrapper(convoId: string, fullUrlWithOrWithoutP mappedCommunityWrapperValues.delete(convoId); } -function getLegacyGroupCached(convoId: string) { - return mappedLegacyGroupWrapperValues.get(convoId); -} - -function getAllLegacyGroups(): Array { - return [...mappedLegacyGroupWrapperValues.values()]; -} - /** * Remove the matching legacy group from the wrapper and from the cached list of legacy groups */ @@ -227,8 +207,6 @@ async function removeLegacyGroupFromWrapper(groupPk: string) { e.message ); } - - mappedLegacyGroupWrapperValues.delete(groupPk); } /** @@ -258,7 +236,6 @@ export const SessionUtilUserGroups = { // legacy group isLegacyGroupToStoreInWrapper, isLegacyGroupToRemoveFromDBIfNotInWrapper, - getLegacyGroupCached, - getAllLegacyGroups, + removeLegacyGroupFromWrapper, // a group can be removed but also just marked hidden, so only call this function when the group is completely removed // TODOLATER };