|
|
|
@ -6,14 +6,16 @@ import { createStore } from '../../state/createStore';
|
|
|
|
|
import { StateType } from '../../state/reducer';
|
|
|
|
|
import { SmartLeftPane } from '../../state/smart/LeftPane';
|
|
|
|
|
import { SmartSessionConversation } from '../../state/smart/SessionConversation';
|
|
|
|
|
import { SessionSettingCategory, SettingsView } from './settings/SessionSettings';
|
|
|
|
|
import {
|
|
|
|
|
SessionSettingCategory,
|
|
|
|
|
SettingsView,
|
|
|
|
|
} from './settings/SessionSettings';
|
|
|
|
|
|
|
|
|
|
// Workaround: A react component's required properties are filtering up through connect()
|
|
|
|
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31363
|
|
|
|
|
const FilteredLeftPane = SmartLeftPane as any;
|
|
|
|
|
const FilteredSessionConversation = SmartSessionConversation as any;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
focusedSection: number;
|
|
|
|
|
};
|
|
|
|
@ -21,34 +23,40 @@ type Props = {
|
|
|
|
|
type State = {
|
|
|
|
|
isInitialLoadComplete: boolean;
|
|
|
|
|
settingsCategory?: SessionSettingCategory;
|
|
|
|
|
networkError: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// tslint:disable: react-a11y-img-has-alt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
private store: any;
|
|
|
|
|
private interval: NodeJS.Timeout | null = null;
|
|
|
|
|
|
|
|
|
|
constructor(props: any) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
isInitialLoadComplete: false,
|
|
|
|
|
settingsCategory: undefined,
|
|
|
|
|
networkError: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Inbox
|
|
|
|
|
const inboxCollection = window.getInboxCollection();
|
|
|
|
|
const conversationModels = window.getConversations();
|
|
|
|
|
this.fetchHandleMessageSentData = this.fetchHandleMessageSentData.bind(
|
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
this.handleMessageSentFailure = this.handleMessageSentFailure.bind(this);
|
|
|
|
|
this.handleMessageSentSuccess = this.handleMessageSentSuccess.bind(this);
|
|
|
|
|
this.showSessionSettingsCategory = this.showSessionSettingsCategory.bind(this);
|
|
|
|
|
this.showSessionViewConversation = this.showSessionViewConversation.bind(this);
|
|
|
|
|
this.showSessionSettingsCategory = this.showSessionSettingsCategory.bind(
|
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
this.showSessionViewConversation = this.showSessionViewConversation.bind(
|
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void this.setupLeftPane();
|
|
|
|
|
|
|
|
|
|
// ConversationCollection
|
|
|
|
|
conversationModels;
|
|
|
|
|
// this.listenTo(inboxCollection, 'messageError', () => {
|
|
|
|
|
// if (this.networkStatusView) {
|
|
|
|
|
// this.networkStatusView.render();
|
|
|
|
@ -69,7 +77,6 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
|
if (!this.state.isInitialLoadComplete) {
|
|
|
|
|
return <></>;
|
|
|
|
@ -79,12 +86,15 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
return (
|
|
|
|
|
<Provider store={this.store}>
|
|
|
|
|
<div className="gutter">
|
|
|
|
|
<div className="network-status-container"/>
|
|
|
|
|
<div className="network-status-container" />
|
|
|
|
|
{this.renderLeftPane()}
|
|
|
|
|
</div>
|
|
|
|
|
{isSettingsView ? this.renderSettings() : this.renderSessionConversation()}
|
|
|
|
|
{isSettingsView
|
|
|
|
|
? this.renderSettings()
|
|
|
|
|
: this.renderSessionConversation()}
|
|
|
|
|
</Provider>
|
|
|
|
|
); }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderLeftPane() {
|
|
|
|
|
return (
|
|
|
|
@ -97,14 +107,14 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderSettings() {
|
|
|
|
|
const isSecondaryDevice = !!window.textsecure.storage.get('isSecondaryDevice');
|
|
|
|
|
const category = this.state.settingsCategory || SessionSettingCategory.Appearance;
|
|
|
|
|
const isSecondaryDevice = !!window.textsecure.storage.get(
|
|
|
|
|
'isSecondaryDevice'
|
|
|
|
|
);
|
|
|
|
|
const category =
|
|
|
|
|
this.state.settingsCategory || SessionSettingCategory.Appearance;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SettingsView
|
|
|
|
|
isSecondaryDevice={isSecondaryDevice}
|
|
|
|
|
category={category}
|
|
|
|
|
/>
|
|
|
|
|
<SettingsView isSecondaryDevice={isSecondaryDevice} category={category} />
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -114,7 +124,7 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
<FilteredSessionConversation />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async fetchHandleMessageSentData(m: any) {
|
|
|
|
|
// nobody is listening to this freshly fetched message .trigger calls
|
|
|
|
@ -148,7 +158,10 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
return { msg: msg.message };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async handleMessageSentSuccess(sentMessage: any, wrappedEnvelope: any) {
|
|
|
|
|
private async handleMessageSentSuccess(
|
|
|
|
|
sentMessage: any,
|
|
|
|
|
wrappedEnvelope: any
|
|
|
|
|
) {
|
|
|
|
|
const fetchedData = await this.fetchHandleMessageSentData(sentMessage);
|
|
|
|
|
if (!fetchedData) {
|
|
|
|
|
return;
|
|
|
|
@ -206,17 +219,11 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
window.inboxStore = this.store;
|
|
|
|
|
|
|
|
|
|
// Enables our redux store to be updated by backbone events in the outside world
|
|
|
|
|
const {
|
|
|
|
|
conversationAdded,
|
|
|
|
|
conversationChanged,
|
|
|
|
|
conversationRemoved,
|
|
|
|
|
removeAllConversations,
|
|
|
|
|
messageExpired,
|
|
|
|
|
openConversationExternal,
|
|
|
|
|
} = bindActionCreators(
|
|
|
|
|
const { messageExpired } = bindActionCreators(
|
|
|
|
|
window.Signal.State.Ducks.conversations.actions,
|
|
|
|
|
this.store.dispatch
|
|
|
|
|
);
|
|
|
|
|
window.actionsCreators = window.Signal.State.Ducks.conversations.actions;
|
|
|
|
|
const { userChanged } = bindActionCreators(
|
|
|
|
|
window.Signal.State.Ducks.user.actions,
|
|
|
|
|
this.store.dispatch
|
|
|
|
@ -226,40 +233,23 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
this.store.dispatch
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// this.openConversationAction = openConversationExternal;
|
|
|
|
|
|
|
|
|
|
this.fetchHandleMessageSentData = this.fetchHandleMessageSentData.bind(
|
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
this.handleMessageSentFailure = this.handleMessageSentFailure.bind(this);
|
|
|
|
|
this.handleMessageSentSuccess = this.handleMessageSentSuccess.bind(this);
|
|
|
|
|
|
|
|
|
|
// this.listenTo(convoCollection, 'remove', conversation => {
|
|
|
|
|
// const { id } = conversation || {};
|
|
|
|
|
// conversationRemoved(id);
|
|
|
|
|
// });
|
|
|
|
|
// this.listenTo(convoCollection, 'add', conversation => {
|
|
|
|
|
// const { id, cachedProps } = conversation || {};
|
|
|
|
|
// conversationAdded(id, cachedProps);
|
|
|
|
|
// });
|
|
|
|
|
// this.listenTo(convoCollection, 'change', conversation => {
|
|
|
|
|
// const { id, cachedProps } = conversation || {};
|
|
|
|
|
// conversationChanged(id, cachedProps);
|
|
|
|
|
// });
|
|
|
|
|
// this.listenTo(convoCollection, 'reset', removeAllConversations);
|
|
|
|
|
|
|
|
|
|
getMessageQueue()
|
|
|
|
|
.events.addListener('success', this.handleMessageSentSuccess);
|
|
|
|
|
getMessageQueue().events.addListener(
|
|
|
|
|
'success',
|
|
|
|
|
this.handleMessageSentSuccess
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
getMessageQueue()
|
|
|
|
|
.events.addListener('fail', this.handleMessageSentFailure);
|
|
|
|
|
getMessageQueue().events.addListener('fail', this.handleMessageSentFailure);
|
|
|
|
|
|
|
|
|
|
window.Whisper.events.on('messageExpired', messageExpired);
|
|
|
|
|
window.Whisper.events.on('messageChanged', messageChanged);
|
|
|
|
|
window.Whisper.events.on('userChanged', userChanged);
|
|
|
|
|
|
|
|
|
|
// Finally, add it to the DOM
|
|
|
|
|
// this.$('.left-pane-placeholder').append(this.leftPaneView.el);
|
|
|
|
|
this.setState({ isInitialLoadComplete: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -270,4 +260,34 @@ export class SessionInboxView extends React.Component<Props, State> {
|
|
|
|
|
private showSessionViewConversation() {
|
|
|
|
|
this.setState({ settingsCategory: undefined });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private startConnectionListener() {
|
|
|
|
|
// this.interval = global.setInterval(() => {
|
|
|
|
|
// const status = window.getSocketStatus();
|
|
|
|
|
// switch (status) {
|
|
|
|
|
// case WebSocket.CONNECTING:
|
|
|
|
|
// break;
|
|
|
|
|
// case WebSocket.OPEN:
|
|
|
|
|
// if (this.interval) {
|
|
|
|
|
// clearInterval(this.interval);
|
|
|
|
|
// }
|
|
|
|
|
// // Default to connected, but lokinet is slow so we pretend empty event
|
|
|
|
|
// // this.onEmpty();
|
|
|
|
|
// this.interval = null;
|
|
|
|
|
// break;
|
|
|
|
|
// case WebSocket.CLOSING:
|
|
|
|
|
// case WebSocket.CLOSED:
|
|
|
|
|
// if (this.interval) {
|
|
|
|
|
// clearInterval(this.interval);
|
|
|
|
|
// }
|
|
|
|
|
// this.interval = null;
|
|
|
|
|
// // if we failed to connect, we pretend we got an empty event
|
|
|
|
|
// // this.onEmpty();
|
|
|
|
|
// break;
|
|
|
|
|
// default:
|
|
|
|
|
// // We also replicate empty here
|
|
|
|
|
// // this.onEmpty();
|
|
|
|
|
// }
|
|
|
|
|
// }, 1000);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|