remove optional setToExpire and UnreadMessageIsAbove indicator

pull/2142/head
Audric Ackermann 3 years ago
parent 4e638d162d
commit 9000c649f8
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -3,10 +3,9 @@ import React from 'react';
import { SessionScrollButton } from '../SessionScrollButton';
import { contextMenu } from 'react-contexify';
import { connect, useSelector } from 'react-redux';
import { connect } from 'react-redux';
import { SessionMessagesList } from './SessionMessagesList';
import styled from 'styled-components';
import autoBind from 'auto-bind';
import { ConversationTypeEnum } from '../../models/conversation';
import { getConversationController } from '../../session/conversations';
@ -19,12 +18,10 @@ import {
} from '../../state/ducks/conversations';
import { StateType } from '../../state/reducer';
import {
getFirstUnreadMessageId,
getQuotedMessageToAnimate,
getSelectedConversation,
getSelectedConversationKey,
getSortedMessagesOfSelectedConversation,
isFirstUnreadMessageIdAbove,
} from '../../state/selectors/conversations';
import { TypingBubble } from './TypingBubble';
@ -46,37 +43,12 @@ export const ScrollToLoadedMessageContext = React.createContext(
(_loadedMessageIdToScrollTo: string, _reason: ScrollToLoadedReasons) => {}
);
const SessionUnreadAboveIndicator = styled.div`
position: sticky;
top: 0;
margin: 1em;
display: flex;
justify-content: center;
background: var(--color-sent-message-background);
color: var(--color-sent-message-text);
`;
const UnreadAboveIndicator = () => {
const isFirstUnreadAbove = useSelector(isFirstUnreadMessageIdAbove);
const firstUnreadMessageId = useSelector(getFirstUnreadMessageId) as string;
if (!isFirstUnreadAbove) {
return null;
}
return (
<SessionUnreadAboveIndicator key={`above-unread-indicator-${firstUnreadMessageId}`}>
{window.i18n('latestUnreadIsAbove')}
</SessionUnreadAboveIndicator>
);
};
type Props = SessionMessageListProps & {
conversationKey?: string;
messagesProps: Array<SortedMessageModelProps>;
conversation?: ReduxConversationType;
animateQuotedMessageId: string | undefined;
firstUnreadOnOpen: string | undefined;
scrollToNow: () => Promise<void>;
};
@ -136,8 +108,6 @@ class SessionMessagesListContainerInner extends React.Component<Props> {
ref={this.props.messageContainerRef}
data-testid="messages-container"
>
<UnreadAboveIndicator />
<TypingBubble
pubkey={conversationKey}
conversationType={conversation.type}
@ -321,7 +291,6 @@ const mapStateToProps = (state: StateType) => {
conversation: getSelectedConversation(state),
messagesProps: getSortedMessagesOfSelectedConversation(state),
animateQuotedMessageId: getQuotedMessageToAnimate(state),
firstUnreadOnOpen: getFirstUnreadMessageId(state),
};
};

@ -890,35 +890,27 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
messageAttributes: Omit<
MessageAttributesOptionals,
'conversationId' | 'source' | 'type' | 'direction' | 'received_at'
>,
setToExpire = true
>
) {
return this.addSingleMessage(
{
...messageAttributes,
conversationId: this.id,
source: UserUtils.getOurPubKeyStrFromCache(),
type: 'outgoing',
direction: 'outgoing',
received_at: messageAttributes.sent_at, // make sure to set an received_at timestamp for an outgoing message, so the order are right.
},
setToExpire
);
return this.addSingleMessage({
...messageAttributes,
conversationId: this.id,
source: UserUtils.getOurPubKeyStrFromCache(),
type: 'outgoing',
direction: 'outgoing',
received_at: messageAttributes.sent_at, // make sure to set an received_at timestamp for an outgoing message, so the order are right.
});
}
public async addSingleIncomingMessage(
messageAttributes: Omit<MessageAttributesOptionals, 'conversationId' | 'type' | 'direction'>,
setToExpire = true
messageAttributes: Omit<MessageAttributesOptionals, 'conversationId' | 'type' | 'direction'>
) {
return this.addSingleMessage(
{
...messageAttributes,
conversationId: this.id,
type: 'incoming',
direction: 'outgoing',
},
setToExpire
);
return this.addSingleMessage({
...messageAttributes,
conversationId: this.id,
type: 'incoming',
direction: 'outgoing',
});
}
public async leaveClosedGroup() {
@ -1470,10 +1462,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}
}
private async addSingleMessage(
messageAttributes: MessageAttributesOptionals,
setToExpire = true
) {
private async addSingleMessage(messageAttributes: MessageAttributesOptionals) {
const model = new MessageModel(messageAttributes);
const isMe = messageAttributes.source === UserUtils.getOurPubKeyStrFromCache();
@ -1490,9 +1479,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const messageId = await model.commit(false);
model.set({ id: messageId });
if (setToExpire) {
await model.setToExpire();
}
await model.setToExpire();
window.inboxStore?.dispatch(
conversationActions.messagesAdded([
{

@ -309,12 +309,6 @@ async function handleExpirationTimerUpdate(
});
conversation.set({ expireTimer });
window?.log?.info("Update conversation 'expireTimer'", {
id: conversation.idForLogging(),
expireTimer,
source: 'handleSwarmDataMessage',
});
await conversation.updateExpireTimer(expireTimer, source, message.get('received_at'));
}
@ -412,9 +406,7 @@ export async function handleMessageJob(
conversation.throttledNotify(messageModel);
}
if (confirm) {
confirm();
}
confirm?.();
} catch (error) {
const errorForLog = error && error.stack ? error.stack : error;
window?.log?.error(

@ -279,7 +279,23 @@ export type ConversationsStateType = {
quotedMessage?: ReplyingToMessageProps;
areMoreTopMessagesBeingFetched: boolean;
areMoreBottomMessagesBeingFetched: boolean;
/**
* oldTopMessageId should only be set when, as the user scroll up we trigger a load of more top messages.
* Saving it here, make it possible to restore the position of the user before the refresh by pointing
* at that same messageId and aligning the list to the top.
*
* Once the view scrolled, this value is reseted by resetOldTopMessageId
*/
oldTopMessageId: string | null;
/**
* oldBottomMessageId should only be set when, as the user scroll down we trigger a load of more bottom messages.
* Saving it here, make it possible to restore the position of the user before the refresh by pointing
* at that same messageId and aligning the list to the bottom.
*
* Once the view scrolled, this value is reseted by resetOldBottomMessageId
*/
oldBottomMessageId: string | null;
showScrollButton: boolean;

Loading…
Cancel
Save