fix deleteMessages from headermenu and load unread_count message on show

pull/1381/head
Audric Ackermann 5 years ago
parent e613613416
commit 21a97ba0ec
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -92,6 +92,8 @@ export interface ConversationModel
makeQuote: any; makeQuote: any;
unblock: any; unblock: any;
deleteContact: any; deleteContact: any;
deleteMessages();
endSession: () => Promise<void>; endSession: () => Promise<void>;
block: any; block: any;
copyPublicKey: any; copyPublicKey: any;

@ -2234,8 +2234,6 @@
}, },
deleteMessages() { deleteMessages() {
this.resetMessageSelection();
let params; let params;
if (this.isPublic()) { if (this.isPublic()) {
throw new Error( throw new Error(

@ -334,13 +334,18 @@ export class SessionConversation extends React.Component<Props, State> {
if (this.state.initialFetchComplete) { if (this.state.initialFetchComplete) {
return; return;
} }
const { conversationKey } = this.props;
return this.getMessages( const conversationModel = window.ConversationController.getOrThrow(
conversationKey
);
const unreadCount = await conversationModel.getUnreadCount();
const messagesToFetch = Math.max(
Constants.CONVERSATION.DEFAULT_MESSAGE_FETCH_COUNT, Constants.CONVERSATION.DEFAULT_MESSAGE_FETCH_COUNT,
() => { unreadCount
this.setState({ initialFetchComplete: true });
}
); );
return this.getMessages(messagesToFetch, () => {
this.setState({ initialFetchComplete: true });
});
} }
// tslint:disable-next-line: no-empty // tslint:disable-next-line: no-empty
@ -440,7 +445,7 @@ export class SessionConversation extends React.Component<Props, State> {
onSetDisappearingMessages: (seconds: any) => onSetDisappearingMessages: (seconds: any) =>
conversation.updateExpirationTimer(seconds), conversation.updateExpirationTimer(seconds),
onDeleteMessages: () => null, onDeleteMessages: () => conversation.deleteMessages(),
onDeleteSelectedMessages: this.deleteSelectedMessages, onDeleteSelectedMessages: this.deleteSelectedMessages,
onCloseOverlay: () => { onCloseOverlay: () => {
this.setState({ selectedMessages: [] }); this.setState({ selectedMessages: [] });

@ -135,6 +135,16 @@ export class SessionConversationMessagesList extends React.Component<
if (findFirstUnreadIndex === -1 && conversation.unreadCount !== 0) { if (findFirstUnreadIndex === -1 && conversation.unreadCount !== 0) {
findFirstUnreadIndex = messages.length - 1; findFirstUnreadIndex = messages.length - 1;
} }
if (conversation.unreadCount === 0) {
findFirstUnreadIndex = -1;
}
// console.log(
// 'findFirstUnreadIndex',
// findFirstUnreadIndex,
// 'unreadCount',
// conversation.unreadCount
// );
return ( return (
<> <>
{messages.map((message: MessageModel) => { {messages.map((message: MessageModel) => {
@ -165,8 +175,8 @@ export class SessionConversationMessagesList extends React.Component<
if (groupNotificationProps) { if (groupNotificationProps) {
return ( return (
<> <>
{unreadIndicator}
<GroupNotification {...groupNotificationProps} /> <GroupNotification {...groupNotificationProps} />
{unreadIndicator}
</> </>
); );
} }
@ -174,8 +184,8 @@ export class SessionConversationMessagesList extends React.Component<
if (propsForGroupInvitation) { if (propsForGroupInvitation) {
return ( return (
<> <>
{unreadIndicator}
<GroupInvitation {...propsForGroupInvitation} /> <GroupInvitation {...propsForGroupInvitation} />
{unreadIndicator}
</> </>
); );
} }
@ -183,8 +193,8 @@ export class SessionConversationMessagesList extends React.Component<
if (verificationSessionProps) { if (verificationSessionProps) {
return ( return (
<> <>
{unreadIndicator}
<VerificationNotification {...verificationSessionProps} /> <VerificationNotification {...verificationSessionProps} />
{unreadIndicator}
</> </>
); );
} }
@ -192,8 +202,8 @@ export class SessionConversationMessagesList extends React.Component<
if (resetSessionProps) { if (resetSessionProps) {
return ( return (
<> <>
{unreadIndicator}
<ResetSessionNotification {...resetSessionProps} /> <ResetSessionNotification {...resetSessionProps} />
{unreadIndicator}
</> </>
); );
} }
@ -201,8 +211,8 @@ export class SessionConversationMessagesList extends React.Component<
if (timerProps) { if (timerProps) {
return ( return (
<> <>
{unreadIndicator}
<TimerNotification {...timerProps} /> <TimerNotification {...timerProps} />
{unreadIndicator}
</> </>
); );
} }
@ -211,12 +221,12 @@ export class SessionConversationMessagesList extends React.Component<
// in a series of messages from the same user // in a series of messages from the same user
return ( return (
<> <>
{unreadIndicator}
{this.renderMessage( {this.renderMessage(
messageProps, messageProps,
message.firstMessageOfSeries, message.firstMessageOfSeries,
multiSelectMode multiSelectMode
)} )}
{unreadIndicator}
</> </>
); );
})} })}

Loading…
Cancel
Save