mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Addressing PR comments
This commit is contained in:
parent
9823a700e2
commit
b5df47c2b8
|
@ -302,7 +302,7 @@ const ConversationListItem = (props: Props) => {
|
|||
* adds ID to block list, syncs the block with linked devices.
|
||||
*/
|
||||
const handleConversationBlock = async () => {
|
||||
blockConvoById(conversationId);
|
||||
await blockConvoById(conversationId);
|
||||
await forceSyncConfigurationNowIfNeeded();
|
||||
};
|
||||
|
||||
|
@ -371,8 +371,8 @@ const ConversationListItem = (props: Props) => {
|
|||
/>
|
||||
<SessionButton
|
||||
buttonColor={SessionButtonColor.Green}
|
||||
onClick={() => {
|
||||
approveConversation(conversationId);
|
||||
onClick={async () => {
|
||||
await approveConversation(conversationId);
|
||||
}}
|
||||
text={window.i18n('accept')}
|
||||
/>
|
||||
|
|
|
@ -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 { getConversationRequests, getLeftPaneLists } from '../state/selectors/conversations';
|
||||
import { getLeftPaneLists } from '../state/selectors/conversations';
|
||||
import { getQuery, getSearchResults, isSearching } from '../state/selectors/search';
|
||||
import { SectionType } from '../state/ducks/section';
|
||||
|
||||
|
@ -29,14 +29,12 @@ 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={conversationRequests}
|
||||
searchResults={searchResults}
|
||||
searchTerm={searchTerm}
|
||||
/>
|
||||
|
|
|
@ -37,7 +37,6 @@ export interface Props {
|
|||
|
||||
contacts: Array<ReduxConversationType>;
|
||||
conversations?: Array<ConversationListItemProps>;
|
||||
conversationRequests?: Array<ConversationListItemProps>;
|
||||
searchResults?: SearchResultsProps;
|
||||
}
|
||||
|
||||
|
@ -226,9 +225,47 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
|
|||
* @returns void
|
||||
*/
|
||||
private async handleBlockAllRequestsClick() {
|
||||
let messageRequestsEnabled = false;
|
||||
if (window?.inboxStore?.getState()) {
|
||||
messageRequestsEnabled =
|
||||
window.inboxStore?.getState().userConfig.messageRequests === true &&
|
||||
window.lokiFeatureFlags?.useMessageRequests === true;
|
||||
}
|
||||
if (!messageRequestsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// block all convo requests. Force sync if there were changes.
|
||||
window?.log?.info('Blocking all conversations');
|
||||
const { conversationRequests } = this.props;
|
||||
const conversations = getConversationController().getConversations();
|
||||
|
||||
if (!conversations) {
|
||||
window?.log?.info('No message requests to block.');
|
||||
return;
|
||||
}
|
||||
|
||||
const conversationRequests = conversations.filter(conversation => {
|
||||
// Add Open Group to list as soon as the name has been set
|
||||
if (
|
||||
conversation.isPublic() &&
|
||||
(!conversation.get('name') || conversation.get('name') === 'Unknown group')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove all invalid conversations and conversatons of devices associated
|
||||
// with cancelled attempted links
|
||||
if (!conversation.isPublic && !conversation.get('active_at')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (conversation.attributes.isApproved || !conversation.get('active_at')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
let syncRequired = false;
|
||||
|
||||
if (!conversationRequests) {
|
||||
|
|
|
@ -92,7 +92,9 @@ export const MessageRequestsBanner = (props: { handleOnClick: () => any }) => {
|
|||
return (
|
||||
<StyledMessageRequestBanner onClick={handleOnClick}>
|
||||
<CirclularIcon iconType="messageRequest" iconSize="medium" />
|
||||
<StyledMessageRequestBannerHeader>{window.i18n('messageRequests')}</StyledMessageRequestBannerHeader>
|
||||
<StyledMessageRequestBannerHeader>
|
||||
{window.i18n('messageRequests')}
|
||||
</StyledMessageRequestBannerHeader>
|
||||
<StyledUnreadCounter>
|
||||
<div>{conversationRequests.length || 0}</div>
|
||||
</StyledUnreadCounter>
|
||||
|
|
|
@ -1042,7 +1042,12 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
const model = new MessageModel(messageAttributes);
|
||||
|
||||
const isMe = messageAttributes.source === UserUtils.getOurPubKeyStrFromCache();
|
||||
if (isMe) {
|
||||
|
||||
if (
|
||||
isMe &&
|
||||
window.lokiFeatureFlags.useMessageRequests &&
|
||||
window.inboxStore?.getState().userConfig.messageRequests
|
||||
) {
|
||||
await this.setIsApproved(true);
|
||||
}
|
||||
|
||||
|
@ -1288,11 +1293,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
isApproved: value,
|
||||
});
|
||||
|
||||
// to exclude the conversation from left pane messages list and message requests
|
||||
if (value === false) {
|
||||
this.set({ active_at: undefined });
|
||||
}
|
||||
|
||||
await this.commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,14 +138,14 @@ const handleContactReceived = async (
|
|||
contactConvo.set('active_at', _.toNumber(envelope.timestamp));
|
||||
|
||||
if (
|
||||
window.lokiFeatureFlags.useMessageRequests === true &&
|
||||
window.lokiFeatureFlags.useMessageRequests &&
|
||||
window.inboxStore?.getState().userConfig.messageRequests
|
||||
) {
|
||||
if (contactReceived.isApproved === true) {
|
||||
if (contactReceived.isApproved) {
|
||||
await contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
|
||||
}
|
||||
|
||||
if (contactReceived.isBlocked === true) {
|
||||
if (contactReceived.isBlocked) {
|
||||
await BlockedNumberController.block(contactConvo.id);
|
||||
} else {
|
||||
await BlockedNumberController.unblock(contactConvo.id);
|
||||
|
|
|
@ -236,7 +236,6 @@ export class ConversationController {
|
|||
if (conversation.isPrivate()) {
|
||||
window.log.info(`deleteContact isPrivate, marking as inactive: ${id}`);
|
||||
|
||||
// conversation.set('active_at', undefined);
|
||||
conversation.set({
|
||||
active_at: undefined,
|
||||
isApproved: false,
|
||||
|
|
Loading…
Reference in a new issue