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 { SessionScrollButton } from '../SessionScrollButton';
import { contextMenu } from 'react-contexify'; import { contextMenu } from 'react-contexify';
import { connect, useSelector } from 'react-redux'; import { connect } from 'react-redux';
import { SessionMessagesList } from './SessionMessagesList'; import { SessionMessagesList } from './SessionMessagesList';
import styled from 'styled-components';
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
import { ConversationTypeEnum } from '../../models/conversation'; import { ConversationTypeEnum } from '../../models/conversation';
import { getConversationController } from '../../session/conversations'; import { getConversationController } from '../../session/conversations';
@ -19,12 +18,10 @@ import {
} from '../../state/ducks/conversations'; } from '../../state/ducks/conversations';
import { StateType } from '../../state/reducer'; import { StateType } from '../../state/reducer';
import { import {
getFirstUnreadMessageId,
getQuotedMessageToAnimate, getQuotedMessageToAnimate,
getSelectedConversation, getSelectedConversation,
getSelectedConversationKey, getSelectedConversationKey,
getSortedMessagesOfSelectedConversation, getSortedMessagesOfSelectedConversation,
isFirstUnreadMessageIdAbove,
} from '../../state/selectors/conversations'; } from '../../state/selectors/conversations';
import { TypingBubble } from './TypingBubble'; import { TypingBubble } from './TypingBubble';
@ -46,37 +43,12 @@ export const ScrollToLoadedMessageContext = React.createContext(
(_loadedMessageIdToScrollTo: string, _reason: ScrollToLoadedReasons) => {} (_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 & { type Props = SessionMessageListProps & {
conversationKey?: string; conversationKey?: string;
messagesProps: Array<SortedMessageModelProps>; messagesProps: Array<SortedMessageModelProps>;
conversation?: ReduxConversationType; conversation?: ReduxConversationType;
animateQuotedMessageId: string | undefined; animateQuotedMessageId: string | undefined;
firstUnreadOnOpen: string | undefined;
scrollToNow: () => Promise<void>; scrollToNow: () => Promise<void>;
}; };
@ -136,8 +108,6 @@ class SessionMessagesListContainerInner extends React.Component<Props> {
ref={this.props.messageContainerRef} ref={this.props.messageContainerRef}
data-testid="messages-container" data-testid="messages-container"
> >
<UnreadAboveIndicator />
<TypingBubble <TypingBubble
pubkey={conversationKey} pubkey={conversationKey}
conversationType={conversation.type} conversationType={conversation.type}
@ -321,7 +291,6 @@ const mapStateToProps = (state: StateType) => {
conversation: getSelectedConversation(state), conversation: getSelectedConversation(state),
messagesProps: getSortedMessagesOfSelectedConversation(state), messagesProps: getSortedMessagesOfSelectedConversation(state),
animateQuotedMessageId: getQuotedMessageToAnimate(state), animateQuotedMessageId: getQuotedMessageToAnimate(state),
firstUnreadOnOpen: getFirstUnreadMessageId(state),
}; };
}; };

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

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

@ -279,7 +279,23 @@ export type ConversationsStateType = {
quotedMessage?: ReplyingToMessageProps; quotedMessage?: ReplyingToMessageProps;
areMoreTopMessagesBeingFetched: boolean; areMoreTopMessagesBeingFetched: boolean;
areMoreBottomMessagesBeingFetched: 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; 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; oldBottomMessageId: string | null;
showScrollButton: boolean; showScrollButton: boolean;

Loading…
Cancel
Save