linter-fixes

pull/1283/head
Vincent 5 years ago
parent 28a59c2d07
commit d7de09e475

@ -571,8 +571,6 @@
const model = this.addSingleMessage(message); const model = this.addSingleMessage(message);
MessageController.register(model.id, model); MessageController.register(model.id, model);
console.log(`[vince] Changed triggered from model`);
this.trigger('change'); this.trigger('change');
}, },
addSingleMessage(message, setToExpire = true) { addSingleMessage(message, setToExpire = true) {

@ -32,9 +32,6 @@ const { ContactName } = require('../../ts/components/conversation/ContactName');
const { const {
ConversationHeader, ConversationHeader,
} = require('../../ts/components/conversation/ConversationHeader'); } = require('../../ts/components/conversation/ConversationHeader');
const {
SessionGroupSettings,
} = require('../../ts/components/session/SessionGroupSettings');
const { const {
EmbeddedContact, EmbeddedContact,
} = require('../../ts/components/conversation/EmbeddedContact'); } = require('../../ts/components/conversation/EmbeddedContact');
@ -282,7 +279,6 @@ exports.setup = (options = {}) => {
ContactListItem, ContactListItem,
ContactName, ContactName,
ConversationHeader, ConversationHeader,
SessionGroupSettings,
SettingsView, SettingsView,
EmbeddedContact, EmbeddedContact,
Emojify, Emojify,

@ -260,59 +260,6 @@
}, },
}; };
}; };
const getGroupSettingsProps = () => {
const ourPK = window.textsecure.storage.user.getNumber();
const members = this.model.get('members') || [];
return {
id: this.model.id,
name: this.model.getName(),
phoneNumber: this.model.getNumber(),
profileName: this.model.getProfileName(),
color: this.model.getColor(),
avatarPath: this.model.getAvatarPath(),
isGroup: !this.model.isPrivate(),
isPublic: this.model.isPublic(),
isAdmin: this.model.get('groupAdmins').includes(ourPK),
isRss: this.model.isRss(),
memberCount: members.length,
amMod: this.model.isModerator(
window.storage.get('primaryDevicePubKey')
),
isKickedFromGroup: this.model.get('isKickedFromGroup'),
isBlocked: this.model.isBlocked(),
timerOptions: Whisper.ExpirationTimerOptions.map(item => ({
name: item.getName(),
value: item.get('seconds'),
})),
onSetDisappearingMessages: seconds =>
this.setDisappearingMessages(seconds),
onGoBack: () => {
this.hideConversationRight();
},
onUpdateGroupName: () => {
window.Whisper.events.trigger('updateGroupName', this.model);
},
onUpdateGroupMembers: () => {
window.Whisper.events.trigger('updateGroupMembers', this.model);
},
onLeaveGroup: () => {
window.Whisper.events.trigger('leaveGroup', this.model);
},
onInviteContacts: () => {
window.Whisper.events.trigger('inviteContacts', this.model);
},
onShowLightBox: (lightBoxOptions = {}) => {
this.showChannelLightbox(lightBoxOptions);
},
};
};
this.titleView = new Whisper.ReactWrapperView({ this.titleView = new Whisper.ReactWrapperView({
className: 'title-wrapper', className: 'title-wrapper',
Component: window.Signal.Components.ConversationHeader, Component: window.Signal.Components.ConversationHeader,
@ -345,28 +292,6 @@
}); });
}; };
this.showGroupSettings = () => {
if (!this.groupSettings) {
this.groupSettings = new Whisper.ReactWrapperView({
className: 'group-settings',
Component: window.Signal.Components.SessionGroupSettings,
props: getGroupSettingsProps(this.model),
});
this.$('.conversation-content-right').append(this.groupSettings.el);
this.updateGroupSettingsPanel = () =>
this.groupSettings.update(getGroupSettingsProps(this.model));
this.listenTo(this.model, 'change', this.updateGroupSettingsPanel);
} else {
this.groupSettings.update(getGroupSettingsProps(this.model));
}
this.showConversationRight();
};
this.hideGroupSettings = () => {
this.showConversationRight();
};
this.memberView.render(); this.memberView.render();
this.bulkEditView = new Whisper.BulkEditView({ this.bulkEditView = new Whisper.BulkEditView({

@ -47,12 +47,12 @@ img.emoji {
} }
img.emoji.small { img.emoji.small {
width: 1.10em; width: 1.1em;
height: 1.10em; height: 1.1em;
} }
img.emoji.medium { img.emoji.medium {
width: 1.30em; width: 1.3em;
height: 1.30em; height: 1.3em;
} }
img.emoji.large { img.emoji.large {
width: 1.7em; width: 1.7em;

@ -268,7 +268,7 @@ $composition-container-height: 60px;
margin-left: 2px; margin-left: 2px;
line-height: $session-font-h2; line-height: $session-font-h2;
letter-spacing: 0.5px; letter-spacing: 0.5px;
color: rgba(0,0,0,0); color: rgba(0, 0, 0, 0);
} }
} }
} }

