From dfbcf3ac9b920dfbd84222525e6f390d2f949556 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 4 Nov 2020 13:06:00 +1100 Subject: [PATCH] do not remove convo when removing only message use the user pubkey if group update notification with an unknown user make GroupNotification a function component --- js/models/conversations.js | 18 +++------- js/models/messages.js | 2 +- js/modules/signal.js | 4 --- .../conversation/GroupNotification.tsx | 34 +++++++++---------- .../conversation/SessionConversation.tsx | 1 + 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index a74d6d207..48fc105dc 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -2339,19 +2339,11 @@ this.messageCollection.reset([]); - // let's try to keep the RSS conversation open just empty... - if (this.isRss()) { - this.set({ - lastMessage: null, - }); - } else { - // this will remove the conversation from conversation lists... - this.set({ - lastMessage: null, - timestamp: null, - active_at: null, - }); - } + // destroy message keeps the active timestamp set so the + // conversation still appears on the conversation list but is empty + this.set({ + lastMessage: null, + }); await this.commit(); }, diff --git a/js/models/messages.js b/js/models/messages.js index 8af9b0e21..2ef114f0a 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -173,7 +173,7 @@ if (!conversation) { return number; } - return conversation.getProfileName(); + return conversation.getDisplayName(); }, getLokiNameForNumber(number) { const conversation = ConversationController.get(number); diff --git a/js/modules/signal.js b/js/modules/signal.js index 76c8a5d3c..4ab8b9caf 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -32,9 +32,6 @@ const { EmbeddedContact, } = require('../../ts/components/conversation/EmbeddedContact'); const { Emojify } = require('../../ts/components/conversation/Emojify'); -const { - GroupNotification, -} = require('../../ts/components/conversation/GroupNotification'); const { Lightbox } = require('../../ts/components/Lightbox'); const { LightboxGallery } = require('../../ts/components/LightboxGallery'); const { MemberList } = require('../../ts/components/conversation/MemberList'); @@ -261,7 +258,6 @@ exports.setup = (options = {}) => { SettingsView, EmbeddedContact, Emojify, - GroupNotification, Lightbox, LightboxGallery, MemberList, diff --git a/ts/components/conversation/GroupNotification.tsx b/ts/components/conversation/GroupNotification.tsx index 2a7e7b4a8..62efb4bf8 100644 --- a/ts/components/conversation/GroupNotification.tsx +++ b/ts/components/conversation/GroupNotification.tsx @@ -2,8 +2,6 @@ import React from 'react'; import { compact, flatten } from 'lodash'; import { Intl } from '../Intl'; -import { LocalizerType } from '../../types/Util'; - import { missingCaseError } from '../../util/missingCaseError'; interface Contact { @@ -23,10 +21,11 @@ interface Props { changes: Array; } -// This class is used to display group updates in the conversation view. +// This component is used to display group updates in the conversation view. // This is a not a "notification" as the name suggests, but a message inside the conversation -export class GroupNotification extends React.Component { - public renderChange(change: Change) { +export const GroupNotification = (props: Props) => { + + function renderChange(change: Change) { const { isMe, contacts, type, newName } = change; const { i18n } = window; @@ -94,17 +93,16 @@ export class GroupNotification extends React.Component { } } - public render() { - const { changes } = this.props; - - return ( -
- {(changes || []).map((change, index) => ( -
- {this.renderChange(change)} -
- ))} -
- ); - } + + const { changes } = props; + return ( +
+ {(changes || []).map((change, index) => ( +
+ {renderChange(change)} +
+ ))} +
+ ); + } diff --git a/ts/components/session/conversation/SessionConversation.tsx b/ts/components/session/conversation/SessionConversation.tsx index 803e73ced..1f10a01f4 100644 --- a/ts/components/session/conversation/SessionConversation.tsx +++ b/ts/components/session/conversation/SessionConversation.tsx @@ -134,6 +134,7 @@ export class SessionConversation extends React.Component { // this.getMessages.bind(this), // 1000 // one second // ); + this.getMessages = this.getMessages.bind(this); // Keyboard navigation this.onKeyDown = this.onKeyDown.bind(this);