Yarn formatting and linting.

pull/1745/head
Warrick Corfe-Tan 4 years ago
parent 264f97663e
commit 49415e3bf0

@ -79,14 +79,14 @@ 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) ? const pinIcon =
<SessionIcon conversationListItemType === ConversationListItemType.Conversation && isPinned ? (
iconType={SessionIconType.Pin} <SessionIcon
iconColor={this.props.theme.colors.textColorSubtle} iconType={SessionIconType.Pin}
iconSize={SessionIconSize.Tiny} /> iconColor={this.props.theme.colors.textColorSubtle}
: iconSize={SessionIconSize.Tiny}
null; />
) : null;
return ( return (
<div className="module-conversation-list-item__header"> <div className="module-conversation-list-item__header">
@ -97,7 +97,6 @@ class ConversationListItem extends React.PureComponent<Props> {
)} )}
> >
{this.renderUser()} {this.renderUser()}
</div> </div>
{pinIcon} {pinIcon}

@ -1,7 +1,5 @@
import React from 'react'; import React from 'react';
import _ from 'lodash';
import { AutoSizer, List } from 'react-virtualized'; import { AutoSizer, List } from 'react-virtualized';
import { MainViewController } from '../MainViewController'; import { MainViewController } from '../MainViewController';
import { import {
ConversationListItemProps, ConversationListItemProps,
@ -11,7 +9,7 @@ import {
import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations'; import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations';
import { SearchResults, SearchResultsProps } from '../SearchResults'; import { SearchResults, SearchResultsProps } from '../SearchResults';
import { SessionSearchInput } from './SessionSearchInput'; import { SessionSearchInput } from './SessionSearchInput';
import { debounce } from 'lodash'; import _, { debounce } from 'lodash';
import { cleanSearchTerm } from '../../util/cleanSearchTerm'; import { cleanSearchTerm } from '../../util/cleanSearchTerm';
import { SearchOptions } from '../../types/Search'; import { SearchOptions } from '../../types/Search';
import { RowRendererParamsType } from '../LeftPane'; import { RowRendererParamsType } from '../LeftPane';
@ -31,8 +29,6 @@ import autoBind from 'auto-bind';
import { onsNameRegex } from '../../session/snode_api/SNodeAPI'; import { onsNameRegex } from '../../session/snode_api/SNodeAPI';
import { SNodeAPI } from '../../session/snode_api'; import { SNodeAPI } from '../../session/snode_api';
import { createClosedGroup } from '../../receiver/closedGroups';
export interface Props { export interface Props {
searchTerm: string; searchTerm: string;
@ -89,8 +85,8 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
throw new Error('renderRow: Tried to render without conversations'); throw new Error('renderRow: Tried to render without conversations');
} }
conversations = _.sortBy([...conversations], (convo) => { conversations = _.sortBy([...conversations], convo => {
return convo.isPinned ? -1 : 1 return convo.isPinned ? -1 : 1;
}); });
const conversation = conversations[index]; const conversation = conversations[index];
@ -107,8 +103,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
}; };
public renderList(): JSX.Element | Array<JSX.Element | null> { public renderList(): JSX.Element | Array<JSX.Element | null> {
let { conversations } = this.props; const { conversations, openConversationExternal, searchResults } = this.props;
const { openConversationExternal, searchResults } = this.props;
const contacts = searchResults?.contacts || []; const contacts = searchResults?.contacts || [];
if (searchResults) { if (searchResults) {

@ -13,7 +13,7 @@ import {
getInviteContactMenuItem, getInviteContactMenuItem,
getLeaveGroupMenuItem, getLeaveGroupMenuItem,
getMarkAllReadMenuItem, getMarkAllReadMenuItem,
MenuItemPinConversation MenuItemPinConversation,
} from './Menu'; } from './Menu';
export type PropsContextConversationItem = { export type PropsContextConversationItem = {
@ -47,7 +47,9 @@ export const ConversationListItemContextMenu = (props: PropsContextConversationI
const isGroup = type === 'group'; const isGroup = type === 'group';
const isConversation = conversationListItemType === ConversationListItemType.Conversation; const isConversation = conversationListItemType === ConversationListItemType.Conversation;
const pinMenuItem = isConversation ? <MenuItemPinConversation conversationId={conversationId} /> : null; const pinMenuItem = isConversation ? (
<MenuItemPinConversation conversationId={conversationId} />
) : null;
return ( return (
<> <>

@ -5,10 +5,7 @@ import { Item, Submenu } from 'react-contexify';
import { ConversationNotificationSettingType } from '../../../models/conversation'; import { ConversationNotificationSettingType } from '../../../models/conversation';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { actions as conversationActions } from '../../../state/ducks/conversations'; import { actions as conversationActions } from '../../../state/ducks/conversations';
import { import { changeNickNameModal, updateConfirmModal } from '../../../state/ducks/modalDialog';
changeNickNameModal,
updateConfirmModal,
} from '../../../state/ducks/modalDialog';
import { getConversationController } from '../../../session/conversations'; import { getConversationController } from '../../../session/conversations';
import { import {
blockConvoById, blockConvoById,
@ -129,21 +126,26 @@ export interface PinConversationMenuItemProps {
conversationId: string; conversationId: string;
} }
export const MenuItemPinConversation = (props: PinConversationMenuItemProps): JSX.Element | null => { export const MenuItemPinConversation = (
props: PinConversationMenuItemProps
): JSX.Element | null => {
const { conversationId } = props; const { conversationId } = props;
const conversation = getConversationController().get(conversationId).getProps(); const conversation = getConversationController()
.get(conversationId)
.getProps();
const { isPinned } = conversation; const { isPinned } = conversation;
const togglePinConversation = () => { const togglePinConversation = () => {
window.inboxStore?.dispatch(conversationActions.conversationChanged(conversationId, window.inboxStore?.dispatch(
{ conversationActions.conversationChanged(conversationId, {
...conversation, ...conversation,
isPinned: !isPinned isPinned: !isPinned,
})) })
} );
const menuText = isPinned ? window.i18n('unpinConversation'): window.i18n('pinConversation'); };
return <Item onClick={togglePinConversation}>{menuText}</Item> const menuText = isPinned ? window.i18n('unpinConversation') : window.i18n('pinConversation');
} return <Item onClick={togglePinConversation}>{menuText}</Item>;
};
export function getDeleteContactMenuItem( export function getDeleteContactMenuItem(
isMe: boolean | undefined, isMe: boolean | undefined,
@ -317,7 +319,7 @@ export function getDisappearingMenuItem(
// Remove the && false to make context menu work with RTL support // Remove the && false to make context menu work with RTL support
<Submenu <Submenu
label={window.i18n('disappearingMessages') as any} label={window.i18n('disappearingMessages') as any}
// rtl={isRtlMode && false} // rtl={isRtlMode && false}
> >
{(timerOptions || []).map(item => ( {(timerOptions || []).map(item => (
<Item <Item
@ -350,7 +352,7 @@ export function getNotificationForConvoMenuItem(
// Remove the && false to make context menu work with RTL support // Remove the && false to make context menu work with RTL support
<Submenu <Submenu
label={window.i18n('notificationForConvo') as any} label={window.i18n('notificationForConvo') as any}
// rtl={isRtlMode && false} // rtl={isRtlMode && false}
> >
{(notificationForConvoOptions || []).map(item => { {(notificationForConvoOptions || []).map(item => {
const disabled = item.value === currentNotificationSetting; const disabled = item.value === currentNotificationSetting;

@ -408,14 +408,10 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
left: !!this.get('left'), left: !!this.get('left'),
groupAdmins, groupAdmins,
members, members,
isPinned: this.getIsPinned() || false isPinned: this.getIsPinned() || false,
}; };
} }
private getIsPinned() {
return window.inboxStore?.getState().conversations.conversationLookup[this.id].isPinned;
}
public async updateGroupAdmins(groupAdmins: Array<string>) { public async updateGroupAdmins(groupAdmins: Array<string>) {
const existingAdmins = _.uniq(_.sortBy(this.getGroupAdmins())); const existingAdmins = _.uniq(_.sortBy(this.getGroupAdmins()));
const newAdmins = _.uniq(_.sortBy(groupAdmins)); const newAdmins = _.uniq(_.sortBy(groupAdmins));
@ -506,9 +502,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
fileName: fileName || null, fileName: fileName || null,
thumbnail: thumbnail thumbnail: thumbnail
? { ? {
...(await loadAttachmentData(thumbnail)), ...(await loadAttachmentData(thumbnail)),
objectUrl: getAbsoluteAttachmentPath(thumbnail.path), objectUrl: getAbsoluteAttachmentPath(thumbnail.path),
} }
: null, : null,
}; };
}) })
@ -531,9 +527,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
fileName: null, fileName: null,
thumbnail: image thumbnail: image
? { ? {
...(await loadAttachmentData(image)), ...(await loadAttachmentData(image)),
objectUrl: getAbsoluteAttachmentPath(image.path), objectUrl: getAbsoluteAttachmentPath(image.path),
} }
: null, : null,
}; };
}) })
@ -1441,6 +1437,10 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return typeof expireTimer === 'number' && expireTimer > 0; return typeof expireTimer === 'number' && expireTimer > 0;
} }
private getIsPinned() {
return window.inboxStore?.getState().conversations.conversationLookup[this.id].isPinned;
}
} }
export class ConversationCollection extends Backbone.Collection<ConversationModel> { export class ConversationCollection extends Backbone.Collection<ConversationModel> {

@ -29,7 +29,7 @@ const logger = createLogger({
export const persistConfig = { export const persistConfig = {
key: 'root', key: 'root',
storage, storage,
whitelist: ['userConfig'] whitelist: ['userConfig'],
}; };
const persistedReducer = persistReducer(persistConfig, allReducers); const persistedReducer = persistReducer(persistConfig, allReducers);

@ -82,7 +82,7 @@ export interface ConversationType {
avatarPath?: string; // absolute filepath to the avatar avatarPath?: string; // absolute filepath to the avatar
groupAdmins?: Array<string>; // admins for closed groups and moderators for open groups groupAdmins?: Array<string>; // admins for closed groups and moderators for open groups
members?: Array<string>; // members for closed groups only members?: Array<string>; // members for closed groups only
isPinned?: boolean isPinned?: boolean;
} }
export type ConversationLookupType = { export type ConversationLookupType = {

@ -16,6 +16,8 @@ import { userConfigReducer as userConfig, UserConfigState } from './ducks/userCo
// tslint:disable-next-line: no-submodule-imports match-default-export-name // tslint:disable-next-line: no-submodule-imports match-default-export-name
import storage from 'redux-persist/lib/storage'; import storage from 'redux-persist/lib/storage';
// tslint:disable-next-line: no-submodule-imports match-default-export-name
import persistReducer from 'redux-persist/lib/persistReducer'; import persistReducer from 'redux-persist/lib/persistReducer';
export type StateType = { export type StateType = {
@ -34,8 +36,8 @@ export type StateType = {
const conversationsPersistConfig = { const conversationsPersistConfig = {
key: 'conversations', key: 'conversations',
storage, storage,
whitelist: ['conversationLookup'] whitelist: ['conversationLookup'],
} };
export const reducers = { export const reducers = {
search, search,

@ -137,7 +137,7 @@ async function bouncyDeleteAccount(reason?: string) {
window.localStorage.setItem('restart-reason', reason || ''); window.localStorage.setItem('restart-reason', reason || '');
if (window.inboxStore) { if (window.inboxStore) {
// warrick: this part might be redundant due to localStorage getting cleared. // warrick: this part might be redundant due to localStorage getting cleared.
persistStore(window.inboxStore).purge(); await persistStore(window.inboxStore).purge();
} }
}; };
try { try {

Loading…
Cancel
Save