contactsConfigWrapper: ContactsConfigWrapperInsideWorker|null,// set this to null to only insert into the convo volatile wrapper (i.e. for ourConvo case)
console.info('Inserting contact into wrapper: ',wrapperContact);
contactsConfigWrapper.set(wrapperContact);
}catch(e){
console.error(
`contactsConfigWrapper.set during migration failed with ${e.message} for id: ${contact.id}`
);
// the wrapper did not like something. Try again with just the boolean fields as it's most likely the issue is with one of the strings (which could be recovered)
try{
console.info('Inserting edited contact into wrapper: ',contact.id);
contactsConfigWrapper.set(
getContactInfoFromDBValues({
id: contact.id,
dbApproved,
dbApprovedMe,
dbBlocked,
dbName: undefined,
dbNickname: undefined,
dbProfileKey: undefined,
dbProfileUrl: undefined,
isPinned: false,
hidden,
})
);
console.info('Inserting contact into wrapper: ',wrapperContact);
contactsConfigWrapper.set(wrapperContact);
}catch(e){
// there is nothing else we can do here
console.error(
`contactsConfigWrapper.set during migration failed with ${e.message} for id: ${contact.id}. Skipping contact entirely`
`contactsConfigWrapper.set during migration failed with ${e.message} for id: ${contact.id}`
);
// the wrapper did not like something. Try again with just the boolean fields as it's most likely the issue is with one of the strings (which could be recovered)
try{
console.info('Inserting edited contact into wrapper: ',contact.id);
contactsConfigWrapper.set(
getContactInfoFromDBValues({
id: contact.id,
dbApproved,
dbApprovedMe,
dbBlocked,
dbName: undefined,
dbNickname: undefined,
dbProfileKey: undefined,
dbProfileUrl: undefined,
isPinned: false,
hidden,
})
);
}catch(e){
// there is nothing else we can do here
console.error(
`contactsConfigWrapper.set during migration failed with ${e.message} for id: ${contact.id}. Skipping contact entirely`
);
}
}
}
try{
constrows=db
.prepare(
`
SELECTMAX(COALESCE(sent_at,0))ASmax_sent_at
FROM${MESSAGES_TABLE}WHERE
conversationId=$conversationIdAND
unread=$unread;
`
)
.get({
conversationId: contact.id,
unread: toSqliteBoolean(false),// we want to find the message read with the higher sentAt timestamp
// TODO it would be nice to be able to remove the lastMessage and lastMessageStatus from the conversation table, and just return it when saving the conversation
// and saving it in memory only.
// But we'd need to update a bunch of things as we do some logic before setting the lastUpdate text and status mostly in `getMessagePropStatus` and `getNotificationText()`
// const lastMessages = getLastMessagesByConversation(convoId, 1) as Array:Record<string, any>>;
@ -62,7 +62,7 @@ function isConvoToStoreInWrapper(convo: ConversationModel): boolean {
return(
SessionUtilUserGroups.isUserGroupToStoreInWrapper(convo)||// this checks for community & legacy group
SessionUtilContact.isContactToStoreInContactsWrapper(convo)||// this checks for contacts
SessionUtilUserProfile.isUserProfileToStoreInContactsWrapper(convo.id)// this checks for out own pubkey, as we want to keep track of the read state for the Note To Self
SessionUtilUserProfile.isUserProfileToStoreInContactsWrapper(convo.id)// this checks for our own pubkey, as we want to keep track of the read state for the Note To Self
);
}
@ -91,7 +91,8 @@ async function insertConvoFromDBIntoWrapperAndRefresh(convoId: string): Promise<
// TODO not having a last read timestamp fallsback to 0, which keeps the existing value in the wrapper if it is already set (as done in src/convo_info_volatile_config.cpp)
// Note: not having a last read timestamp fallsback to 0, which keeps the existing value in the wrapper if it is already set (as done in src/convo_info_volatile_config.cpp)
// we actually do the max() of whatever is inside the wrapper and the value from the DB