message request refactoring.

pull/2000/head
warrickct 4 years ago
parent 40396224dc
commit 2e2941ba9b

@ -51,7 +51,7 @@ window.lokiFeatureFlags = {
padOutgoingAttachments: true, padOutgoingAttachments: true,
enablePinConversations: true, enablePinConversations: true,
useUnsendRequests: false, useUnsendRequests: false,
useMessageRequests: false, useMessageRequests: true,
}; };
window.isBeforeVersion = (toCheck, baseVersion) => { window.isBeforeVersion = (toCheck, baseVersion) => {

@ -84,10 +84,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
throw new Error('renderRow: Tried to render without conversations'); throw new Error('renderRow: Tried to render without conversations');
} }
const messageRequestsEnabled =
window.inboxStore?.getState().userConfig.messageRequests === true &&
window?.lokiFeatureFlags?.useMessageRequests;
let conversation; let conversation;
if (conversations?.length) { if (conversations?.length) {
conversation = conversations[index]; conversation = conversations[index];
@ -97,10 +93,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
return null; return null;
} }
// TODO: need to confirm what default setting is best here.
if (messageRequestsEnabled && !Boolean(conversation.isApproved)) {
return null;
}
return <MemoConversationListItemWithDetails key={key} style={style} {...conversation} />; return <MemoConversationListItemWithDetails key={key} style={style} {...conversation} />;
}; };

@ -236,7 +236,11 @@ export class ConversationController {
if (conversation.isPrivate()) { if (conversation.isPrivate()) {
window.log.info(`deleteContact isPrivate, marking as inactive: ${id}`); window.log.info(`deleteContact isPrivate, marking as inactive: ${id}`);
conversation.set('active_at', undefined); // conversation.set('active_at', undefined);
conversation.set({
active_at: undefined,
isApproved: false,
});
await conversation.commit(); await conversation.commit();
} else { } else {
window.log.info(`deleteContact !isPrivate, removing convo from DB: ${id}`); window.log.info(`deleteContact !isPrivate, removing convo from DB: ${id}`);

@ -304,29 +304,60 @@ export const _getLeftPaneLists = (
}; };
} }
if (!Boolean(conversation.isApproved) === true && window.lokiFeatureFlags.useMessageRequests) { const messageRequestsEnabled =
continue; window.inboxStore?.getState().userConfig.messageRequests === true &&
} window?.lokiFeatureFlags?.useMessageRequests === true;
// if (!Boolean(conversation.isApproved) === true && window.lokiFeatureFlags.useMessageRequests) {
// continue;
// }
// Add Open Group to list as soon as the name has been set // Add Open Group to list as soon as the name has been set
if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) { // if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
continue; // continue;
// }
// if (!conversation.isApproved && !conversation.isBlocked) {
// conversationRequests.push(conversation);
// }
if (shouldShowInRequestList(conversation, messageRequestsEnabled)) {
conversationRequests.push(conversation);
} }
// Remove all invalid conversations and conversatons of devices associated // Remove all invalid conversations and conversatons of devices associated
// with cancelled attempted links // with cancelled attempted links
if (!conversation.isPublic && !conversation.activeAt) { // if (!conversation.isPublic && !conversation.activeAt) {
continue; // continue;
} // }
if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) { // if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
// directConversations.push(conversation);
// }
if (shouldShowInContacts(conversation)) {
directConversations.push(conversation); directConversations.push(conversation);
} }
if (!conversation.isApproved && !conversation.isBlocked) { if (shouldShowInConversationList(conversation, messageRequestsEnabled)) {
conversationRequests.push(conversation); conversations.push(conversation);
unreadCount = calculateNewUnreadTotal(unreadCount, conversation);
}
// if (conversation.isApproved) {
// conversations.push(conversation);
// }
} }
return {
conversations,
contacts: directConversations,
conversationRequests,
unreadCount,
};
};
const calculateNewUnreadTotal = (unreadCount: number, conversation: ReduxConversationType) => {
if ( if (
unreadCount < 9 && unreadCount < 9 &&
conversation.unreadCount && conversation.unreadCount &&
@ -335,18 +366,73 @@ export const _getLeftPaneLists = (
) { ) {
unreadCount += conversation.unreadCount; unreadCount += conversation.unreadCount;
} }
return unreadCount;
};
if (conversation.isApproved) { const shouldShowInRequestList = (
conversations.push(conversation); conversation: ReduxConversationType,
messageRequestsEnabled: boolean
) => {
if (conversation.isPublic || conversation.isBlocked || Boolean(conversation.activeAt) === false) {
return false;
} }
if (messageRequestsEnabled) {
if (Boolean(conversation.isApproved || !conversation.isBlocked)) {
return false;
} }
}
return true;
};
return { const shouldShowInContacts = (conversation: ReduxConversationType) => {
conversations, // Add Open Group to list as soon as the name has been set
contacts: directConversations, if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
conversationRequests, return false;
unreadCount, }
};
// if (shouldShowInRequestList(conversation)) {
// conversationRequests.push(conversation);
// }
// Remove all invalid conversations and conversatons of devices associated
// with cancelled attempted links
if (!conversation.isPublic && !conversation.activeAt) {
return false;
}
if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
// directConversations.push(conversation);
return true;
} else {
return false;
}
};
const shouldShowInConversationList = (
conversation: ReduxConversationType,
messageRequestsEnabled: boolean
) => {
// // Add Open Group to list as soon as the name has been set
if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
return false;
}
// Remove all invalid conversations and conversatons of devices associated
// with cancelled attempted links
if (!conversation.isPublic && !conversation.activeAt) {
return false;
}
// if (!conversation.activeAt) {
// return false;
// }
if (messageRequestsEnabled && !conversation.isApproved) {
return false;
}
return true;
}; };
export const getLeftPaneLists = createSelector( export const getLeftPaneLists = createSelector(

Loading…
Cancel
Save