From 3bc7d95d4749398317260a320343661761f33a98 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 8 Jul 2020 14:29:22 +1000 Subject: [PATCH] closed-group-contacts-redux --- ts/components/LeftPane.tsx | 1 + .../session/LeftPaneContactSection.tsx | 1 - .../session/LeftPaneMessageSection.tsx | 28 ++----------------- .../session/SessionClosableOverlay.tsx | 20 ++++--------- ts/state/selectors/conversations.ts | 24 ++++++++++------ 5 files changed, 25 insertions(+), 49 deletions(-) diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index d567c23ab..a4c4c600c 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -122,6 +122,7 @@ export class LeftPane extends React.Component { return ( ; contacts: Array; - searchResults?: SearchResultsProps; updateSearchTerm: (searchTerm: string) => void; diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index 8a27576a7..77a26f2dc 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -7,6 +7,7 @@ import { ConversationListItem, PropsData as ConversationListItemPropsType, } from '../ConversationListItem'; +import { ConversationType } from '../../state/ducks/conversations'; import { PropsData as SearchResultsProps, SearchResults, @@ -34,6 +35,7 @@ export interface Props { searchTerm: string; isSecondaryDevice: boolean; + contacts: Array; conversations?: Array; searchResults?: SearchResultsProps; @@ -313,6 +315,7 @@ export class LeftPaneMessageSection extends React.Component { const closedGroupElement = ( { @@ -481,31 +484,6 @@ export class LeftPaneMessageSection extends React.Component { }); this.setState({loading: true}); - - // Call conversationRenderedResolve when the conversation is rendered. - let conversationRenderedResolve: any; - const conversationRenderedPromise = async () => - // tslint:disable-next-line: promise-must-complete - new Promise(resolve => { - conversationRenderedResolve = resolve; - }); - - // STOP IT AT THE SOURCE; SELECTORS/CONVERSATIONS.TS - const isRenderedInterval = setInterval(async () => { - // The conversation is shown in LeftPane when lastMessage is set. - // Notify the user when we're ready to render in LeftPane. - if ((await OpenGroup.getConversation(serverUrl))?.lastMessage) { - conversationRenderedResolve(); - window.pushToast({ - title: window.i18n('connectToServerFail'), - id: 'connectToServerFail', - type: 'error', - }); - } - }, 100); - - - } }); diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index d9ad94de4..3788380d9 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -66,20 +66,10 @@ export class SessionClosableOverlay extends React.Component { } public getContacts() { - const conversations = window.getConversations() || []; - - const conversationList = conversations.filter((conversation: any) => { - return ( - !conversation.isMe() && - conversation.isPrivate() && - !conversation.isSecondaryDevice() && - !conversation.isBlocked() - ); - }); + const contactsList = this.props.contacts ?? []; - return conversationList.map((d: any) => { - const lokiProfile = d.getLokiProfile(); - const name = lokiProfile ? lokiProfile.displayName : 'Anonymous'; + return contactsList.map((d: any) => { + const name = d.name ?? 'Anonymous'; // TODO: should take existing members into account const existingMember = false; @@ -87,10 +77,10 @@ export class SessionClosableOverlay extends React.Component { return { id: d.id, authorPhoneNumber: d.id, - authorProfileName: name, + authorProfileName: d.name, selected: false, authorName: name, - authorColor: d.getColor(), + authorColor: d.color, checkmarked: false, existingMember, }; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 9ba5559c9..bc6d32a6d 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -120,14 +120,22 @@ export const _getLeftPaneLists = ( }; } - const isPublic = conversation.isPublic; - console.log('[vince] isPublic:', isPublic); - console.log('[vince] isPublic:', isPublic); - console.log('[vince] isPublic:', isPublic); - console.log('[vince] isPublic:', isPublic); - + // Add Open Group to list as soon as the name has been set + if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) { + continue; + } + + // Show loading icon while fetching messages + if (conversation.isPublic && !conversation.timestamp) { + conversation.lastMessage = { + status: 'sending', + text: '', + isRss: false, + }; + } + // Remove all invalid conversations and conversatons of devices associated with cancelled attempted links - if (!conversation.timestamp) { + if (!conversation.isPublic && !conversation.timestamp) { continue; } @@ -139,7 +147,7 @@ export const _getLeftPaneLists = ( unreadCount += conversation.unreadCount; } - if (!conversation.activeAt) { + if (!conversation.isPublic && !conversation.activeAt) { continue; }