pull/1279/head
Vincent 5 years ago
parent 704d5a1184
commit bf32cd3ae6

@ -603,7 +603,6 @@
isModerator, isModerator,
onCopyText: () => this.copyText(), onCopyText: () => this.copyText(),
onSelectMessage: () => this.selectMessage(),
onSelectMessageUnchecked: () => this.selectMessageUnchecked(), onSelectMessageUnchecked: () => this.selectMessageUnchecked(),
onCopyPubKey: () => this.copyPubKey(), onCopyPubKey: () => this.copyPubKey(),
onBanUser: () => this.banUser(), onBanUser: () => this.banUser(),
@ -957,14 +956,6 @@
this.trigger('change'); this.trigger('change');
}, },
selectMessage() {
if (window.contextMenuShown || this.get('isRss')) {
return;
}
this.selectMessageUnchecked();
},
copyText() { copyText() {
clipboard.writeText(this.get('body')); clipboard.writeText(this.get('body'));

@ -141,6 +141,7 @@ $composition-container-height: 60px;
height: 0; height: 0;
background-color: inherit; background-color: inherit;
outline: none; outline: none;
position: relative;
&__blocking-overlay { &__blocking-overlay {
background-color: rgba(0, 0, 0, 0.8); background-color: rgba(0, 0, 0, 0.8);

@ -113,7 +113,6 @@ export interface Props {
onClickLinkPreview?: (url: string) => void; onClickLinkPreview?: (url: string) => void;
onCopyText?: () => void; onCopyText?: () => void;
onSelectMessage: (messageId: string) => void; onSelectMessage: (messageId: string) => void;
onSelectMessageUnchecked: () => void;
onReply?: () => void; onReply?: () => void;
onRetrySend?: () => void; onRetrySend?: () => void;
onDownload?: (isDangerous: boolean) => void; onDownload?: (isDangerous: boolean) => void;
@ -919,7 +918,6 @@ export class Message extends React.PureComponent<Props, State> {
const { const {
attachments, attachments,
onCopyText, onCopyText,
onSelectMessageUnchecked,
direction, direction,
status, status,
isDeletable, isDeletable,
@ -966,8 +964,6 @@ export class Message extends React.PureComponent<Props, State> {
const isServerDeletable = !!this.props.isPublic; const isServerDeletable = !!this.props.isPublic;
const deleteMessageCtxText = i18n(isServerDeletable ? 'unsend' : 'delete'); const deleteMessageCtxText = i18n(isServerDeletable ? 'unsend' : 'delete');
// CONTEXT MENU "Select Message" does not work
return ( return (
<ContextMenu <ContextMenu
id={triggerId} id={triggerId}
@ -991,9 +987,6 @@ export class Message extends React.PureComponent<Props, State> {
) : null} ) : null}
<MenuItem onClick={wrap(onCopyText)}>{i18n('copyMessage')}</MenuItem> <MenuItem onClick={wrap(onCopyText)}>{i18n('copyMessage')}</MenuItem>
<MenuItem onClick={wrap(onSelectMessageUnchecked)}>
{i18n('selectMessage')}
</MenuItem>
<MenuItem <MenuItem
attributes={{ attributes={{
className: 'module-message__context__reply', className: 'module-message__context__reply',

@ -127,11 +127,16 @@ export class SessionConversation extends React.Component<any, State> {
// Keyboard navigation // Keyboard navigation
this.onKeyDown = this.onKeyDown.bind(this); this.onKeyDown = this.onKeyDown.bind(this);
const conversationModel = window.ConversationController.get(this.state.conversationKey); const conversationModel = window.ConversationController.get(
this.state.conversationKey
);
conversationModel.on('change', () => { conversationModel.on('change', () => {
this.setState({ this.setState(
{
messages: conversationModel.messageCollection.models, messages: conversationModel.messageCollection.models,
}); },
this.updateReadMessages
);
}); });
} }
@ -162,16 +167,15 @@ export class SessionConversation extends React.Component<any, State> {
this.scrollToBottom(); this.scrollToBottom();
} }
// New messages get from message collection. // New messages get from message collection.
const messageCollection = window.ConversationController.get(this.state.conversationKey).messageCollection; const messageCollection = window.ConversationController.get(
this.state.conversationKey
).messageCollection;
console.log('[vince] messageCollection:', messageCollection); console.log('[vince] messageCollection:', messageCollection);
console.log('[vince] this.state.messages:', this.state.messages); console.log('[vince] this.state.messages:', this.state.messages);
} }
public async componentWillReceiveProps(nextProps: any) { public async componentWillReceiveProps(nextProps: any) {}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~ RENDER METHODS ~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~ RENDER METHODS ~~~~~~~~~~~~~~
@ -288,7 +292,6 @@ export class SessionConversation extends React.Component<any, State> {
} }
public renderMessages(messages: any) { public renderMessages(messages: any) {
const multiSelectMode = Boolean(this.state.selectedMessages.length); const multiSelectMode = Boolean(this.state.selectedMessages.length);
// FIXME VINCE: IF MESSAGE IS THE TOP OF UNREAD, THEN INSERT AN UNREAD BANNER // FIXME VINCE: IF MESSAGE IS THE TOP OF UNREAD, THEN INSERT AN UNREAD BANNER
@ -381,7 +384,9 @@ export class SessionConversation extends React.Component<any, State> {
// in the conversation model. // in the conversation model.
// The only time we need to call getMessages() is to grab more messages on scroll. // The only time we need to call getMessages() is to grab more messages on scroll.
const { conversationKey, initialFetchComplete } = this.state; const { conversationKey, initialFetchComplete } = this.state;
const conversationModel = window.ConversationController.get(conversationKey); const conversationModel = window.ConversationController.get(
conversationKey
);
if (initialFetchComplete) { if (initialFetchComplete) {
return; return;
@ -389,7 +394,10 @@ export class SessionConversation extends React.Component<any, State> {
const messageSet = await window.Signal.Data.getMessagesByConversation( const messageSet = await window.Signal.Data.getMessagesByConversation(
conversationKey, conversationKey,
{ limit: Constants.CONVERSATION.DEFAULT_MESSAGE_FETCH_COUNT, MessageCollection: window.Whisper.MessageCollection } {
limit: Constants.CONVERSATION.DEFAULT_MESSAGE_FETCH_COUNT,
MessageCollection: window.Whisper.MessageCollection,
}
); );
const messages = messageSet.models; const messages = messageSet.models;
@ -410,7 +418,9 @@ export class SessionConversation extends React.Component<any, State> {
fetchInterval = Constants.CONVERSATION.MESSAGE_FETCH_INTERVAL fetchInterval = Constants.CONVERSATION.MESSAGE_FETCH_INTERVAL
) { ) {
const { conversationKey, messageFetchTimestamp } = this.state; const { conversationKey, messageFetchTimestamp } = this.state;
const conversationModel = window.ConversationController.get(conversationKey); const conversationModel = window.ConversationController.get(
conversationKey
);
const timestamp = getTimestamp(); const timestamp = getTimestamp();
// If we have pulled messages in the last interval, don't bother rescanning // If we have pulled messages in the last interval, don't bother rescanning
@ -770,9 +780,11 @@ export class SessionConversation extends React.Component<any, State> {
public async deleteSelectedMessages() { public async deleteSelectedMessages() {
// Get message objects // Get message objects
const selectedMessages = this.state.messages.filter(message => this.state.selectedMessages.find( const selectedMessages = this.state.messages.filter(message =>
this.state.selectedMessages.find(
selectedMessage => selectedMessage === message.id selectedMessage => selectedMessage === message.id
)); )
);
const { conversationKey } = this.state; const { conversationKey } = this.state;
const conversationModel = window.ConversationController.get( const conversationModel = window.ConversationController.get(
@ -793,7 +805,9 @@ export class SessionConversation extends React.Component<any, State> {
? window.i18n('deleteMultiplePublicWarning') ? window.i18n('deleteMultiplePublicWarning')
: window.i18n('deletePublicWarning'); : window.i18n('deletePublicWarning');
} }
return multiple ? window.i18n('deleteMultipleWarning') : window.i18n('deleteWarning'); return multiple
? window.i18n('deleteMultipleWarning')
: window.i18n('deleteWarning');
})(); })();
const doDelete = async () => { const doDelete = async () => {
@ -807,7 +821,9 @@ export class SessionConversation extends React.Component<any, State> {
if (!ourDevicePubkey) { if (!ourDevicePubkey) {
return; return;
} }
const ourPrimaryPubkey = (await MultiDeviceProtocol.getPrimaryDevice(ourDevicePubkey)).key; const ourPrimaryPubkey = (
await MultiDeviceProtocol.getPrimaryDevice(ourDevicePubkey)
).key;
const isModerator = conversationModel.isModerator(ourPrimaryPubkey); const isModerator = conversationModel.isModerator(ourPrimaryPubkey);
const isAllOurs = selectedMessages.every( const isAllOurs = selectedMessages.every(
message => message =>
@ -821,16 +837,21 @@ export class SessionConversation extends React.Component<any, State> {
id: 'messageDeletionForbidden', id: 'messageDeletionForbidden',
}); });
this.setState({ selectedMessages: [] });
return; return;
} }
toDeleteLocally = await conversationModel.deletePublicMessages(selectedMessages); toDeleteLocally = await conversationModel.deletePublicMessages(
selectedMessages
);
if (toDeleteLocally.length === 0) { if (toDeleteLocally.length === 0) {
// Message failed to delete from server, show error? // Message failed to delete from server, show error?
return; return;
} }
} else { } else {
selectedMessages.forEach(m => conversationModel.messageCollection.remove(m.id)); selectedMessages.forEach(m =>
conversationModel.messageCollection.remove(m.id)
);
toDeleteLocally = selectedMessages; toDeleteLocally = selectedMessages;
} }
@ -859,9 +880,7 @@ export class SessionConversation extends React.Component<any, State> {
// If removable from server, we "Unsend" - otherwise "Delete" // If removable from server, we "Unsend" - otherwise "Delete"
const pluralSuffix = multiple ? 's' : ''; const pluralSuffix = multiple ? 's' : '';
const title = window.i18n( const title = window.i18n(
isPublic isPublic ? `unsendMessage${pluralSuffix}` : `deleteMessage${pluralSuffix}`
? `unsendMessage${pluralSuffix}`
: `deleteMessage${pluralSuffix}`
); );
const okText = window.i18n(isServerDeletable ? 'unsend' : 'delete'); const okText = window.i18n(isServerDeletable ? 'unsend' : 'delete');

Loading…
Cancel
Save