remove friends from UI logic

pull/1178/head
Audric Ackermann 5 years ago
parent 66de8d9648
commit eb9a838af1
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -469,6 +469,7 @@ async function updateToSchemaVersion6(currentVersion, instance) {
console.log('updateToSchemaVersion6: starting...'); console.log('updateToSchemaVersion6: starting...');
await instance.run('BEGIN TRANSACTION;'); await instance.run('BEGIN TRANSACTION;');
// friendRequestStatus is no longer needed. So no need to add the column on new apps
// await instance.run( // await instance.run(
// `ALTER TABLE conversations // `ALTER TABLE conversations
// ADD COLUMN friendRequestStatus INTEGER;` // ADD COLUMN friendRequestStatus INTEGER;`
@ -2015,7 +2016,6 @@ async function getAllConversations() {
return map(rows, row => jsonToObject(row.json)); return map(rows, row => jsonToObject(row.json));
} }
async function getAllConversationIds() { async function getAllConversationIds() {
const rows = await db.all( const rows = await db.all(
`SELECT id FROM ${CONVERSATIONS_TABLE} ORDER BY id ASC;` `SELECT id FROM ${CONVERSATIONS_TABLE} ORDER BY id ASC;`

@ -1177,9 +1177,9 @@
} }
}); });
Whisper.events.on('inviteFriends', async groupConvo => { Whisper.events.on('inviteContacts', async groupConvo => {
if (appView) { if (appView) {
appView.showInviteFriendsDialog(groupConvo); appView.showInviteContactsDialog(groupConvo);
} }
}); });

