Addressing PR fixes

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

@ -39,11 +39,6 @@ window.isBehindProxy = () => Boolean(config.proxyUrl);
window.lokiFeatureFlags = { window.lokiFeatureFlags = {
useOnionRequests: true, useOnionRequests: true,
useFileOnionRequests: true,
useFileOnionRequestsV2: true, // more compact encoding of files in response
padOutgoingAttachments: true,
enablePinConversations: true,
useUnsendRequests: false,
useMessageRequests: true, useMessageRequests: true,
useCallMessage: true, useCallMessage: true,
}; };

@ -29,10 +29,9 @@ import { getFocusedSection } from '../state/selectors/section';
import { ConversationNotificationSettingType } from '../models/conversation'; import { ConversationNotificationSettingType } from '../models/conversation';
import { Flex } from './basic/Flex'; import { Flex } from './basic/Flex';
import { SessionButton, SessionButtonColor } from './session/SessionButton'; import { SessionButton, SessionButtonColor } from './session/SessionButton';
import { getConversationById } from '../data/data';
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils'; import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
import { BlockedNumberController } from '../util';
import { updateUserDetailsModal } from '../state/ducks/modalDialog'; import { updateUserDetailsModal } from '../state/ducks/modalDialog';
import { approveConversation, blockConvoById } from '../interactions/conversationInteractions';
// tslint:disable-next-line: no-empty-interface // tslint:disable-next-line: no-empty-interface
export interface ConversationListItemProps extends ReduxConversationType {} export interface ConversationListItemProps extends ReduxConversationType {}
@ -303,20 +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 () => {
const convoToBlock = await getConversationById(conversationId); blockConvoById(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);
await forceSyncConfigurationNowIfNeeded(); await forceSyncConfigurationNowIfNeeded();
}; };
@ -325,6 +311,10 @@ const ConversationListItem = (props: Props) => {
<div <div
role="button" role="button"
onMouseDown={openConvo} onMouseDown={openConvo}
onMouseUp={e => {
e.stopPropagation();
e.preventDefault();
}}
onContextMenu={(e: any) => { onContextMenu={(e: any) => {
contextMenu.show({ contextMenu.show({
id: triggerId, id: triggerId,
@ -381,7 +371,9 @@ const ConversationListItem = (props: Props) => {
/> />
<SessionButton <SessionButton
buttonColor={SessionButtonColor.Green} buttonColor={SessionButtonColor.Green}
onClick={handleConversationAccept} onClick={() => {
approveConversation(conversationId);
}}
text={window.i18n('accept')} text={window.i18n('accept')}
/> />
</Flex> </Flex>

@ -107,7 +107,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
throw new Error('render: must provided conversations if no search results are provided'); 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; const listKey = 0;
// Note: conversations is not a known prop for List, but it is required to ensure that // 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<Props, State> {
{({ height, width }) => ( {({ height, width }) => (
<List <List
className="module-left-pane__virtual-list" className="module-left-pane__virtual-list"
conversations={this.props.conversations} conversations={conversations}
height={height} height={height}
rowCount={length} rowCount={length}
rowHeight={64} rowHeight={64}
@ -301,15 +301,10 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
const messageRequestsElement = ( const messageRequestsElement = (
<SessionClosableOverlay <SessionClosableOverlay
overlayMode={SessionClosableOverlayType.MessageRequests} overlayMode={SessionClosableOverlayType.MessageRequests}
onChangeSessionID={this.handleOnPaste}
onCloseClick={() => { onCloseClick={() => {
this.handleToggleOverlay(undefined); this.handleToggleOverlay(undefined);
}} }}
onButtonClick={this.handleBlockAllRequestsClick} onButtonClick={this.handleBlockAllRequestsClick}
searchTerm={searchTerm}
searchResults={searchResults}
showSpinner={loading}
updateSearch={this.updateSearch}
/> />
); );

@ -92,7 +92,7 @@ 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>Message Requests</StyledMessageRequestBannerHeader> <StyledMessageRequestBannerHeader>{window.i18n('messageRequests')}</StyledMessageRequestBannerHeader>
<StyledUnreadCounter> <StyledUnreadCounter>
<div>{conversationRequests.length || 0}</div> <div>{conversationRequests.length || 0}</div>
</StyledUnreadCounter> </StyledUnreadCounter>

@ -25,7 +25,7 @@ export enum SessionClosableOverlayType {
interface Props { interface Props {
overlayMode: SessionClosableOverlayType; overlayMode: SessionClosableOverlayType;
onChangeSessionID: any; onChangeSessionID?: any;
onCloseClick: any; onCloseClick: any;
onButtonClick: any; onButtonClick: any;
contacts?: Array<ReduxConversationType>; contacts?: Array<ReduxConversationType>;

@ -1,8 +1,10 @@
import React from 'react'; import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
// tslint:disable-next-line: no-submodule-imports // tslint:disable-next-line: no-submodule-imports
import useUpdate from 'react-use/lib/useUpdate'; import useUpdate from 'react-use/lib/useUpdate';
import { sessionPassword, updateConfirmModal } from '../../../../state/ducks/modalDialog'; import { sessionPassword, updateConfirmModal } from '../../../../state/ducks/modalDialog';
import { toggleMessageRequests } from '../../../../state/ducks/userConfig'; import { toggleMessageRequests } from '../../../../state/ducks/userConfig';
import { getIsMessageRequestsEnabled } from '../../../../state/selectors/userConfig';
import { PasswordAction } from '../../../dialog/SessionPasswordDialog'; import { PasswordAction } from '../../../dialog/SessionPasswordDialog';
import { SessionButtonColor } from '../../SessionButton'; import { SessionButtonColor } from '../../SessionButton';
import { SessionSettingButtonItem, SessionToggleWithDescription } from '../SessionSettingListItem'; import { SessionSettingButtonItem, SessionToggleWithDescription } from '../SessionSettingListItem';
@ -53,6 +55,7 @@ export const SettingsCategoryPrivacy = (props: {
onPasswordUpdated: (action: string) => void; onPasswordUpdated: (action: string) => void;
}) => { }) => {
const forceUpdate = useUpdate(); const forceUpdate = useUpdate();
const dispatch = useDispatch();
if (props.hasPassword !== null) { if (props.hasPassword !== null) {
return ( return (
@ -110,14 +113,11 @@ export const SettingsCategoryPrivacy = (props: {
/> />
<SessionToggleWithDescription <SessionToggleWithDescription
onClickToggle={() => { onClickToggle={() => {
// const old = Boolean(window.getSettingValue(settingsAutoUpdate)); dispatch(toggleMessageRequests());
// window.setSettingValue(settingsAutoUpdate, !old);
window.inboxStore?.dispatch(toggleMessageRequests());
forceUpdate();
}} }}
title={window.i18n('messageRequests')} title={window.i18n('messageRequests')}
description={window.i18n('messageRequestsDescription')} description={window.i18n('messageRequestsDescription')}
active={Boolean(window.getSettingValue(settingsAutoUpdate))} active={useSelector(getIsMessageRequestsEnabled)}
/> />
{!props.hasPassword && ( {!props.hasPassword && (
<SessionSettingButtonItem <SessionSettingButtonItem

@ -22,6 +22,7 @@ import {
} from '../state/ducks/modalDialog'; } from '../state/ducks/modalDialog';
import { import {
createOrUpdateItem, createOrUpdateItem,
getConversationById,
getItemById, getItemById,
getMessageById, getMessageById,
hasLinkPreviewPopupBeenDisplayed, hasLinkPreviewPopupBeenDisplayed,
@ -36,6 +37,7 @@ import { fromHexToArray, toHex } from '../session/utils/String';
import { SessionButtonColor } from '../components/session/SessionButton'; import { SessionButtonColor } from '../components/session/SessionButton';
import { perfEnd, perfStart } from '../session/utils/Performance'; import { perfEnd, perfStart } from '../session/utils/Performance';
import { getCallMediaPermissionsSettings } from '../components/session/settings/SessionSettings'; import { getCallMediaPermissionsSettings } from '../components/session/settings/SessionSettings';
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
export const getCompleteUrlForV2ConvoId = async (convoId: string) => { export const getCompleteUrlForV2ConvoId = async (convoId: string) => {
if (convoId.match(openGroupV2ConversationIdRegex)) { if (convoId.match(openGroupV2ConversationIdRegex)) {
@ -115,6 +117,15 @@ export async function unblockConvoById(conversationId: string) {
await conversation.commit(); 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) { export async function showUpdateGroupNameByConvoId(conversationId: string) {
const conversation = getConversationController().get(conversationId); const conversation = getConversationController().get(conversationId);
if (conversation.isMediumGroup()) { if (conversation.isMediumGroup()) {

@ -13,3 +13,8 @@ export const getShowRecoveryPhrasePrompt = createSelector(
getUserConfig, getUserConfig,
(state: UserConfigState): boolean => state.showRecoveryPhrasePrompt (state: UserConfigState): boolean => state.showRecoveryPhrasePrompt
); );
export const getIsMessageRequestsEnabled = createSelector(
getUserConfig,
(state: UserConfigState): boolean => state.messageRequests
);

Loading…
Cancel
Save