Addressing PR comments

This commit is contained in:
warrickct 2021-11-24 09:32:07 +11:00
parent 2d664a2df7
commit 726418887c
4 changed files with 44 additions and 34 deletions

View file

@ -377,15 +377,13 @@ const ConversationListItem = (props: Props) => {
<SessionButton
onClick={handleConversationBlock}
buttonColor={SessionButtonColor.Danger}
text={window.i18n('block')}
>
Block
</SessionButton>
text={window.i18n('blockUser')}
/>
<SessionButton
buttonColor={SessionButtonColor.Green}
onClick={handleConversationAccept}
text={window.i18n('accept')}
></SessionButton>
/>
</Flex>
) : null}
</div>

View file

@ -221,6 +221,33 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
this.handleToggleOverlay(SessionClosableOverlayType.MessageRequests);
}
/**
* Blocks all message request conversations and synchronizes across linked devices
* @returns void
*/
private async handleBlockAllRequestsClick() {
// block all convo requests. Force sync if there were changes.
window?.log?.info('Blocking all conversations');
const { conversationRequests } = this.props;
let syncRequired = false;
if (!conversationRequests) {
window?.log?.info('No conversation requests to block.');
return;
}
await Promise.all(
conversationRequests.map(async convo => {
await BlockedNumberController.block(convo.id);
syncRequired = true;
})
);
if (syncRequired) {
await forceSyncConfigurationNowIfNeeded();
}
}
private renderClosableOverlay() {
const { searchTerm, searchResults } = this.props;
const { loading, overlay } = this.state;
@ -278,28 +305,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
onCloseClick={() => {
this.handleToggleOverlay(undefined);
}}
onButtonClick={async () => {
// block all convo requests. Force sync if there were changes.
window?.log?.info('Blocking all conversations');
const { conversationRequests } = this.props;
let syncRequired = false;
if (!conversationRequests) {
window?.log?.info('No conversation requests to block.');
return;
}
await Promise.all(
conversationRequests.map(async convo => {
await BlockedNumberController.block(convo.id);
syncRequired = true;
})
);
if (syncRequired) {
await forceSyncConfigurationNowIfNeeded();
}
}}
onButtonClick={this.handleBlockAllRequestsClick}
searchTerm={searchTerm}
searchResults={searchResults}
showSpinner={loading}

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import { createOrUpdateItem } from '../data/data';
import { createOrUpdateItem, getItemById, hasSyncedInitialConfigurationItem } from '../data/data';
import { ConversationTypeEnum } from '../models/conversation';
import {
joinOpenGroupV2WithUIEvents,
@ -59,6 +59,18 @@ async function handleGroupsAndContactsFromConfigMessage(
value: true,
});
const didWeHandleAConfigurationMessageAlready =
(await getItemById(hasSyncedInitialConfigurationItem))?.value || false;
if (didWeHandleAConfigurationMessageAlready) {
window?.log?.info(
'Dropping configuration groups change as we already handled one... Only handling contacts '
);
if (configMessage.contacts?.length) {
await Promise.all(configMessage.contacts.map(async c => handleContactReceived(c, envelope)));
}
return;
}
const numberClosedGroup = configMessage.closedGroups?.length || 0;
window?.log?.info(

View file

@ -266,12 +266,6 @@ export class ConversationController {
return Array.from(this.conversations.models);
}
public getConversationRequests(): Array<ConversationModel> {
return Array.from(this.conversations.models).filter(
conversation => conversation.isApproved() && !conversation.isBlocked
);
}
public unsafeDelete(convo: ConversationModel) {
this.conversations.remove(convo);
}