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

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

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

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

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

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

@ -82,7 +82,7 @@ export interface ConversationType {
avatarPath?: string; // absolute filepath to the avatar
groupAdmins?: Array<string>; // admins for closed groups and moderators for open groups
members?: Array<string>; // members for closed groups only
isPinned?: boolean
isPinned?: boolean;
}
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
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';
export type StateType = {
@ -34,8 +36,8 @@ export type StateType = {
const conversationsPersistConfig = {
key: 'conversations',
storage,
whitelist: ['conversationLookup']
}
whitelist: ['conversationLookup'],
};
export const reducers = {
search,

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

Loading…
Cancel
Save