Exclude showing pin icon and menu item for contacts list.

pull/1745/head
Warrick Corfe-Tan 4 years ago
parent 6dd7f34e4d
commit 60b3032833

@ -23,7 +23,11 @@ import { DefaultTheme, withTheme } from 'styled-components';
import { PubKey } from '../session/types'; import { PubKey } from '../session/types';
import { ConversationType, openConversationExternal } from '../state/ducks/conversations'; import { ConversationType, openConversationExternal } from '../state/ducks/conversations';
import { SessionIcon, SessionIconSize, SessionIconType } from './session/icon'; import { SessionIcon, SessionIconSize, SessionIconType } from './session/icon';
import { SessionButtonColor } from './session/SessionButton';
export enum ConversationListItemType {
Conversation = 'conversation',
Contact = 'contact',
}
export interface ConversationListItemProps extends ConversationType { export interface ConversationListItemProps extends ConversationType {
index?: number; // used to force a refresh when one conversation is removed on top of the list index?: number; // used to force a refresh when one conversation is removed on top of the list
@ -33,6 +37,7 @@ export interface ConversationListItemProps extends ConversationType {
type PropsHousekeeping = { type PropsHousekeeping = {
style?: Object; style?: Object;
theme: DefaultTheme; theme: DefaultTheme;
conversationListItemType: ConversationListItemType;
}; };
type Props = ConversationListItemProps & PropsHousekeeping; type Props = ConversationListItemProps & PropsHousekeeping;
@ -65,7 +70,7 @@ class ConversationListItem extends React.PureComponent<Props> {
} }
public renderHeader() { public renderHeader() {
const { unreadCount, mentionedUs, activeAt, isPinned } = this.props; const { unreadCount, mentionedUs, activeAt, isPinned, conversationListItemType } = this.props;
let atSymbol = null; let atSymbol = null;
let unreadCountDiv = null; let unreadCountDiv = null;
@ -74,6 +79,15 @@ class ConversationListItem extends React.PureComponent<Props> {
unreadCountDiv = <p className="module-conversation-list-item__unread-count">{unreadCount}</p>; unreadCountDiv = <p className="module-conversation-list-item__unread-count">{unreadCount}</p>;
} }
const pinIcon = (conversationListItemType === ConversationListItemType.Conversation && isPinned) ?
<SessionIcon
iconType={SessionIconType.Pin}
iconColor={this.props.theme.colors.textColorSubtle}
iconSize={SessionIconSize.Tiny} />
:
null;
return ( return (
<div className="module-conversation-list-item__header"> <div className="module-conversation-list-item__header">
<div <div
@ -85,13 +99,8 @@ class ConversationListItem extends React.PureComponent<Props> {
{this.renderUser()} {this.renderUser()}
</div> </div>
{isPinned ?
<SessionIcon {pinIcon}
iconType={SessionIconType.Pin}
iconColor={this.props.theme.colors.textColorSubtle}
iconSize={SessionIconSize.Tiny} />
: null
}
{unreadCountDiv} {unreadCountDiv}
{atSymbol} {atSymbol}
{ {

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { ConversationListItemWithDetails } from '../ConversationListItem'; import { ConversationListItemType, ConversationListItemWithDetails } from '../ConversationListItem';
import { RowRendererParamsType } from '../LeftPane'; import { RowRendererParamsType } from '../LeftPane';
import { AutoSizer, List } from 'react-virtualized'; import { AutoSizer, List } from 'react-virtualized';
import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations'; import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations';
@ -39,6 +39,7 @@ export class LeftPaneContactSection extends React.Component<Props> {
return ( return (
<ConversationListItemWithDetails <ConversationListItemWithDetails
conversationListItemType={ConversationListItemType.Contact}
key={item.id} key={item.id}
style={style} style={style}
{...item} {...item}

@ -5,6 +5,7 @@ import { AutoSizer, List } from 'react-virtualized';
import { MainViewController } from '../MainViewController'; import { MainViewController } from '../MainViewController';
import { import {
ConversationListItemProps, ConversationListItemProps,
ConversationListItemType,
ConversationListItemWithDetails, ConversationListItemWithDetails,
} from '../ConversationListItem'; } from '../ConversationListItem';
import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations'; import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations';
@ -97,6 +98,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
return ( return (
<ConversationListItemWithDetails <ConversationListItemWithDetails
key={key} key={key}
conversationListItemType={ConversationListItemType.Conversation}
style={style} style={style}
{...conversation} {...conversation}
onClick={openConversationExternal} onClick={openConversationExternal}

@ -1,6 +1,7 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { animation, Menu } from 'react-contexify'; import { animation, Menu } from 'react-contexify';
import { ConversationTypeEnum } from '../../../models/conversation'; import { ConversationTypeEnum } from '../../../models/conversation';
import { ConversationListItemType } from '../../ConversationListItem';
import { import {
getBlockMenuItem, getBlockMenuItem,
@ -19,6 +20,7 @@ export type PropsContextConversationItem = {
id: string; id: string;
triggerId: string; triggerId: string;
type: ConversationTypeEnum; type: ConversationTypeEnum;
conversationListItemType: ConversationListItemType;
isMe: boolean; isMe: boolean;
isPublic?: boolean; isPublic?: boolean;
isBlocked?: boolean; isBlocked?: boolean;
@ -39,15 +41,18 @@ export const ConversationListItemContextMenu = (props: PropsContextConversationI
type, type,
left, left,
isKickedFromGroup, isKickedFromGroup,
theme, conversationListItemType,
} = props; } = props;
const isGroup = type === 'group'; const isGroup = type === 'group';
const isConversation = conversationListItemType === ConversationListItemType.Conversation;
const pinMenuItem = isConversation ? <MenuItemPinConversation conversationId={conversationId} /> : null;
return ( return (
<> <>
<Menu id={triggerId} animation={animation.fade}> <Menu id={triggerId} animation={animation.fade}>
<MenuItemPinConversation conversationId={conversationId} /> {pinMenuItem}
{getBlockMenuItem(isMe, type === ConversationTypeEnum.PRIVATE, isBlocked, conversationId)} {getBlockMenuItem(isMe, type === ConversationTypeEnum.PRIVATE, isBlocked, conversationId)}
{getCopyMenuItem(isPublic, isGroup, conversationId)} {getCopyMenuItem(isPublic, isGroup, conversationId)}
{getMarkAllReadMenuItem(conversationId)} {getMarkAllReadMenuItem(conversationId)}

@ -25,8 +25,6 @@ import {
showUpdateGroupNameByConvoId, showUpdateGroupNameByConvoId,
unblockConvoById, unblockConvoById,
} from '../../../interactions/conversationInteractions'; } from '../../../interactions/conversationInteractions';
import { purgeStoredState } from 'redux-persist';
import { persistConfig, _purgedStoredState } from '../../../state/createStore';
function showTimerOptions( function showTimerOptions(
isPublic: boolean, isPublic: boolean,
@ -142,10 +140,6 @@ export const MenuItemPinConversation = (props: PinConversationMenuItemProps): JS
...conversation, ...conversation,
isPinned: !isPinned isPinned: !isPinned
})) }))
if (isPinned) {
// purgeStoredState(persistConfig);
}
} }
return <Item onClick={togglePinConversation}>{(isPinned ? 'Unpin' : 'Pin') + ' Conversation'}</Item> return <Item onClick={togglePinConversation}>{(isPinned ? 'Unpin' : 'Pin') + ' Conversation'}</Item>

@ -9,6 +9,7 @@ import { actions as userActions } from '../state/ducks/user';
import { mn_decode, mn_encode } from '../session/crypto/mnemonic'; import { mn_decode, mn_encode } from '../session/crypto/mnemonic';
import { ConversationTypeEnum } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
import _ from 'underscore'; import _ from 'underscore';
import { persistStore } from 'redux-persist';
/** /**
* Might throw * Might throw
@ -134,6 +135,10 @@ async function bouncyDeleteAccount(reason?: string) {
await window.Signal.Data.removeOtherData(); await window.Signal.Data.removeOtherData();
// 'unlink' => toast will be shown on app restart // 'unlink' => toast will be shown on app restart
window.localStorage.setItem('restart-reason', reason || ''); window.localStorage.setItem('restart-reason', reason || '');
if (window.inboxStore) {
// warrick: this part might be redundant due to localStorage getting cleared.
persistStore(window.inboxStore).purge();
}
}; };
try { try {
window?.log?.info('DeleteAccount => Sending a last SyncConfiguration'); window?.log?.info('DeleteAccount => Sending a last SyncConfiguration');

Loading…
Cancel
Save