From 9823a700e278aa30d85b5c01662063fef0e0b179 Mon Sep 17 00:00:00 2001 From: warrickct Date: Wed, 24 Nov 2021 11:14:24 +1100 Subject: [PATCH] Addressing PR fixes --- preload.js | 5 ---- ts/components/ConversationListItem.tsx | 26 +++++++------------ .../session/LeftPaneMessageSection.tsx | 9 ++----- .../session/MessageRequestsBanner.tsx | 2 +- .../session/SessionClosableOverlay.tsx | 2 +- .../settings/section/CategoryPrivacy.tsx | 10 +++---- ts/interactions/conversationInteractions.ts | 11 ++++++++ ts/state/selectors/userConfig.ts | 5 ++++ 8 files changed, 34 insertions(+), 36 deletions(-) diff --git a/preload.js b/preload.js index cd1679c43..ebe50c750 100644 --- a/preload.js +++ b/preload.js @@ -39,11 +39,6 @@ window.isBehindProxy = () => Boolean(config.proxyUrl); window.lokiFeatureFlags = { useOnionRequests: true, - useFileOnionRequests: true, - useFileOnionRequestsV2: true, // more compact encoding of files in response - padOutgoingAttachments: true, - enablePinConversations: true, - useUnsendRequests: false, useMessageRequests: true, useCallMessage: true, }; diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index 9725cc20b..4d0ea641a 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -29,10 +29,9 @@ import { getFocusedSection } from '../state/selectors/section'; import { ConversationNotificationSettingType } from '../models/conversation'; import { Flex } from './basic/Flex'; import { SessionButton, SessionButtonColor } from './session/SessionButton'; -import { getConversationById } from '../data/data'; import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils'; -import { BlockedNumberController } from '../util'; import { updateUserDetailsModal } from '../state/ducks/modalDialog'; +import { approveConversation, blockConvoById } from '../interactions/conversationInteractions'; // tslint:disable-next-line: no-empty-interface export interface ConversationListItemProps extends ReduxConversationType {} @@ -303,20 +302,7 @@ const ConversationListItem = (props: Props) => { * adds ID to block list, syncs the block with linked devices. */ const handleConversationBlock = async () => { - const convoToBlock = await getConversationById(conversationId); - if (!convoToBlock) { - window?.log?.error('Unable to find conversation to be blocked.'); - } - await BlockedNumberController.block(convoToBlock?.id); - await forceSyncConfigurationNowIfNeeded(); - }; - - /** - * marks the conversation as approved. - */ - const handleConversationAccept = async () => { - const conversationToApprove = await getConversationById(conversationId); - await conversationToApprove?.setIsApproved(true); + blockConvoById(conversationId); await forceSyncConfigurationNowIfNeeded(); }; @@ -325,6 +311,10 @@ const ConversationListItem = (props: Props) => {
{ + e.stopPropagation(); + e.preventDefault(); + }} onContextMenu={(e: any) => { contextMenu.show({ id: triggerId, @@ -381,7 +371,9 @@ const ConversationListItem = (props: Props) => { /> { + approveConversation(conversationId); + }} text={window.i18n('accept')} /> diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index 2632409fd..694e46612 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -107,7 +107,7 @@ export class LeftPaneMessageSection extends React.Component { throw new Error('render: must provided conversations if no search results are provided'); } - const length = this.props.conversations ? this.props.conversations.length : 0; + const length = conversations.length; const listKey = 0; // Note: conversations is not a known prop for List, but it is required to ensure that @@ -119,7 +119,7 @@ export class LeftPaneMessageSection extends React.Component { {({ height, width }) => ( { const messageRequestsElement = ( { this.handleToggleOverlay(undefined); }} onButtonClick={this.handleBlockAllRequestsClick} - searchTerm={searchTerm} - searchResults={searchResults} - showSpinner={loading} - updateSearch={this.updateSearch} /> ); diff --git a/ts/components/session/MessageRequestsBanner.tsx b/ts/components/session/MessageRequestsBanner.tsx index 7e2f5408e..ffd5a970b 100644 --- a/ts/components/session/MessageRequestsBanner.tsx +++ b/ts/components/session/MessageRequestsBanner.tsx @@ -92,7 +92,7 @@ export const MessageRequestsBanner = (props: { handleOnClick: () => any }) => { return ( - Message Requests + {window.i18n('messageRequests')}
{conversationRequests.length || 0}
diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index a533d09a2..14d6efd72 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -25,7 +25,7 @@ export enum SessionClosableOverlayType { interface Props { overlayMode: SessionClosableOverlayType; - onChangeSessionID: any; + onChangeSessionID?: any; onCloseClick: any; onButtonClick: any; contacts?: Array; diff --git a/ts/components/session/settings/section/CategoryPrivacy.tsx b/ts/components/session/settings/section/CategoryPrivacy.tsx index da4e7c02f..e876bbc2b 100644 --- a/ts/components/session/settings/section/CategoryPrivacy.tsx +++ b/ts/components/session/settings/section/CategoryPrivacy.tsx @@ -1,8 +1,10 @@ import React from 'react'; +import { useDispatch, useSelector } from 'react-redux'; // tslint:disable-next-line: no-submodule-imports import useUpdate from 'react-use/lib/useUpdate'; import { sessionPassword, updateConfirmModal } from '../../../../state/ducks/modalDialog'; import { toggleMessageRequests } from '../../../../state/ducks/userConfig'; +import { getIsMessageRequestsEnabled } from '../../../../state/selectors/userConfig'; import { PasswordAction } from '../../../dialog/SessionPasswordDialog'; import { SessionButtonColor } from '../../SessionButton'; import { SessionSettingButtonItem, SessionToggleWithDescription } from '../SessionSettingListItem'; @@ -53,6 +55,7 @@ export const SettingsCategoryPrivacy = (props: { onPasswordUpdated: (action: string) => void; }) => { const forceUpdate = useUpdate(); + const dispatch = useDispatch(); if (props.hasPassword !== null) { return ( @@ -110,14 +113,11 @@ export const SettingsCategoryPrivacy = (props: { /> { - // const old = Boolean(window.getSettingValue(settingsAutoUpdate)); - // window.setSettingValue(settingsAutoUpdate, !old); - window.inboxStore?.dispatch(toggleMessageRequests()); - forceUpdate(); + dispatch(toggleMessageRequests()); }} title={window.i18n('messageRequests')} description={window.i18n('messageRequestsDescription')} - active={Boolean(window.getSettingValue(settingsAutoUpdate))} + active={useSelector(getIsMessageRequestsEnabled)} /> {!props.hasPassword && ( { if (convoId.match(openGroupV2ConversationIdRegex)) { @@ -115,6 +117,15 @@ export async function unblockConvoById(conversationId: string) { await conversation.commit(); } +/** + * marks the conversation as approved. + */ +export const approveConversation = async (conversationId: string) => { + const conversationToApprove = await getConversationById(conversationId); + await conversationToApprove?.setIsApproved(true); + await forceSyncConfigurationNowIfNeeded(); +}; + export async function showUpdateGroupNameByConvoId(conversationId: string) { const conversation = getConversationController().get(conversationId); if (conversation.isMediumGroup()) { diff --git a/ts/state/selectors/userConfig.ts b/ts/state/selectors/userConfig.ts index 9c8641cb2..39dd45eba 100644 --- a/ts/state/selectors/userConfig.ts +++ b/ts/state/selectors/userConfig.ts @@ -13,3 +13,8 @@ export const getShowRecoveryPhrasePrompt = createSelector( getUserConfig, (state: UserConfigState): boolean => state.showRecoveryPhrasePrompt ); + +export const getIsMessageRequestsEnabled = createSelector( + getUserConfig, + (state: UserConfigState): boolean => state.messageRequests +);