@ -3,10 +3,7 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import is from '@sindresorhus/is'; import is from '@sindresorhus/is';
import { import { getRegex, SizeClassType } from '../../util/emoji';
getRegex,
SizeClassType,
} from '../../util/emoji';
import { LocalizerType, RenderTextCallbackType } from '../../types/Util'; import { LocalizerType, RenderTextCallbackType } from '../../types/Util';
import { Twemoji } from 'react-emoji-render'; import { Twemoji } from 'react-emoji-render';
@ -67,24 +64,24 @@ export class Emojify extends React.Component<Props> {
); );
} }
let size = 1.00; let size = 1.0;
switch (sizeClass) { switch (sizeClass) {
case 'jumbo': case 'jumbo':
size = 2.00; size = 2.0;
break; break;
case 'large': case 'large':
size = 1.80; size = 1.8;
break; break;
case 'medium': case 'medium':
size = 1.50; size = 1.5;
break; break;
case 'small': case 'small':
size = 1.10; size = 1.1;
break; break;
default: default:
} }
const style = {fontSize: `${size}em`}; const style = { fontSize: `${size}em` };
const emojiText = match[0] ?? match[1]; const emojiText = match[0] ?? match[1];
@ -93,11 +90,13 @@ export class Emojify extends React.Component<Props> {
<Twemoji <Twemoji
key={count++} key={count++}
text={emojiText} text={emojiText}
options={{ options={
baseUrl: 'images/twemoji/', {
protocol: '', baseUrl: 'images/twemoji/',
ext: 'png', protocol: '',
} as any} ext: 'png',
} as any
}
/> />
</span> </span>
); );

