closed-group-contacts-redux

pull/1225/head
Vincent 5 years ago
parent e72970fdc7
commit 3bc7d95d47

@ -122,6 +122,7 @@ export class LeftPane extends React.Component<Props, State> {
return ( return (
<LeftPaneMessageSection <LeftPaneMessageSection
contacts={this.props.contacts}
openConversationInternal={openConversationInternal} openConversationInternal={openConversationInternal}
conversations={conversations} conversations={conversations}
searchResults={searchResults} searchResults={searchResults}

@ -29,7 +29,6 @@ export interface Props {
conversations: Array<ConversationListItemPropsType>; conversations: Array<ConversationListItemPropsType>;
contacts: Array<ConversationType>; contacts: Array<ConversationType>;
searchResults?: SearchResultsProps; searchResults?: SearchResultsProps;
updateSearchTerm: (searchTerm: string) => void; updateSearchTerm: (searchTerm: string) => void;

@ -7,6 +7,7 @@ import {
ConversationListItem, ConversationListItem,
PropsData as ConversationListItemPropsType, PropsData as ConversationListItemPropsType,
} from '../ConversationListItem'; } from '../ConversationListItem';
import { ConversationType } from '../../state/ducks/conversations';
import { import {
PropsData as SearchResultsProps, PropsData as SearchResultsProps,
SearchResults, SearchResults,
@ -34,6 +35,7 @@ export interface Props {
searchTerm: string; searchTerm: string;
isSecondaryDevice: boolean; isSecondaryDevice: boolean;
contacts: Array<ConversationType>;
conversations?: Array<ConversationListItemPropsType>; conversations?: Array<ConversationListItemPropsType>;
searchResults?: SearchResultsProps; searchResults?: SearchResultsProps;
@ -313,6 +315,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
const closedGroupElement = ( const closedGroupElement = (
<SessionClosableOverlay <SessionClosableOverlay
contacts={this.props.contacts}
overlayMode={SessionClosableOverlayType.ClosedGroup} overlayMode={SessionClosableOverlayType.ClosedGroup}
onChangeSessionID={this.handleOnPaste} onChangeSessionID={this.handleOnPaste}
onCloseClick={() => { onCloseClick={() => {
@ -481,31 +484,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
}); });
this.setState({loading: true}); 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);
} }
}); });

@ -66,20 +66,10 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
} }
public getContacts() { public getContacts() {
const conversations = window.getConversations() || []; const contactsList = this.props.contacts ?? [];
const conversationList = conversations.filter((conversation: any) => {
return (
!conversation.isMe() &&
conversation.isPrivate() &&
!conversation.isSecondaryDevice() &&
!conversation.isBlocked()
);
});
return conversationList.map((d: any) => { return contactsList.map((d: any) => {
const lokiProfile = d.getLokiProfile(); const name = d.name ?? 'Anonymous';
const name = lokiProfile ? lokiProfile.displayName : 'Anonymous';
// TODO: should take existing members into account // TODO: should take existing members into account
const existingMember = false; const existingMember = false;
@ -87,10 +77,10 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
return { return {
id: d.id, id: d.id,
authorPhoneNumber: d.id, authorPhoneNumber: d.id,
authorProfileName: name, authorProfileName: d.name,
selected: false, selected: false,
authorName: name, authorName: name,
authorColor: d.getColor(), authorColor: d.color,
checkmarked: false, checkmarked: false,
existingMember, existingMember,
}; };

@ -120,14 +120,22 @@ export const _getLeftPaneLists = (
}; };
} }
const isPublic = conversation.isPublic; // Add Open Group to list as soon as the name has been set
console.log('[vince] isPublic:', isPublic); if (conversation.isPublic && (!conversation.name || conversation.name === 'Unknown group')) {
console.log('[vince] isPublic:', isPublic); continue;
console.log('[vince] isPublic:', isPublic); }
console.log('[vince] isPublic:', isPublic);
// 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 // Remove all invalid conversations and conversatons of devices associated with cancelled attempted links
if (!conversation.timestamp) { if (!conversation.isPublic && !conversation.timestamp) {
continue; continue;
} }
@ -139,7 +147,7 @@ export const _getLeftPaneLists = (
unreadCount += conversation.unreadCount; unreadCount += conversation.unreadCount;
} }
if (!conversation.activeAt) { if (!conversation.isPublic && !conversation.activeAt) {
continue; continue;
} }

Loading…
Cancel
Save