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;
unblock: any;
deleteContact: any;
deleteMessages();
endSession: () => Promise<void>;
block: any;
copyPublicKey: any;

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

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

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

Loading…
Cancel
Save