@ -315,9 +315,15 @@
// We don't send typing messages if the setting is disabled or we do not have a session // We don't send typing messages if the setting is disabled or we do not have a session
// or we blocked that user // or we blocked that user
const devicePubkey = new libsession.Types.PubKey(this.id); const devicePubkey = new libsession.Types.PubKey(this.id);
const hasSession = await libsession.Protocols.SessionProtocol.hasSession(devicePubkey); const hasSession = await libsession.Protocols.SessionProtocol.hasSession(
devicePubkey
);
if (!storage.get('typing-indicators-setting') || !hasSession || this.isBlocked()) { if (
!storage.get('typing-indicators-setting') ||
!hasSession ||
this.isBlocked()
) {
return; return;
} }
@ -747,7 +753,6 @@
// otherwise, enable the input and set default placeholder // otherwise, enable the input and set default placeholder
this.trigger('disable:input', false); this.trigger('disable:input', false);
this.trigger('change:placeholder', 'chat'); this.trigger('change:placeholder', 'chat');
}, },
isSecondaryDevice() { isSecondaryDevice() {
return !!this.get('secondaryStatus'); return !!this.get('secondaryStatus');
@ -1399,10 +1404,7 @@
await serverAPI.setAvatar(url, profileKey); await serverAPI.setAvatar(url, profileKey);
}, },
async handleMessageSendResult({ async handleMessageSendResult({ failoverNumbers, unidentifiedDeliveries }) {
failoverNumbers,
unidentifiedDeliveries,
}) {
await Promise.all( await Promise.all(
(failoverNumbers || []).map(async number => { (failoverNumbers || []).map(async number => {
const conversation = ConversationController.get(number); const conversation = ConversationController.get(number);
@ -2009,7 +2011,9 @@
read = read.filter(item => !item.hasErrors); read = read.filter(item => !item.hasErrors);
const devicePubkey = new libsession.Types.PubKey(this.id); const devicePubkey = new libsession.Types.PubKey(this.id);
const hasSession = await libsession.Protocols.SessionProtocol.hasSession(devicePubkey); const hasSession = await libsession.Protocols.SessionProtocol.hasSession(
devicePubkey
);
if (hasSession) { if (hasSession) {
return; return;
} }

@ -1,4 +1,3 @@
type MessageModelType = 'incoming' | 'outgoing'; type MessageModelType = 'incoming' | 'outgoing';
export type EndSessionType = 'done' | 'ongoing'; export type EndSessionType = 'done' | 'ongoing';

@ -1968,7 +1968,7 @@ class LokiPublicChannelAPI {
const messageData = { const messageData = {
serverId: adnMessage.id, serverId: adnMessage.id,
clientVerified: true, clientVerified: true,
friendRequest: false, isSessionRequest: false,
source: pubKey, source: pubKey,
sourceDevice: 1, sourceDevice: 1,
timestamp, timestamp,

@ -120,7 +120,7 @@ class LokiRssAPI extends EventEmitter {
// if we use group style, we can put the title in the source // if we use group style, we can put the title in the source
const messageData = { const messageData = {
friendRequest: false, isSessionRequest: false,
source: this.groupId, source: this.groupId,
sourceDevice: 1, sourceDevice: 1,
timestamp: pubDate.getTime(), timestamp: pubDate.getTime(),

@ -39,9 +39,6 @@ const {
EmbeddedContact, EmbeddedContact,
} = require('../../ts/components/conversation/EmbeddedContact'); } = require('../../ts/components/conversation/EmbeddedContact');
const { Emojify } = require('../../ts/components/conversation/Emojify'); const { Emojify } = require('../../ts/components/conversation/Emojify');
const {
FriendRequest,
} = require('../../ts/components/conversation/FriendRequest');
const { const {
GroupNotification, GroupNotification,
} = require('../../ts/components/conversation/GroupNotification'); } = require('../../ts/components/conversation/GroupNotification');
@ -286,7 +283,6 @@ exports.setup = (options = {}) => {
SettingsView, SettingsView,
EmbeddedContact, EmbeddedContact,
Emojify, Emojify,
FriendRequest,
GroupNotification, GroupNotification,
Lightbox, Lightbox,
LightboxGallery, LightboxGallery,

@ -259,8 +259,8 @@
resolve: () => ConversationController.deleteContact(groupConvo.id), resolve: () => ConversationController.deleteContact(groupConvo.id),
}); });
}, },
showInviteFriendsDialog(groupConvo) { showInviteContactsDialog(groupConvo) {
const dialog = new Whisper.InviteFriendsDialogView(groupConvo); const dialog = new Whisper.InviteContactsDialogView(groupConvo);
this.el.append(dialog.el); this.el.append(dialog.el);
}, },
showAddModeratorsDialog(groupConvo) { showAddModeratorsDialog(groupConvo) {

@ -241,8 +241,8 @@
window.Whisper.events.trigger('leaveGroup', this.model); window.Whisper.events.trigger('leaveGroup', this.model);
}, },
onInviteFriends: () => { onInviteContacts: () => {
window.Whisper.events.trigger('inviteFriends', this.model); window.Whisper.events.trigger('inviteContacts', this.model);
}, },
onUpdateGroupName: () => { onUpdateGroupName: () => {
@ -312,8 +312,8 @@
window.Whisper.events.trigger('leaveGroup', this.model); window.Whisper.events.trigger('leaveGroup', this.model);
}, },
onInviteFriends: () => { onInviteContacts: () => {
window.Whisper.events.trigger('inviteFriends', this.model); window.Whisper.events.trigger('inviteContacts', this.model);
}, },
onShowLightBox: (lightBoxOptions = {}) => { onShowLightBox: (lightBoxOptions = {}) => {
this.showChannelLightbox(lightBoxOptions); this.showChannelLightbox(lightBoxOptions);

@ -16,9 +16,7 @@
const convos = window.getConversations().models; const convos = window.getConversations().models;
let allMembers = convos.filter( let allMembers = convos.filter(d => !!d && d.isPrivate() && !d.isMe());
d => !!d && d.isPrivate() && !d.isMe()
);
allMembers = _.uniq(allMembers, true, d => d.id); allMembers = _.uniq(allMembers, true, d => d.id);
this.membersToShow = allMembers; this.membersToShow = allMembers;
@ -34,7 +32,7 @@
titleText: this.titleText, titleText: this.titleText,
okText: this.okText, okText: this.okText,
cancelText: this.cancelText, cancelText: this.cancelText,
friendList: this.membersToShow, contactList: this.membersToShow,
onClose: this.close, onClose: this.close,
}, },
}); });
@ -130,8 +128,8 @@
this.isAdmin = groupConvo.isModerator( this.isAdmin = groupConvo.isModerator(
window.storage.get('primaryDevicePubKey') window.storage.get('primaryDevicePubKey')
); );
// zero out friendList for now // zero out contactList for now
this.friendsAndMembers = []; this.contactsAndMembers = [];
this.existingMembers = []; this.existingMembers = [];
} else { } else {
this.titleText = i18n('updateGroupDialogTitle'); this.titleText = i18n('updateGroupDialogTitle');
@ -140,11 +138,11 @@
this.existingMembers = groupConvo.get('members') || []; this.existingMembers = groupConvo.get('members') || [];
// Show a contact if they are our friend or if they are a member // Show a contact if they are our friend or if they are a member
this.friendsAndMembers = convos.filter( this.contactsAndMembers = convos.filter(
d => this.existingMembers.includes(d.id) && d.isPrivate() && !d.isMe() d => this.existingMembers.includes(d.id) && d.isPrivate() && !d.isMe()
); );
this.friendsAndMembers = _.uniq( this.contactsAndMembers = _.uniq(
this.friendsAndMembers, this.contactsAndMembers,
true, true,
d => d.id d => d.id
); );
@ -168,7 +166,7 @@
cancelText: i18n('cancel'), cancelText: i18n('cancel'),
isPublic: this.isPublic, isPublic: this.isPublic,
existingMembers: this.existingMembers, existingMembers: this.existingMembers,
friendList: this.friendsAndMembers, contactList: this.contactsAndMembers,
isAdmin: this.isAdmin, isAdmin: this.isAdmin,
onClose: this.close, onClose: this.close,
onSubmit: this.onSubmit, onSubmit: this.onSubmit,

@ -6,7 +6,7 @@
window.Whisper = window.Whisper || {}; window.Whisper = window.Whisper || {};
Whisper.InviteFriendsDialogView = Whisper.View.extend({ Whisper.InviteContactsDialogView = Whisper.View.extend({
className: 'loki-dialog modal', className: 'loki-dialog modal',
initialize(convo) { initialize(convo) {
this.close = this.close.bind(this); this.close = this.close.bind(this);
@ -14,9 +14,7 @@
const convos = window.getConversations().models; const convos = window.getConversations().models;
this.contacts = convos.filter( this.contacts = convos.filter(d => !!d && d.isPrivate() && !d.isMe());
d => !!d && d.isPrivate() && !d.isMe()
);
if (!convo.isPublic()) { if (!convo.isPublic()) {
const members = convo.get('members') || []; const members = convo.get('members') || [];
this.contacts = this.contacts.filter(d => !members.includes(d.id)); this.contacts = this.contacts.filter(d => !members.includes(d.id));
@ -36,7 +34,7 @@
className: 'invite-friends-dialog', className: 'invite-friends-dialog',
Component: window.Signal.Components.InviteFriendsDialog, Component: window.Signal.Components.InviteFriendsDialog,
props: { props: {
friendList: this.contacts, contactList: this.contacts,
onSubmit: this.submit, onSubmit: this.submit,
onClose: this.close, onClose: this.close,
chatName: this.chatName, chatName: this.chatName,

@ -74,11 +74,6 @@
Component: Components.ResetSessionNotification, Component: Components.ResetSessionNotification,
props: this.model.getPropsForResetSessionNotification(), props: this.model.getPropsForResetSessionNotification(),
}; };
} else if (this.model.propsForFriendRequest) {
return {
Component: Components.FriendRequest,
props: this.model.propsForFriendRequest,
};
} else if (this.model.propsForGroupInvitation) { } else if (this.model.propsForGroupInvitation) {
return { return {
Component: Components.GroupInvitation, Component: Components.GroupInvitation,

@ -23,11 +23,7 @@
// private friends (not you) that aren't already moderators // private friends (not you) that aren't already moderators
const contacts = convos.filter( const contacts = convos.filter(
d => d => !!d && d.isPrivate() && !d.isMe() && !modPubKeys.includes(d.id)
!!d &&
d.isPrivate() &&
!d.isMe() &&
!modPubKeys.includes(d.id)
); );
this.contacts = contacts; this.contacts = contacts;
@ -40,7 +36,7 @@
className: 'add-moderators-dialog', className: 'add-moderators-dialog',
Component: window.Signal.Components.AddModeratorsDialog, Component: window.Signal.Components.AddModeratorsDialog,
props: { props: {
friendList: this.contacts, contactList: this.contacts,
chatName: this.chatName, chatName: this.chatName,
onSubmit: this.onSubmit, onSubmit: this.onSubmit,
onClose: this.close, onClose: this.close,

@ -8,12 +8,10 @@
const DebugFlagsEnum = { const DebugFlagsEnum = {
GROUP_SYNC_MESSAGES: 1, GROUP_SYNC_MESSAGES: 1,
CONTACT_SYNC_MESSAGES: 2, CONTACT_SYNC_MESSAGES: 2,
AUTO_FRIEND_REQUEST_MESSAGES: 4,
SESSION_REQUEST_MESSAGES: 8, SESSION_REQUEST_MESSAGES: 8,
SESSION_MESSAGE_SENDING: 16, SESSION_MESSAGE_SENDING: 16,
SESSION_BACKGROUND_MESSAGE: 32, SESSION_BACKGROUND_MESSAGE: 32,
GROUP_REQUEST_INFO: 64, GROUP_REQUEST_INFO: 64,
NORMAL_FRIEND_REQUEST_MESSAGES: 128,
// If you add any new flag, be sure it is bitwise safe! (unique and 2 multiples) // If you add any new flag, be sure it is bitwise safe! (unique and 2 multiples)
ALL: 65535, ALL: 65535,
}; };
@ -50,18 +48,6 @@
} }
} }
function logAutoFriendRequest(...args) {
if (debugFlags & DebugFlagsEnum.AUTO_FRIEND_REQUEST_MESSAGES) {
debugLogFn(...args);
}
}
function logNormalFriendRequest(...args) {
if (debugFlags & DebugFlagsEnum.NORMAL_FRIEND_REQUEST_MESSAGES) {
debugLogFn(...args);
}
}
function logSessionRequest(...args) { function logSessionRequest(...args) {
if (debugFlags & DebugFlagsEnum.SESSION_REQUEST_MESSAGES) { if (debugFlags & DebugFlagsEnum.SESSION_REQUEST_MESSAGES) {
debugLogFn(...args); debugLogFn(...args);
@ -304,12 +290,10 @@
const debug = { const debug = {
logContactSync, logContactSync,
logGroupSync, logGroupSync,
logAutoFriendRequest,
logSessionRequest, logSessionRequest,
logSessionMessageSending, logSessionMessageSending,
logBackgroundMessage, logBackgroundMessage,
logGroupRequestInfo, logGroupRequestInfo,
logNormalFriendRequest,
}; };
window.libloki.api = { window.libloki.api = {

@ -106,9 +106,6 @@ function getStaleDeviceIdsForNumber(number) {
} }
const DebugMessageType = { const DebugMessageType = {
AUTO_FR_REQUEST: 'auto-friend-request',
AUTO_FR_ACCEPT: 'auto-friend-accept',
SESSION_REQUEST: 'session-request', SESSION_REQUEST: 'session-request',
SESSION_REQUEST_ACCEPT: 'session-request-accepted', SESSION_REQUEST_ACCEPT: 'session-request-accepted',
@ -357,8 +354,6 @@ OutgoingMessage.prototype = {
const updatedDevices = await getStaleDeviceIdsForNumber(devicePubKey); const updatedDevices = await getStaleDeviceIdsForNumber(devicePubKey);
const keysFound = await this.getKeysForNumber(devicePubKey, updatedDevices); const keysFound = await this.getKeysForNumber(devicePubKey, updatedDevices);
// Check if we need to attach the preKeys // Check if we need to attach the preKeys
const enableFallBackEncryption = const enableFallBackEncryption =
!keysFound || this.messageType === 'session-request'; !keysFound || this.messageType === 'session-request';
@ -580,7 +575,7 @@ OutgoingMessage.prototype = {
if (!outgoingObject) { if (!outgoingObject) {
return; return;
} }
const { pubKey: destination, ttl, isSessionRequest } = outgoingObject; const { pubKey: destination, ttl } = outgoingObject;
try { try {
const socketMessage = wrapInWebsocketMessage( const socketMessage = wrapInWebsocketMessage(

@ -1177,7 +1177,6 @@ MessageSender.prototype = {
throw error; throw error;
}; };
// The actual deletion of the session now happens later // The actual deletion of the session now happens later
// as we need to ensure the other contact has successfully // as we need to ensure the other contact has successfully
// switch to a new session first. // switch to a new session first.

@ -117,12 +117,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
} }
public renderHeader() { public renderHeader() {
const { const { unreadCount, i18n, isMe, lastUpdated } = this.props;
unreadCount,
i18n,
isMe,
lastUpdated,
} = this.props;
return ( return (
<div className="module-conversation-list-item__header"> <div className="module-conversation-list-item__header">
@ -137,7 +132,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
{isMe ? i18n('noteToSelf') : this.renderUser()} {isMe ? i18n('noteToSelf') : this.renderUser()}
</div> </div>
{this.renderUnread()} {this.renderUnread()}
{( {
<div <div
className={classNames( className={classNames(
'module-conversation-list-item__header__date', 'module-conversation-list-item__header__date',
@ -146,16 +141,16 @@ export class ConversationListItem extends React.PureComponent<Props> {
: null : null
)} )}
> >
{( {
<Timestamp <Timestamp
timestamp={lastUpdated} timestamp={lastUpdated}
extended={false} extended={false}
module="module-conversation-list-item__header__timestamp" module="module-conversation-list-item__header__timestamp"
i18n={i18n} i18n={i18n}
/> />
)} }
</div> </div>
)} }
</div> </div>
); );
} }
@ -214,12 +209,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
} }
public renderMessage() { public renderMessage() {
const { const { lastMessage, isTyping, unreadCount, i18n } = this.props;
lastMessage,
isTyping,
unreadCount,
i18n,
} = this.props;
if (!lastMessage && !isTyping) { if (!lastMessage && !isTyping) {
return null; return null;

@ -12,7 +12,6 @@ import { LocalizerType } from '../types/Util';
export type PropsData = { export type PropsData = {
contacts: Array<ConversationListItemPropsType>; contacts: Array<ConversationListItemPropsType>;
friends: Array<ConversationListItemPropsType>;
conversations: Array<ConversationListItemPropsType>; conversations: Array<ConversationListItemPropsType>;
hideMessagesHeader: boolean; hideMessagesHeader: boolean;
messages: Array<MessageSearchResultPropsType>; messages: Array<MessageSearchResultPropsType>;

@ -89,7 +89,7 @@ interface Props {
onLeaveGroup: () => void; onLeaveGroup: () => void;
onAddModerators: () => void; onAddModerators: () => void;
onRemoveModerators: () => void; onRemoveModerators: () => void;
onInviteFriends: () => void; onInviteContacts: () => void;
onAvatarClick?: (userPubKey: string) => void; onAvatarClick?: (userPubKey: string) => void;
onUpdateGroupName: () => void; onUpdateGroupName: () => void;
@ -300,7 +300,7 @@ export class ConversationHeader extends React.Component<Props> {
onLeaveGroup, onLeaveGroup,
onAddModerators, onAddModerators,
onRemoveModerators, onRemoveModerators,
onInviteFriends, onInviteContacts,
onUpdateGroupName, onUpdateGroupName,
} = this.props; } = this.props;
@ -333,7 +333,9 @@ export class ConversationHeader extends React.Component<Props> {
) : null} ) : null}
{/* TODO: add delete group */} {/* TODO: add delete group */}
{isGroup && isPublic ? ( {isGroup && isPublic ? (
<MenuItem onClick={onInviteFriends}>{i18n('inviteFriends')}</MenuItem> <MenuItem onClick={onInviteContacts}>
{i18n('inviteContacts')}
</MenuItem>
) : null} ) : null}
{!isMe && isClosable && !isPrivateGroup ? ( {!isMe && isClosable && !isPrivateGroup ? (
!isPublic ? ( !isPublic ? (

@ -17,13 +17,13 @@ interface Props {
titleText: string; titleText: string;
okText: string; okText: string;
cancelText: string; cancelText: string;
friendList: Array<any>; contactList: Array<any>;
i18n: any; i18n: any;
onClose: any; onClose: any;
} }
interface State { interface State {
friendList: Array<Contact>; contactList: Array<Contact>;
groupName: string; groupName: string;
errorDisplayed: boolean; errorDisplayed: boolean;
errorMessage: string; errorMessage: string;
@ -39,9 +39,9 @@ export class CreateGroupDialog extends React.Component<Props, State> {
this.closeDialog = this.closeDialog.bind(this); this.closeDialog = this.closeDialog.bind(this);
this.onGroupNameChanged = this.onGroupNameChanged.bind(this); this.onGroupNameChanged = this.onGroupNameChanged.bind(this);
let friends = this.props.friendList; let contacts = this.props.contactList;
friends = friends.map(d => { contacts = contacts.map(d => {
const lokiProfile = d.getLokiProfile(); const lokiProfile = d.getLokiProfile();
const name = lokiProfile ? lokiProfile.displayName : 'Anonymous'; const name = lokiProfile ? lokiProfile.displayName : 'Anonymous';
@ -57,7 +57,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
}); });
this.state = { this.state = {
friendList: friends, contactList: contacts,
groupName: '', groupName: '',
errorDisplayed: false, errorDisplayed: false,
// if empty, the initial height is 0, which is not desirable // if empty, the initial height is 0, which is not desirable
@ -68,7 +68,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
} }
public onClickOK() { public onClickOK() {
const members = this.state.friendList const members = this.state.contactList
.filter(d => d.checkmarked) .filter(d => d.checkmarked)
.map(d => d.id); .map(d => d.id);
@ -118,7 +118,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
/> />
<div className="friend-selection-list"> <div className="friend-selection-list">
<MemberList <MemberList
members={this.state.friendList} members={this.state.contactList}
selected={{}} selected={{}}
i18n={this.props.i18n} i18n={this.props.i18n}
onMemberClicked={this.onMemberClicked} onMemberClicked={this.onMemberClicked}
@ -182,7 +182,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
private getMemberCount() { private getMemberCount() {
// Add 1 to include yourself // Add 1 to include yourself
return this.state.friendList.filter(d => d.checkmarked).length + 1; return this.state.contactList.filter(d => d.checkmarked).length + 1;
} }
private closeDialog() { private closeDialog() {
@ -192,7 +192,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
} }
private onMemberClicked(selected: any) { private onMemberClicked(selected: any) {
const updatedFriends = this.state.friendList.map(member => { const updatedContacts = this.state.contactList.map(member => {
if (member.id === selected.id) { if (member.id === selected.id) {
return { ...member, checkmarked: !member.checkmarked }; return { ...member, checkmarked: !member.checkmarked };
} else { } else {
@ -201,7 +201,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
}); });
if ( if (
updatedFriends.filter(d => d.checkmarked).length > updatedContacts.filter(d => d.checkmarked).length >
window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT - 1 window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT - 1
) { ) {
const msg = `${this.props.i18n('maxGroupMembersError')} ${ const msg = `${this.props.i18n('maxGroupMembersError')} ${
@ -215,7 +215,7 @@ export class CreateGroupDialog extends React.Component<Props, State> {
this.setState(state => { this.setState(state => {
return { return {
...state, ...state,
friendList: updatedFriends, contactList: updatedContacts,
}; };
}); });
} }

@ -8,14 +8,14 @@ import {
} from '../session/SessionMemberListItem'; } from '../session/SessionMemberListItem';
interface Props { interface Props {
friendList: Array<any>; contactList: Array<any>;
chatName: string; chatName: string;
onSubmit: any; onSubmit: any;
onClose: any; onClose: any;
} }
interface State { interface State {
friendList: Array<ContactType>; contactList: Array<ContactType>;
} }
export class InviteFriendsDialog extends React.Component<Props, State> { export class InviteFriendsDialog extends React.Component<Props, State> {
@ -27,9 +27,9 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
this.onClickOK = this.onClickOK.bind(this); this.onClickOK = this.onClickOK.bind(this);
this.onKeyUp = this.onKeyUp.bind(this); this.onKeyUp = this.onKeyUp.bind(this);
let friends = this.props.friendList; let contacts = this.props.contactList;
friends = friends.map(d => { contacts = contacts.map(d => {
const lokiProfile = d.getLokiProfile(); const lokiProfile = d.getLokiProfile();
const name = lokiProfile ? lokiProfile.displayName : 'Anonymous'; const name = lokiProfile ? lokiProfile.displayName : 'Anonymous';
@ -49,7 +49,7 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
}); });
this.state = { this.state = {
friendList: friends, contactList: contacts,
}; };
window.addEventListener('keyup', this.onKeyUp); window.addEventListener('keyup', this.onKeyUp);
@ -60,7 +60,7 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
const cancelText = window.i18n('cancel'); const cancelText = window.i18n('cancel');
const okText = window.i18n('ok'); const okText = window.i18n('ok');
const hasFriends = this.state.friendList.length !== 0; const hasContacts = this.state.contactList.length !== 0;
return ( return (
<SessionModal <SessionModal
@ -71,7 +71,7 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
<div className="spacer-lg" /> <div className="spacer-lg" />
<div className="friend-selection-list">{this.renderMemberList()}</div> <div className="friend-selection-list">{this.renderMemberList()}</div>
{hasFriends ? null : ( {hasContacts ? null : (
<> <>
<div className="spacer-lg" /> <div className="spacer-lg" />
<p className="no-friends">{window.i18n('noFriendsToAdd')}</p> <p className="no-friends">{window.i18n('noFriendsToAdd')}</p>
@ -85,7 +85,7 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
<SessionButton text={cancelText} onClick={this.closeDialog} /> <SessionButton text={cancelText} onClick={this.closeDialog} />
<SessionButton <SessionButton
text={okText} text={okText}
disabled={!hasFriends} disabled={!hasContacts}
onClick={this.onClickOK} onClick={this.onClickOK}
/> />
</div> </div>
@ -94,19 +94,19 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
} }
private onClickOK() { private onClickOK() {
const selectedFriends = this.state.friendList const selectedContacts = this.state.contactList
.filter(d => d.checkmarked) .filter(d => d.checkmarked)
.map(d => d.id); .map(d => d.id);
if (selectedFriends.length > 0) { if (selectedContacts.length > 0) {
this.props.onSubmit(selectedFriends); this.props.onSubmit(selectedContacts);
} }
this.closeDialog(); this.closeDialog();
} }
private renderMemberList() { private renderMemberList() {
const members = this.state.friendList; const members = this.state.contactList;
return members.map((member: ContactType, index: number) => ( return members.map((member: ContactType, index: number) => (
<SessionMemberListItem <SessionMemberListItem
@ -138,7 +138,7 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
} }
private onMemberClicked(clickedMember: ContactType) { private onMemberClicked(clickedMember: ContactType) {
const updatedFriends = this.state.friendList.map(member => { const updatedContacts = this.state.contactList.map(member => {
if (member.id === clickedMember.id) { if (member.id === clickedMember.id) {
return { ...member, checkmarked: !member.checkmarked }; return { ...member, checkmarked: !member.checkmarked };
} else { } else {
@ -149,7 +149,7 @@ export class InviteFriendsDialog extends React.Component<Props, State> {
this.setState(state => { this.setState(state => {
return { return {
...state, ...state,
friendList: updatedFriends, contactList: updatedContacts,
}; };
}); });
} }

@ -3,7 +3,7 @@ import { Contact, MemberList } from './MemberList';
import { cleanSearchTerm } from '../../util/cleanSearchTerm'; import { cleanSearchTerm } from '../../util/cleanSearchTerm';
interface Props { interface Props {
friendList: Array<any>; contactList: Array<any>;
chatName: string; chatName: string;
onSubmit: any; onSubmit: any;
onClose: any; onClose: any;
@ -16,7 +16,7 @@ declare global {
} }
interface State { interface State {
friendList: Array<Contact>; contactList: Array<Contact>;
inputBoxValue: string; inputBoxValue: string;
} }
@ -37,8 +37,8 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
this.onKeyUp = this.onKeyUp.bind(this); this.onKeyUp = this.onKeyUp.bind(this);
this.inputRef = React.createRef(); this.inputRef = React.createRef();
let friends = this.props.friendList; let contacts = this.props.contactList;
friends = friends.map(d => { contacts = contacts.map(d => {
const lokiProfile = d.getLokiProfile(); const lokiProfile = d.getLokiProfile();
const name = lokiProfile ? lokiProfile.displayName : 'Anonymous'; const name = lokiProfile ? lokiProfile.displayName : 'Anonymous';
@ -57,7 +57,7 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
}; };
}); });
this.state = { this.state = {
friendList: friends, contactList: contacts,
inputBoxValue: '', inputBoxValue: '',
}; };
@ -82,15 +82,15 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
public add() { public add() {
// if we have valid data // if we have valid data
if (this.state.inputBoxValue.length > 64) { if (this.state.inputBoxValue.length > 64) {
const weHave = this.state.friendList.some( const weHave = this.state.contactList.some(
user => user.authorPhoneNumber === this.state.inputBoxValue user => user.authorPhoneNumber === this.state.inputBoxValue
); );
if (!weHave) { if (!weHave) {
// lookup to verify it's registered? // lookup to verify it's registered?
// convert pubKey into local object... // convert pubKey into local object...
const friends = this.state.friendList; const contacts = this.state.contactList;
friends.push({ contacts.push({
id: this.state.inputBoxValue, id: this.state.inputBoxValue,
authorPhoneNumber: this.state.inputBoxValue, authorPhoneNumber: this.state.inputBoxValue,
authorProfileName: this.state.inputBoxValue, authorProfileName: this.state.inputBoxValue,
@ -104,7 +104,7 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
this.setState(state => { this.setState(state => {
return { return {
...state, ...state,
friendList: friends, contactList: contacts,
}; };
}); });
} }
@ -125,7 +125,7 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
public render() { public render() {
const i18n = window.i18n; const i18n = window.i18n;
const hasFriends = this.state.friendList.length !== 0; const hasContacts = this.state.contactList.length !== 0;
return ( return (
<div className="content"> <div className="content">
@ -150,13 +150,13 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
<p>From friends:</p> <p>From friends:</p>
<div className="friend-selection-list"> <div className="friend-selection-list">
<MemberList <MemberList
members={this.state.friendList} members={this.state.contactList}
selected={{}} selected={{}}
i18n={i18n} i18n={i18n}
onMemberClicked={this.onMemberClicked} onMemberClicked={this.onMemberClicked}
/> />
</div> </div>
{hasFriends ? null : ( {hasContacts ? null : (
<p className="no-friends">{i18n('noFriendsToAdd')}</p> <p className="no-friends">{i18n('noFriendsToAdd')}</p>
)} )}
</div> </div>
@ -174,11 +174,11 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
private onClickOK() { private onClickOK() {
this.add(); // process inputBox this.add(); // process inputBox
const selectedFriends = this.state.friendList const selectedContacts = this.state.contactList
.filter(d => d.checkmarked) .filter(d => d.checkmarked)
.map(d => d.id); .map(d => d.id);
if (selectedFriends.length > 0) { if (selectedContacts.length > 0) {
this.props.onSubmit(selectedFriends); this.props.onSubmit(selectedContacts);
} }
this.closeDialog(); this.closeDialog();
@ -204,7 +204,7 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
} }
private onMemberClicked(selected: any) { private onMemberClicked(selected: any) {
const updatedFriends = this.state.friendList.map(member => { const updatedContacts = this.state.contactList.map(member => {
if (member.id === selected.id) { if (member.id === selected.id) {
return { ...member, checkmarked: !member.checkmarked }; return { ...member, checkmarked: !member.checkmarked };
} else { } else {
@ -215,7 +215,7 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
this.setState(state => { this.setState(state => {
return { return {
...state, ...state,
friendList: updatedFriends, contactList: updatedContacts,
}; };
}); });
} }

@ -123,7 +123,7 @@ export class RemoveModeratorsDialog extends React.Component<Props, State> {
} }
private onModClicked(selected: any) { private onModClicked(selected: any) {
const updatedFriends = this.state.modList.map(member => { const updatedContacts = this.state.modList.map(member => {
if (member.id === selected.id) { if (member.id === selected.id) {
return { ...member, checkmarked: !member.checkmarked }; return { ...member, checkmarked: !member.checkmarked };
} else { } else {
@ -134,7 +134,7 @@ export class RemoveModeratorsDialog extends React.Component<Props, State> {
this.setState(state => { this.setState(state => {
return { return {
...state, ...state,
modList: updatedFriends, modList: updatedContacts,
}; };
}); });
} }

@ -14,8 +14,8 @@ interface Props {
okText: string; okText: string;
isPublic: boolean; isPublic: boolean;
cancelText: string; cancelText: string;
// friends not in the group // contacts not in the group
friendList: Array<any>; contactList: Array<any>;
isAdmin: boolean; isAdmin: boolean;
existingMembers: Array<String>; existingMembers: Array<String>;
i18n: any; i18n: any;
@ -24,7 +24,7 @@ interface Props {
} }
interface State { interface State {
friendList: Array<Contact>; contactList: Array<Contact>;
errorDisplayed: boolean; errorDisplayed: boolean;
errorMessage: string; errorMessage: string;
} }
@ -38,8 +38,8 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
this.onKeyUp = this.onKeyUp.bind(this); this.onKeyUp = this.onKeyUp.bind(this);
this.closeDialog = this.closeDialog.bind(this); this.closeDialog = this.closeDialog.bind(this);
let friends = this.props.friendList; let contacts = this.props.contactList;
friends = friends.map(d => { contacts = contacts.map(d => {
const lokiProfile = d.getLokiProfile(); const lokiProfile = d.getLokiProfile();
const name = lokiProfile ? lokiProfile.displayName : 'Anonymous'; const name = lokiProfile ? lokiProfile.displayName : 'Anonymous';
@ -58,7 +58,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
}); });
this.state = { this.state = {
friendList: friends, contactList: contacts,
errorDisplayed: false, errorDisplayed: false,
errorMessage: 'placeholder', errorMessage: 'placeholder',
}; };
@ -67,7 +67,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
} }
public onClickOK() { public onClickOK() {
const members = this.getWouldBeMembers(this.state.friendList).map( const members = this.getWouldBeMembers(this.state.contactList).map(
d => d.id d => d.id
); );
@ -77,7 +77,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
} }
public render() { public render() {
const checkMarkedCount = this.getMemberCount(this.state.friendList); const checkMarkedCount = this.getMemberCount(this.state.contactList);
const okText = this.props.okText; const okText = this.props.okText;
const cancelText = this.props.cancelText; const cancelText = this.props.cancelText;
@ -94,7 +94,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
// private group // private group
titleText = this.props.titleText; titleText = this.props.titleText;
noFriendsClasses = noFriendsClasses =
this.state.friendList.length === 0 this.state.contactList.length === 0
? 'no-friends' ? 'no-friends'
: classNames('no-friends', 'hidden'); : classNames('no-friends', 'hidden');
} }
@ -145,7 +145,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
} }
private renderMemberList() { private renderMemberList() {
const members = this.state.friendList; const members = this.state.contactList;
return members.map((member: ContactType, index: number) => ( return members.map((member: ContactType, index: number) => (
<SessionMemberListItem <SessionMemberListItem
@ -218,7 +218,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
return; return;
} }
const updatedFriends = this.state.friendList.map(member => { const updatedContacts = this.state.contactList.map(member => {
if (member.id === selected.id) { if (member.id === selected.id) {
return { ...member, checkmarked: !member.checkmarked }; return { ...member, checkmarked: !member.checkmarked };
} else { } else {
@ -229,7 +229,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
this.setState(state => { this.setState(state => {
return { return {
...state, ...state,
friendList: updatedFriends, contactList: updatedContacts,
}; };
}); });
} }

@ -126,10 +126,7 @@ export class ActionsPanel extends React.Component<Props, State> {
} }
public render(): JSX.Element { public render(): JSX.Element {
const { const { selectedSection, unreadMessageCount } = this.props;
selectedSection,
unreadMessageCount,
} = this.props;
const isProfilePageSelected = selectedSection === SectionType.Profile; const isProfilePageSelected = selectedSection === SectionType.Profile;
const isMessagePageSelected = selectedSection === SectionType.Message; const isMessagePageSelected = selectedSection === SectionType.Message;

@ -107,7 +107,6 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
); );
} }
public renderRow = ({ public renderRow = ({
index, index,
key, key,
@ -189,7 +188,6 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
})); }));
} }
private handleOnAddContact() { private handleOnAddContact() {
const sessionID = this.state.addContactRecipientID.trim(); const sessionID = this.state.addContactRecipientID.trim();
const error = validateNumber(sessionID, window.i18n); const error = validateNumber(sessionID, window.i18n);

@ -118,8 +118,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
let conversationList = conversations; let conversationList = conversations;
if (conversationList !== undefined) { if (conversationList !== undefined) {
conversationList = conversationList.filter( conversationList = conversationList.filter(
conversation => conversation => !conversation.isSecondary
!conversation.isSecondary
); );
} }

@ -24,7 +24,7 @@ interface Props {
isKickedFromGroup: boolean; isKickedFromGroup: boolean;
onGoBack: () => void; onGoBack: () => void;
onInviteFriends: () => void; onInviteContacts: () => void;
onLeaveGroup: () => void; onLeaveGroup: () => void;
onUpdateGroupName: () => void; onUpdateGroupName: () => void;
onUpdateGroupMembers: () => void; onUpdateGroupMembers: () => void;
@ -308,14 +308,14 @@ export class SessionGroupSettings extends React.Component<Props, any> {
const { const {
id, id,
onGoBack, onGoBack,
onInviteFriends, onInviteContacts,
avatarPath, avatarPath,
isAdmin, isAdmin,
isPublic, isPublic,
isKickedFromGroup, isKickedFromGroup,
} = this.props; } = this.props;
const showInviteFriends = (isPublic || isAdmin) && !isKickedFromGroup; const showInviteContacts = (isPublic || isAdmin) && !isKickedFromGroup;
return ( return (
<div className="group-settings-header"> <div className="group-settings-header">
@ -332,11 +332,11 @@ export class SessionGroupSettings extends React.Component<Props, any> {
size={80} size={80}
/> />
<div className="invite-friends-container"> <div className="invite-friends-container">
{showInviteFriends && ( {showInviteContacts && (
<SessionIconButton <SessionIconButton
iconType={SessionIconType.AddUser} iconType={SessionIconType.AddUser}
iconSize={SessionIconSize.Medium} iconSize={SessionIconSize.Medium}
onClick={onInviteFriends} onClick={onInviteContacts}
/> />
)} )}
</div> </div>

1
ts/global.d.ts vendored

@ -8,7 +8,6 @@ interface Window {
clearLocalData: any; clearLocalData: any;
getAccountManager: any; getAccountManager: any;
getConversations: any; getConversations: any;
getFriendsFromContacts: any;
mnemonic: any; mnemonic: any;
clipboard: any; clipboard: any;
attemptConnection: any; attemptConnection: any;

@ -47,8 +47,8 @@ export async function preprocessGroupMessage(
// NOTE: we use group admins to tell if this is // NOTE: we use group admins to tell if this is
// the creation of the group (initial update) // the creation of the group (initial update)
const groupAdminsSet = const groupAdminsSet =
conversation.get('groupAdmins') && conversation.get('groupAdmins') &&
conversation.get('groupAdmins').length > 0; conversation.get('groupAdmins').length > 0;
const newGroup = !groupAdminsSet; const newGroup = !groupAdminsSet;
const knownMembers = conversation.get('members'); const knownMembers = conversation.get('members');

@ -66,7 +66,6 @@ function initIncomingMessage(data: MessageCreationData): MessageModel {
isRss, // + isRss, // +
}; };
return new window.Whisper.Message(messageData); return new window.Whisper.Message(messageData);
} }
@ -217,7 +216,6 @@ async function isMessageDuplicate({
} }
} }
function getEnvelopeId(envelope: EnvelopePlus) { function getEnvelopeId(envelope: EnvelopePlus) {
if (envelope.source) { if (envelope.source) {
return `${envelope.source}.${envelope.sourceDevice} ${toNumber( return `${envelope.source}.${envelope.sourceDevice} ${toNumber(
@ -595,6 +593,8 @@ export async function handleMessageEvent(event: any): Promise<void> {
const isDuplicate = await isMessageDuplicate(data); const isDuplicate = await isMessageDuplicate(data);
const testNb: number = 3.1545;
if (isDuplicate) { if (isDuplicate) {
// RSS expects duplicates, so squelch log // RSS expects duplicates, so squelch log
if (!source.match(/^rss:/)) { if (!source.match(/^rss:/)) {

@ -124,10 +124,7 @@ export const _getLeftPaneLists = (
allContacts.push(conversation); allContacts.push(conversation);
} }
if ( if (unreadCount < 9 && conversation.unreadCount > 0) {
unreadCount < 9 &&
conversation.unreadCount > 0
) {
unreadCount += conversation.unreadCount; unreadCount += conversation.unreadCount;
} }

@ -25,7 +25,6 @@ interface WindowInterface extends Window {
clearLocalData: any; clearLocalData: any;
getAccountManager: any; getAccountManager: any;
getConversations: any; getConversations: any;
getFriendsFromContacts: any;
mnemonic: any; mnemonic: any;
clipboard: any; clipboard: any;
attemptConnection: any; attemptConnection: any;
@ -49,7 +48,6 @@ interface WindowInterface extends Window {
Session: any; Session: any;
log: any; log: any;
i18n: LocalizerType; i18n: LocalizerType;
friends: any;
generateID: any; generateID: any;
storage: any; storage: any;
pushToast: any; pushToast: any;
@ -106,7 +104,6 @@ export const lokiFeatureFlags = window.lokiFeatureFlags;
// Getters // Getters
export const getAccountManager = window.getAccountManager; export const getAccountManager = window.getAccountManager;
export const getConversations = window.getConversations; export const getConversations = window.getConversations;
export const getFriendsFromContacts = window.getFriendsFromContacts;
export const getSettingValue = window.getSettingValue; export const getSettingValue = window.getSettingValue;
// Setters // Setters

Loading…
Cancel
Save