Addressing PR comments

pull/2000/head
warrickct 4 years ago
parent 9823a700e2
commit b5df47c2b8

@ -302,7 +302,7 @@ const ConversationListItem = (props: Props) => {
* adds ID to block list, syncs the block with linked devices. * adds ID to block list, syncs the block with linked devices.
*/ */
const handleConversationBlock = async () => { const handleConversationBlock = async () => {
blockConvoById(conversationId); await blockConvoById(conversationId);
await forceSyncConfigurationNowIfNeeded(); await forceSyncConfigurationNowIfNeeded();
}; };
@ -371,8 +371,8 @@ const ConversationListItem = (props: Props) => {
/> />
<SessionButton <SessionButton
buttonColor={SessionButtonColor.Green} buttonColor={SessionButtonColor.Green}
onClick={() => { onClick={async () => {
approveConversation(conversationId); await approveConversation(conversationId);
}} }}
text={window.i18n('accept')} text={window.i18n('accept')}
/> />

@ -8,7 +8,7 @@ import { LeftPaneSettingSection } from './session/LeftPaneSettingSection';
import { SessionTheme } from '../state/ducks/SessionTheme'; import { SessionTheme } from '../state/ducks/SessionTheme';
import { getFocusedSection } from '../state/selectors/section'; import { getFocusedSection } from '../state/selectors/section';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { getConversationRequests, getLeftPaneLists } from '../state/selectors/conversations'; import { getLeftPaneLists } from '../state/selectors/conversations';
import { getQuery, getSearchResults, isSearching } from '../state/selectors/search'; import { getQuery, getSearchResults, isSearching } from '../state/selectors/search';
import { SectionType } from '../state/ducks/section'; import { SectionType } from '../state/ducks/section';
@ -29,14 +29,12 @@ const InnerLeftPaneMessageSection = () => {
const searchResults = showSearch ? useSelector(getSearchResults) : undefined; const searchResults = showSearch ? useSelector(getSearchResults) : undefined;
const lists = showSearch ? undefined : useSelector(getLeftPaneLists); const lists = showSearch ? undefined : useSelector(getLeftPaneLists);
const conversationRequests = useSelector(getConversationRequests);
// tslint:disable: use-simple-attributes // tslint:disable: use-simple-attributes
return ( return (
<LeftPaneMessageSection <LeftPaneMessageSection
conversations={lists?.conversations || []} conversations={lists?.conversations || []}
contacts={lists?.contacts || []} contacts={lists?.contacts || []}
conversationRequests={conversationRequests}
searchResults={searchResults} searchResults={searchResults}
searchTerm={searchTerm} searchTerm={searchTerm}
/> />

@ -37,7 +37,6 @@ export interface Props {
contacts: Array<ReduxConversationType>; contacts: Array<ReduxConversationType>;
conversations?: Array<ConversationListItemProps>; conversations?: Array<ConversationListItemProps>;
conversationRequests?: Array<ConversationListItemProps>;
searchResults?: SearchResultsProps; searchResults?: SearchResultsProps;
} }
@ -226,9 +225,47 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
* @returns void * @returns void
*/ */
private async handleBlockAllRequestsClick() { private async handleBlockAllRequestsClick() {
let messageRequestsEnabled = false;
if (window?.inboxStore?.getState()) {
messageRequestsEnabled =
window.inboxStore?.getState().userConfig.messageRequests === true &&
window.lokiFeatureFlags?.useMessageRequests === true;
}
if (!messageRequestsEnabled) {
return;
}
// block all convo requests. Force sync if there were changes. // block all convo requests. Force sync if there were changes.
window?.log?.info('Blocking all conversations'); window?.log?.info('Blocking all conversations');
const { conversationRequests } = this.props; const conversations = getConversationController().getConversations();
if (!conversations) {
window?.log?.info('No message requests to block.');
return;
}
const conversationRequests = conversations.filter(conversation => {
// Add Open Group to list as soon as the name has been set
if (
conversation.isPublic() &&
(!conversation.get('name') || conversation.get('name') === 'Unknown group')
) {
return false;
}
// Remove all invalid conversations and conversatons of devices associated
// with cancelled attempted links
if (!conversation.isPublic && !conversation.get('active_at')) {
return false;
}
if (conversation.attributes.isApproved || !conversation.get('active_at')) {
return false;
}
return true;
});
let syncRequired = false; let syncRequired = false;
if (!conversationRequests) { if (!conversationRequests) {

@ -92,7 +92,9 @@ export const MessageRequestsBanner = (props: { handleOnClick: () => any }) => {
return ( return (
<StyledMessageRequestBanner onClick={handleOnClick}> <StyledMessageRequestBanner onClick={handleOnClick}>
<CirclularIcon iconType="messageRequest" iconSize="medium" /> <CirclularIcon iconType="messageRequest" iconSize="medium" />
<StyledMessageRequestBannerHeader>{window.i18n('messageRequests')}</StyledMessageRequestBannerHeader> <StyledMessageRequestBannerHeader>
{window.i18n('messageRequests')}
</StyledMessageRequestBannerHeader>
<StyledUnreadCounter> <StyledUnreadCounter>
<div>{conversationRequests.length || 0}</div> <div>{conversationRequests.length || 0}</div>
</StyledUnreadCounter> </StyledUnreadCounter>

@ -1042,7 +1042,12 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const model = new MessageModel(messageAttributes); const model = new MessageModel(messageAttributes);
const isMe = messageAttributes.source === UserUtils.getOurPubKeyStrFromCache(); const isMe = messageAttributes.source === UserUtils.getOurPubKeyStrFromCache();
if (isMe) {
if (
isMe &&
window.lokiFeatureFlags.useMessageRequests &&
window.inboxStore?.getState().userConfig.messageRequests
) {
await this.setIsApproved(true); await this.setIsApproved(true);
} }
@ -1288,11 +1293,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
isApproved: value, isApproved: value,
}); });
// to exclude the conversation from left pane messages list and message requests
if (value === false) {
this.set({ active_at: undefined });
}
await this.commit(); await this.commit();
} }
} }

@ -138,14 +138,14 @@ const handleContactReceived = async (
contactConvo.set('active_at', _.toNumber(envelope.timestamp)); contactConvo.set('active_at', _.toNumber(envelope.timestamp));
if ( if (
window.lokiFeatureFlags.useMessageRequests === true && window.lokiFeatureFlags.useMessageRequests &&
window.inboxStore?.getState().userConfig.messageRequests window.inboxStore?.getState().userConfig.messageRequests
) { ) {
if (contactReceived.isApproved === true) { if (contactReceived.isApproved) {
await contactConvo.setIsApproved(Boolean(contactReceived.isApproved)); await contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
} }
if (contactReceived.isBlocked === true) { if (contactReceived.isBlocked) {
await BlockedNumberController.block(contactConvo.id); await BlockedNumberController.block(contactConvo.id);
} else { } else {
await BlockedNumberController.unblock(contactConvo.id); await BlockedNumberController.unblock(contactConvo.id);

@ -236,7 +236,6 @@ 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({ conversation.set({
active_at: undefined, active_at: undefined,
isApproved: false, isApproved: false,

Loading…
Cancel
Save