chore: cleanup commented caching code of some wrappers

pull/2620/head
Audric Ackermann 2 years ago
parent 3cd52d5b1a
commit 328c131d8b

@ -349,56 +349,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
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<ConversationAttributes> {
}
}
// -- 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) {

@ -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<string, CommunityInfo>();
/**
* The key of this map is the convoId as stored in the database. So the legacy group 05 sessionID
*/
const mappedLegacyGroupWrapperValues = new Map<string, LegacyGroupInfo>();
/**
* 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<LegacyGroupInfo> {
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
};

Loading…
Cancel
Save