@ -210,8 +210,6 @@ export class Message extends React.PureComponent<Props, State> {
} }
public handleImageError() { public handleImageError() {
// tslint:disable-next-line no-console
console.log('Message: Image failed to load; failing over to placeholder');
this.setState({ this.setState({
imageBroken: true, imageBroken: true,
}); });
@ -780,8 +778,6 @@ export class Message extends React.PureComponent<Props, State> {
return null; return null;
} }
console.log('[vince] contents:', contents);
return ( return (
<div <div
dir="auto" dir="auto"

@ -156,9 +156,6 @@ export class MessageBody extends React.Component<Props> {
/> />
); );
console.log('[vince] bodyContents:', bodyContents);
return this.addDownloading( return this.addDownloading(
<Linkify <Linkify
text={textWithPending} text={textWithPending}

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import classNames from 'classnames';
import { Constants } from '../../session'; import { Constants } from '../../session';
interface Props { interface Props {
@ -11,7 +10,6 @@ interface Props {
sendStatus: -1 | 0 | 1 | 2; sendStatus: -1 | 0 | 1 | 2;
visible: boolean; visible: boolean;
showOnComplete: boolean; showOnComplete: boolean;
resetProgress: any; resetProgress: any;
} }
@ -98,9 +96,8 @@ export class SessionProgress extends React.PureComponent<Props, State> {
return; return;
} }
console.log(`[sending] ONCOMPLETE`);
this.setState({ show: false }, () => { this.setState({ show: false }, () => {
setTimeout(this.props.resetProgress, 2000); setTimeout(() => this.props.resetProgress(), 2000);
}); });
} }

@ -16,7 +16,6 @@ import { Constants } from '../../../session';
import { toArray } from 'react-emoji-render'; import { toArray } from 'react-emoji-render';
interface Props { interface Props {
placeholder?: string; placeholder?: string;
@ -274,15 +273,15 @@ export class SessionCompositionBox extends React.Component<Props, State> {
} }
private parseEmojis(value: string) { private parseEmojis(value: string) {
const emojisArray = toArray(value); const emojisArray = toArray(value);
// toArray outputs React elements for emojis and strings for other // toArray outputs React elements for emojis and strings for other
return emojisArray.reduce((previous: string, current: any) => { return emojisArray.reduce((previous: string, current: any) => {
if (typeof current === 'string') { if (typeof current === 'string') {
return previous + current; return previous + current;
} }
return previous + (current.props.children as string); return previous + (current.props.children as string);
}, ''); }, '');
} }
private async onSendMessage() { private async onSendMessage() {
@ -305,8 +304,7 @@ export class SessionCompositionBox extends React.Component<Props, State> {
this.props.onMessageSending(); this.props.onMessageSending();
try { try {
await this.props await this.props.sendMessage(
.sendMessage(
messagePlaintext, messagePlaintext,
attachments, attachments,
undefined, undefined,
@ -398,10 +396,10 @@ export class SessionCompositionBox extends React.Component<Props, State> {
private onChange(event: any) { private onChange(event: any) {
const message = event.target.value ?? ''; const message = event.target.value ?? '';
this.setState({message}); this.setState({ message });
} }
private onEmojiClick({colons, native}: {colons: string; native: string}) { private onEmojiClick({ colons, native }: { colons: string; native: string }) {
const messageBox = this.textarea.current; const messageBox = this.textarea.current;
if (!messageBox) { if (!messageBox) {
return; return;

@ -171,11 +171,11 @@ export class SessionConversation extends React.Component<any, State> {
const messageCollection = window.ConversationController.get( const messageCollection = window.ConversationController.get(
this.state.conversationKey this.state.conversationKey
).messageCollection; ).messageCollection;
console.log('[vince] messageCollection:', messageCollection);
console.log('[vince] this.state.messages:', this.state.messages);
} }
public async componentWillReceiveProps(nextProps: any) {} public async componentWillReceiveProps(nextProps: any) {
return;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~ RENDER METHODS ~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~ RENDER METHODS ~~~~~~~~~~~~~~
@ -468,12 +468,6 @@ export class SessionConversation extends React.Component<any, State> {
} }
}); });
// Add new messages to conversation collection
// const newMessages = _.xor(messages, previousMessageSet);
// newMessages.forEach(message => conversationModel.addSingleMessage(message));
// console.log('[vince] conversationModel.messageCollection:', conversationModel.messageCollection);
return { newTopMessage, previousTopMessage }; return { newTopMessage, previousTopMessage };
} }

@ -64,16 +64,17 @@ export async function getMessages(
const previousTopMessage = currentMessages[0]?.id; const previousTopMessage = currentMessages[0]?.id;
const newTopMessage = messages[0]?.id; const newTopMessage = messages[0]?.id;
messageFetchTimestamp = getTimestamp(); const newMessageFetchTimestamp = getTimestamp();
// Callback to onGotMessages // Callback to onGotMessages
if (onGotMessages) if (onGotMessages) {
onGotMessages( onGotMessages(
messages, messages,
messageFetchTimestamp, newMessageFetchTimestamp,
previousTopMessage, previousTopMessage,
newTopMessage newTopMessage
); );
}
return { newTopMessage, previousTopMessage }; return { newTopMessage, previousTopMessage };
} }

@ -7,15 +7,15 @@ import { getTimestamp } from './SessionConversationManager';
import { SessionIconButton, SessionIconSize, SessionIconType } from '../icon'; import { SessionIconButton, SessionIconSize, SessionIconType } from '../icon';
import { import {
SessionButton, SessionButton,
SessionButtonType,
SessionButtonColor, SessionButtonColor,
SessionButtonType,
} from '../SessionButton'; } from '../SessionButton';
import { Constants } from '../../../session'; import { Constants } from '../../../session';
interface Props { interface Props {
sendVoiceMessage: any;
onLoadVoiceNoteView: any;
onExitVoiceNoteView: any; onExitVoiceNoteView: any;
onLoadVoiceNoteView: any;
sendVoiceMessage: any;
} }
interface State { interface State {
@ -56,9 +56,9 @@ interface State {
} }
export class SessionRecording extends React.Component<Props, State> { export class SessionRecording extends React.Component<Props, State> {
private visualisationRef: React.RefObject<HTMLDivElement>; private readonly visualisationRef: React.RefObject<HTMLDivElement>;
private visualisationCanvas: React.RefObject<HTMLCanvasElement>; private readonly visualisationCanvas: React.RefObject<HTMLCanvasElement>;
private playbackCanvas: React.RefObject<HTMLCanvasElement>; private readonly playbackCanvas: React.RefObject<HTMLCanvasElement>;
constructor(props: any) { constructor(props: any) {
super(props); super(props);
@ -125,12 +125,17 @@ export class SessionRecording extends React.Component<Props, State> {
public async componentWillMount() { public async componentWillMount() {
// This turns on the microphone on the system. Later we need to turn it off. // This turns on the microphone on the system. Later we need to turn it off.
this.initiateRecordingStream(); await this.initiateRecordingStream();
} }
public componentDidMount() { public componentDidMount() {
window.addEventListener('resize', this.updateCanvasDimensions); window.addEventListener('resize', this.updateCanvasDimensions);
this.updateCanvasDimensions(); this.updateCanvasDimensions();
// Callback to parent on load complete
if (this.props.onLoadVoiceNoteView) {
this.props.onLoadVoiceNoteView();
}
} }
public componentWillUnmount() { public componentWillUnmount() {
@ -138,12 +143,12 @@ export class SessionRecording extends React.Component<Props, State> {
window.removeEventListener('resize', this.updateCanvasDimensions); window.removeEventListener('resize', this.updateCanvasDimensions);
} }
public componentDidUpdate() { public async componentDidUpdate() {
const { audioElement, isPlaying } = this.state; const { audioElement, isPlaying } = this.state;
if (audioElement) { if (audioElement) {
if (isPlaying) { if (isPlaying) {
audioElement.play(); await audioElement.play();
} else { } else {
audioElement.pause(); audioElement.pause();
} }
@ -226,8 +231,8 @@ export class SessionRecording extends React.Component<Props, State> {
className="session-recording--visualisation" className="session-recording--visualisation"
ref={this.visualisationRef} ref={this.visualisationRef}
> >
{!isRecording && <canvas ref={this.playbackCanvas}></canvas>} {!isRecording && <canvas ref={this.playbackCanvas} />}
{isRecording && <canvas ref={this.visualisationCanvas}></canvas>} {isRecording && <canvas ref={this.visualisationCanvas} />}
</div> </div>
<div <div
@ -237,9 +242,7 @@ export class SessionRecording extends React.Component<Props, State> {
)} )}
> >
{displayTimeString} {displayTimeString}
{isRecording && ( {isRecording && <div className="session-recording--timer-light" />}
<div className="session-recording--timer-light"></div>
)}
</div> </div>
{!isRecording && ( {!isRecording && (
@ -282,13 +285,13 @@ export class SessionRecording extends React.Component<Props, State> {
} }
} }
private timerUpdate() { private async timerUpdate() {
const { nowTimestamp, startTimestamp } = this.state; const { nowTimestamp, startTimestamp } = this.state;
const elapsedTime = nowTimestamp - startTimestamp; const elapsedTime = nowTimestamp - startTimestamp;
// Prevent voice messages exceeding max length. // Prevent voice messages exceeding max length.
if (elapsedTime >= Constants.CONVERSATION.MAX_VOICE_MESSAGE_DURATION) { if (elapsedTime >= Constants.CONVERSATION.MAX_VOICE_MESSAGE_DURATION) {
this.stopRecordingStream(); await this.stopRecordingStream();
} }
this.setState({ this.setState({
@ -321,19 +324,19 @@ export class SessionRecording extends React.Component<Props, State> {
} }
const audioURL = window.URL.createObjectURL(mediaBlob.data); const audioURL = window.URL.createObjectURL(mediaBlob.data);
const audioElement = new Audio(audioURL); const audioElementN = new Audio(audioURL);
audioElement.loop = false; audioElementN.loop = false;
audioElement.oncanplaythrough = async () => { audioElementN.oncanplaythrough = async () => {
const duration = recordDuration; const duration = recordDuration;
if (duration && audioElement.currentTime < duration) { if (duration && audioElementN.currentTime < duration) {
await audioElement.play(); await audioElementN.play();
} }
}; };
return audioElement; return audioElementN;
}; };
const audioElement = this.state.audioElement || generateAudioElement(); const audioElement = this.state.audioElement || generateAudioElement();
@ -422,9 +425,7 @@ export class SessionRecording extends React.Component<Props, State> {
// Is the audio file > attachment filesize limit // Is the audio file > attachment filesize limit
if (audioBlob.size > Constants.CONVERSATION.MAX_ATTACHMENT_FILESIZE) { if (audioBlob.size > Constants.CONVERSATION.MAX_ATTACHMENT_FILESIZE) {
console.log( // TODO VINCE: warn the user that it's too big
`[send] Voice message too large: ${audioBlob.size / 1000000} MB`
);
return; return;
} }

@ -6,8 +6,7 @@ import {
reducer as conversations, reducer as conversations,
} from './ducks/conversations'; } from './ducks/conversations';
import { reducer as user, UserStateType } from './ducks/user'; import { reducer as user, UserStateType } from './ducks/user';
// import { reducer as messages } from './ducks/messages';
import { reducer as messages } from './ducks/search';
export type StateType = { export type StateType = {
search: SearchStateType; search: SearchStateType;
@ -18,7 +17,9 @@ export type StateType = {
export const reducers = { export const reducers = {
search, search,
messages, // Temporary until ./ducks/messages is working
// messages,
messages: search,
conversations, conversations,
user, user,
}; };

@ -221,7 +221,7 @@ export const _getSessionConversationInfo = (
const max = sorted.length; const max = sorted.length;
for (let i = 0; i < max; i += 1) { for (let i = 0; i < max; i += 1) {
let conv = sorted[i]; const conv = sorted[i];
if (conv.id === selectedConversation) { if (conv.id === selectedConversation) {
conversation = conv; conversation = conv;

Loading…
Cancel
Save