render Session Verification Messages

pull/1387/head
Audric Ackermann 5 years ago
parent 325331550c
commit 3f538b9be1
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -52,20 +52,6 @@
request_received: 2, request_received: 2,
}); });
const COLORS = [
'red',
'deep_orange',
'brown',
'pink',
'purple',
'indigo',
'blue',
'teal',
'green',
'light_green',
'blue_grey',
];
Whisper.Conversation = Backbone.Model.extend({ Whisper.Conversation = Backbone.Model.extend({
storeName: 'conversations', storeName: 'conversations',
defaults() { defaults() {
@ -2609,6 +2595,4 @@
this.reset([]); this.reset([]);
}, },
}); });
Whisper.Conversation.COLORS = COLORS.concat(['grey', 'default']).join(' ');
})(); })();

@ -60,5 +60,6 @@ export interface MessageModel extends Backbone.Model<MessageAttributes> {
propsForResetSessionNotification?: any; propsForResetSessionNotification?: any;
propsForGroupInvitation?: any; propsForGroupInvitation?: any;
propsForGroupNotification?: any; propsForGroupNotification?: any;
propsForVerificationNotification?: any;
firstMessageOfSeries: boolean; firstMessageOfSeries: boolean;
} }

@ -1507,7 +1507,10 @@ input {
align-items: center; align-items: center;
padding-top: $session-margin-lg; padding-top: $session-margin-lg;
text-align: center; text-align: center;
@include themify($themes) {
background: themed('inboxBackground');
color: themed('textColor');
}
&__header { &__header {
word-break: break-all; word-break: break-all;
@ -1525,6 +1528,7 @@ input {
font-family: $session-font-mono; font-family: $session-font-mono;
margin: 30px 0; margin: 30px 0;
width: 250px; width: 250px;
color: white;
} }
&__is-verified { &__is-verified {

@ -3,7 +3,6 @@ import React from 'react';
import { ContactName } from './ContactName'; import { ContactName } from './ContactName';
import { Intl } from '../Intl'; import { Intl } from '../Intl';
import { LocalizerType } from '../../types/Util';
import { missingCaseError } from '../../util/missingCaseError'; import { missingCaseError } from '../../util/missingCaseError';
@ -13,16 +12,15 @@ interface Contact {
name?: string; name?: string;
} }
interface Props { type Props = {
type: 'markVerified' | 'markNotVerified'; type: 'markVerified' | 'markNotVerified';
isLocal: boolean; isLocal: boolean;
contact: Contact; contact: Contact;
i18n: LocalizerType; };
}
export class VerificationNotification extends React.Component<Props> { export const VerificationNotification = (props: Props) => {
public getStringId() { const getStringId = () => {
const { isLocal, type } = this.props; const { isLocal, type } = props;
switch (type) { switch (type) {
case 'markVerified': case 'markVerified':
@ -36,11 +34,12 @@ export class VerificationNotification extends React.Component<Props> {
default: default:
throw missingCaseError(type); throw missingCaseError(type);
} }
} };
public renderContents() { const renderContents = () => {
const { contact, i18n } = this.props; const { contact } = props;
const id = this.getStringId(); const { i18n } = window;
const id = getStringId();
return ( return (
<Intl <Intl
@ -59,18 +58,16 @@ export class VerificationNotification extends React.Component<Props> {
i18n={i18n} i18n={i18n}
/> />
); );
} };
public render() { const { type } = props;
const { type } = this.props; const suffix =
const suffix = type === 'markVerified' ? 'mark-verified' : 'mark-not-verified';
type === 'markVerified' ? 'mark-verified' : 'mark-not-verified';
return ( return (
<div className="module-verification-notification"> <div className="module-verification-notification">
<div className={`module-verification-notification__icon--${suffix}`} /> <div className={`module-verification-notification__icon--${suffix}`} />
{this.renderContents()} {renderContents()}
</div> </div>
); );
} };
}

@ -130,10 +130,10 @@ export class SessionConversation extends React.Component<Props, State> {
this.onClickAttachment = this.onClickAttachment.bind(this); this.onClickAttachment = this.onClickAttachment.bind(this);
this.downloadAttachment = this.downloadAttachment.bind(this); this.downloadAttachment = this.downloadAttachment.bind(this);
this.refreshMessages = this.refreshMessages.bind(this); this.refreshMessages = this.refreshMessages.bind(this);
this.getMessages = _.throttle( // this.getMessages = _.throttle(
this.getMessages.bind(this), // this.getMessages.bind(this),
1000 // one second // 1000 // one second
); // );
// Keyboard navigation // Keyboard navigation
this.onKeyDown = this.onKeyDown.bind(this); this.onKeyDown = this.onKeyDown.bind(this);
@ -219,6 +219,7 @@ export class SessionConversation extends React.Component<Props, State> {
selectedMessages, selectedMessages,
isDraggingFile, isDraggingFile,
stagedAttachments, stagedAttachments,
initialFetchComplete,
} = this.state; } = this.state;
const selectionMode = !!selectedMessages.length; const selectionMode = !!selectedMessages.length;
@ -273,7 +274,11 @@ export class SessionConversation extends React.Component<Props, State> {
{lightBoxOptions?.media && this.renderLightBox(lightBoxOptions)} {lightBoxOptions?.media && this.renderLightBox(lightBoxOptions)}
<div className="conversation-messages"> <div className="conversation-messages">
<SessionConversationMessagesList {...this.getMessagesListProps()} /> {initialFetchComplete && (
<SessionConversationMessagesList
{...this.getMessagesListProps()}
/>
)}
{showRecordingView && ( {showRecordingView && (
<div className="conversation-messages__blocking-overlay" /> <div className="conversation-messages__blocking-overlay" />

@ -14,6 +14,7 @@ import { GroupInvitation } from '../../conversation/GroupInvitation';
import { ConversationType } from '../../../state/ducks/conversations'; import { ConversationType } from '../../../state/ducks/conversations';
import { MessageModel } from '../../../../js/models/messages'; import { MessageModel } from '../../../../js/models/messages';
import { SessionLastSeenIndicator } from './SessionLastSeedIndicator'; import { SessionLastSeenIndicator } from './SessionLastSeedIndicator';
import { VerificationNotification } from '../../conversation/VerificationNotification';
interface State { interface State {
isScrolledToBottom: boolean; isScrolledToBottom: boolean;
@ -126,6 +127,8 @@ export class SessionConversationMessagesList extends React.Component<
const timerProps = message.propsForTimerNotification; const timerProps = message.propsForTimerNotification;
const resetSessionProps = message.propsForResetSessionNotification; const resetSessionProps = message.propsForResetSessionNotification;
const verificationSessionProps =
message.propsForVerificationNotification;
const propsForGroupInvitation = message.propsForGroupInvitation; const propsForGroupInvitation = message.propsForGroupInvitation;
const groupNotificationProps = message.propsForGroupNotification; const groupNotificationProps = message.propsForGroupNotification;
@ -139,6 +142,7 @@ export class SessionConversationMessagesList extends React.Component<
) { ) {
unreadIndicator = <SessionLastSeenIndicator count={unreadCount} />; unreadIndicator = <SessionLastSeenIndicator count={unreadCount} />;
} }
currentMessageIndex = currentMessageIndex + 1; currentMessageIndex = currentMessageIndex + 1;
if (groupNotificationProps) { if (groupNotificationProps) {
@ -159,6 +163,15 @@ export class SessionConversationMessagesList extends React.Component<
); );
} }
if (verificationSessionProps) {
return (
<>
{unreadIndicator}
<VerificationNotification {...verificationSessionProps} />
</>
);
}
if (resetSessionProps) { if (resetSessionProps) {
return ( return (
<> <>
@ -186,7 +199,7 @@ export class SessionConversationMessagesList extends React.Component<
messageProps, messageProps,
message.firstMessageOfSeries, message.firstMessageOfSeries,
multiSelectMode multiSelectMode
)}{' '} )}
</> </>
); );
})} })}

Loading…
Cancel
Save