mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Applying PR changes.
This commit is contained in:
parent
3602b51986
commit
2d664a2df7
|
@ -377,15 +377,15 @@ const ConversationListItem = (props: Props) => {
|
|||
<SessionButton
|
||||
onClick={handleConversationBlock}
|
||||
buttonColor={SessionButtonColor.Danger}
|
||||
text={window.i18n('block')}
|
||||
>
|
||||
Block
|
||||
</SessionButton>
|
||||
<SessionButton
|
||||
buttonColor={SessionButtonColor.Green}
|
||||
onClick={handleConversationAccept}
|
||||
>
|
||||
Accept
|
||||
</SessionButton>
|
||||
text={window.i18n('accept')}
|
||||
></SessionButton>
|
||||
</Flex>
|
||||
) : null}
|
||||
</div>
|
||||
|
|
|
@ -8,7 +8,7 @@ import { LeftPaneSettingSection } from './session/LeftPaneSettingSection';
|
|||
import { SessionTheme } from '../state/ducks/SessionTheme';
|
||||
import { getFocusedSection } from '../state/selectors/section';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getLeftPaneLists } from '../state/selectors/conversations';
|
||||
import { getConversationRequests, getLeftPaneLists } from '../state/selectors/conversations';
|
||||
import { getQuery, getSearchResults, isSearching } from '../state/selectors/search';
|
||||
import { SectionType } from '../state/ducks/section';
|
||||
|
||||
|
@ -29,12 +29,14 @@ const InnerLeftPaneMessageSection = () => {
|
|||
const searchResults = showSearch ? useSelector(getSearchResults) : undefined;
|
||||
|
||||
const lists = showSearch ? undefined : useSelector(getLeftPaneLists);
|
||||
const conversationRequests = useSelector(getConversationRequests);
|
||||
|
||||
// tslint:disable: use-simple-attributes
|
||||
return (
|
||||
<LeftPaneMessageSection
|
||||
conversations={lists?.conversations || []}
|
||||
contacts={lists?.contacts || []}
|
||||
conversationRequests={lists?.conversationRequests}
|
||||
conversationRequests={conversationRequests}
|
||||
searchResults={searchResults}
|
||||
searchTerm={searchTerm}
|
||||
/>
|
||||
|
|
|
@ -65,8 +65,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
|
|||
public constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
console.warn('convos updated');
|
||||
|
||||
this.state = {
|
||||
loading: false,
|
||||
overlay: false,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import styled from 'styled-components';
|
||||
import { getLeftPaneLists } from '../../state/selectors/conversations';
|
||||
import { getConversationRequests } from '../../state/selectors/conversations';
|
||||
import { SessionIcon, SessionIconSize, SessionIconType } from './icon';
|
||||
|
||||
const StyledMessageRequestBanner = styled.div`
|
||||
|
@ -83,9 +83,9 @@ export const CirclularIcon = (props: { iconType: SessionIconType; iconSize: Sess
|
|||
|
||||
export const MessageRequestsBanner = (props: { handleOnClick: () => any }) => {
|
||||
const { handleOnClick } = props;
|
||||
const convos = useSelector(getLeftPaneLists).conversationRequests;
|
||||
const conversationRequests = useSelector(getConversationRequests);
|
||||
|
||||
if (!convos.length) {
|
||||
if (!conversationRequests.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ export const MessageRequestsBanner = (props: { handleOnClick: () => any }) => {
|
|||
<CirclularIcon iconType="messageRequest" iconSize="medium" />
|
||||
<StyledMessageRequestBannerHeader>Message Requests</StyledMessageRequestBannerHeader>
|
||||
<StyledUnreadCounter>
|
||||
<div>{convos.length || 0}</div>
|
||||
<div>{conversationRequests.length || 0}</div>
|
||||
</StyledUnreadCounter>
|
||||
</StyledMessageRequestBanner>
|
||||
);
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ConversationTypeEnum } from '../../models/conversation';
|
|||
import { SessionJoinableRooms } from './SessionJoinableDefaultRooms';
|
||||
import { SpacerLG, SpacerMD } from '../basic/Text';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getLeftPaneLists } from '../../state/selectors/conversations';
|
||||
import { getConversationRequests } from '../../state/selectors/conversations';
|
||||
import {
|
||||
ConversationListItemProps,
|
||||
MemoConversationListItemWithDetails,
|
||||
|
@ -295,11 +295,10 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
|
|||
* @returns List of message request items
|
||||
*/
|
||||
const MessageRequestList = () => {
|
||||
const lists = useSelector(getLeftPaneLists);
|
||||
const validConversationRequests = lists?.conversationRequests;
|
||||
const conversationRequests = useSelector(getConversationRequests);
|
||||
return (
|
||||
<div className="message-request-list__container">
|
||||
{validConversationRequests.map(conversation => {
|
||||
{conversationRequests.map(conversation => {
|
||||
return <MessageRequestListItem key={conversation.id} conversation={conversation} />;
|
||||
})}
|
||||
</div>
|
||||
|
|
|
@ -317,11 +317,13 @@ async function handleRegularMessage(
|
|||
updateReadStatus(message, conversation);
|
||||
}
|
||||
|
||||
if (type === 'outgoing' && window.lokiFeatureFlags.useMessageRequests) {
|
||||
if (type === 'outgoing') {
|
||||
await handleSyncedReceipts(message, conversation);
|
||||
|
||||
// assumes sync receipts are always from linked device outgoings
|
||||
await conversation.setIsApproved(true);
|
||||
if (window.lokiFeatureFlags.useMessageRequests) {
|
||||
// assumes sync receipts are always from linked device outgoings
|
||||
await conversation.setIsApproved(true);
|
||||
}
|
||||
}
|
||||
|
||||
const conversationActiveAt = conversation.get('active_at');
|
||||
|
|
|
@ -429,7 +429,6 @@ export const _getLeftPaneLists = (
|
|||
): {
|
||||
conversations: Array<ReduxConversationType>;
|
||||
contacts: Array<ReduxConversationType>;
|
||||
conversationRequests: Array<ReduxConversationType>;
|
||||
unreadCount: number;
|
||||
} => {
|
||||
const values = Object.values(lookup);
|
||||
|
@ -437,7 +436,6 @@ export const _getLeftPaneLists = (
|
|||
|
||||
const conversations: Array<ReduxConversationType> = [];
|
||||
const directConversations: Array<ReduxConversationType> = [];
|
||||
const conversationRequests: Array<ReduxConversationType> = [];
|
||||
|
||||
let unreadCount = 0;
|
||||
for (let conversation of sorted) {
|
||||
|
@ -459,7 +457,7 @@ export const _getLeftPaneLists = (
|
|||
}
|
||||
|
||||
let messageRequestsEnabled = false;
|
||||
// TODO: if message requests toggle on and msg requesnt enable
|
||||
|
||||
if (window?.inboxStore?.getState()) {
|
||||
messageRequestsEnabled =
|
||||
window.inboxStore?.getState().userConfig.messageRequests === true &&
|
||||
|
@ -481,12 +479,9 @@ export const _getLeftPaneLists = (
|
|||
directConversations.push(conversation);
|
||||
}
|
||||
|
||||
if (messageRequestsEnabled) {
|
||||
if (!conversation.isApproved && !conversation.isBlocked) {
|
||||
// dont increase unread counter, don't push to convo list.
|
||||
conversationRequests.push(conversation);
|
||||
continue;
|
||||
}
|
||||
if (messageRequestsEnabled && !conversation.isApproved && !conversation.isBlocked) {
|
||||
// dont increase unread counter, don't push to convo list.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -504,11 +499,75 @@ export const _getLeftPaneLists = (
|
|||
return {
|
||||
conversations,
|
||||
contacts: directConversations,
|
||||
conversationRequests,
|
||||
unreadCount,
|
||||
};
|
||||
};
|
||||
|
||||
export const _getConversationRequests = (
|
||||
lookup: ConversationLookupType,
|
||||
comparator: (left: ReduxConversationType, right: ReduxConversationType) => number,
|
||||
selectedConversation?: string
|
||||
): Array<ReduxConversationType> => {
|
||||
const values = Object.values(lookup);
|
||||
const sorted = values.sort(comparator);
|
||||
|
||||
const conversationRequests: Array<ReduxConversationType> = [];
|
||||
|
||||
for (let conversation of sorted) {
|
||||
if (selectedConversation === conversation.id) {
|
||||
conversation = {
|
||||
...conversation,
|
||||
isSelected: true,
|
||||
};
|
||||
}
|
||||
|
||||
const isBlocked =
|
||||
BlockedNumberController.isBlocked(conversation.id) ||
|
||||
BlockedNumberController.isGroupBlocked(conversation.id);
|
||||
|
||||
if (isBlocked) {
|
||||
conversation = {
|
||||
...conversation,
|
||||
isBlocked: true,
|
||||
};
|
||||
}
|
||||
|
||||
let messageRequestsEnabled = false;
|
||||
|
||||
if (window?.inboxStore?.getState()) {
|
||||
messageRequestsEnabled =
|
||||
window.inboxStore?.getState().userConfig.messageRequests === true &&
|
||||
window.lokiFeatureFlags?.useMessageRequests === true;
|
||||
}
|
||||
|
||||
// Add Open Group to list as soon as the name has been set
|
||||
if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove all invalid conversations and conversatons of devices associated
|
||||
// with cancelled attempted links
|
||||
if (!conversation.isPublic && !conversation.activeAt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (messageRequestsEnabled && !conversation.isApproved && !conversation.isBlocked) {
|
||||
// dont increase unread counter, don't push to convo list.
|
||||
conversationRequests.push(conversation);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return conversationRequests;
|
||||
};
|
||||
|
||||
export const getConversationRequests = createSelector(
|
||||
getConversationLookup,
|
||||
getConversationComparator,
|
||||
getSelectedConversationKey,
|
||||
_getConversationRequests
|
||||
);
|
||||
|
||||
export const getLeftPaneLists = createSelector(
|
||||
getConversationLookup,
|
||||
getConversationComparator,
|
||||
|
|
5
ts/window.d.ts
vendored
5
ts/window.d.ts
vendored
|
@ -43,11 +43,6 @@ declare global {
|
|||
log: any;
|
||||
lokiFeatureFlags: {
|
||||
useOnionRequests: boolean;
|
||||
useFileOnionRequests: boolean;
|
||||
useFileOnionRequestsV2: boolean;
|
||||
padOutgoingAttachments: boolean;
|
||||
enablePinConversations: boolean;
|
||||
useUnsendRequests: boolean;
|
||||
useMessageRequests: boolean;
|
||||
useCallMessage: boolean;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue