Addressing PR fixes

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

@ -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,
};

@ -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) => {
<div
role="button"
onMouseDown={openConvo}
onMouseUp={e => {
e.stopPropagation();
e.preventDefault();
}}
onContextMenu={(e: any) => {
contextMenu.show({
id: triggerId,
@ -381,7 +371,9 @@ const ConversationListItem = (props: Props) => {
/>
<SessionButton
buttonColor={SessionButtonColor.Green}
onClick={handleConversationAccept}
onClick={() => {
approveConversation(conversationId);
}}
text={window.i18n('accept')}
/>
</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');
}
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<Props, State> {
{({ height, width }) => (
<List
className="module-left-pane__virtual-list"
conversations={this.props.conversations}
conversations={conversations}
height={height}
rowCount={length}
rowHeight={64}
@ -301,15 +301,10 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
const messageRequestsElement = (
<SessionClosableOverlay
overlayMode={SessionClosableOverlayType.MessageRequests}
onChangeSessionID={this.handleOnPaste}
onCloseClick={() => {
this.handleToggleOverlay(undefined);
}}
onButtonClick={this.handleBlockAllRequestsClick}
searchTerm={searchTerm}
searchResults={searchResults}
showSpinner={loading}
updateSearch={this.updateSearch}
/>
);

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

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

@ -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: {
/>
<SessionToggleWithDescription
onClickToggle={() => {
// 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 && (
<SessionSettingButtonItem

@ -22,6 +22,7 @@ import {
} from '../state/ducks/modalDialog';
import {
createOrUpdateItem,
getConversationById,
getItemById,
getMessageById,
hasLinkPreviewPopupBeenDisplayed,
@ -36,6 +37,7 @@ import { fromHexToArray, toHex } from '../session/utils/String';
import { SessionButtonColor } from '../components/session/SessionButton';
import { perfEnd, perfStart } from '../session/utils/Performance';
import { getCallMediaPermissionsSettings } from '../components/session/settings/SessionSettings';
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
export const getCompleteUrlForV2ConvoId = async (convoId: string) => {
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()) {

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

Loading…
Cancel
Save