Skip to content

Commit

Permalink
Temp: for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kunall17 committed Jun 24, 2017
1 parent e1da2b8 commit 6313c62
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/ZulipMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class ZulipMobile extends Component {
};

componentWillMount() {
console.disableYellowBox = true;
restore(() => {
this.setState({ rehydrated: true });
});
Expand Down
86 changes: 67 additions & 19 deletions src/compose/ComposeText.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* @flow */
import React from 'react';
import { StyleSheet, View, ScrollView, TextInput } from 'react-native';
import { NotificationsAndroid } from 'react-native-notifications';

import styles from '../styles';
import { MatchResult, Auth, Narrow, User } from '../types';
Expand Down Expand Up @@ -53,26 +54,73 @@ export default class ComposeText extends React.Component {
autocomplete: false,
contentHeight: MIN_HEIGHT,
};

rnd = () => Math.floor(Math.random() * 100) + 1;
handleSend = () => {
const { auth, narrow, operator } = this.props;
const { text } = this.state;

if (isPrivateOrGroupNarrow(narrow)) {
sendMessage(auth, 'private', narrow[0].operand, '', text);
} else if (isTopicNarrow(narrow) || isStreamNarrow(narrow)) {
if (operator !== null) {
sendMessage(auth, 'stream', narrow[0].operand,
(operator === '') ? '(no topic)' : operator, text);
} else if (isTopicNarrow(narrow)) {
sendMessage(auth, 'stream', narrow[0].operand, narrow[1].operand, text);
} else if (isStreamNarrow(narrow)) {
sendMessage(auth, 'stream', narrow[0].operand, '(no topic)', text);
}
}


this.clearInput();
NotificationsAndroid.localNotification({
'sender_full_name': `Watson ${this.rnd()}`,
'google.sent_time': 1497506244014,
'sender_avatar_url': 'https://secure.gravatar.com/avatar/7b82892ab28701cc6bfe7798b3498eb7?d=identicon&version=1',
'content_truncated': 'false',
'zulip_message_id': '227901',
'recipient_type': 'private',
'time': '1497506243',
'user': 'kunall.gupta17@gmail.com',
'alert': 'New private message from Watson',
'event': 'message',
'google.message_id': '0:1497506244033759%46869b2df9fd7ecd',
'content': `Hello${this.rnd()} ${this.rnd()} ${this.rnd()} `,
'sender_email': `watson43517${this.rnd()}@gmail.com`
}, 1);
//
// NotificationsAndroid.localNotification({
// 'sender_full_name': 'Watson',
// 'google.sent_time': 1497506282911,
// 'sender_avatar_url': '/user_avatars/2/b72674b783578f8c21b96b330823b5f819082fa3.png?x=x&version=2',
// 'content_truncated': 'false',
// 'zulip_message_id': '227902',
// 'recipient_type': 'private',
// 'time': '1497506282',
// 'user': 'kunall.gupta17@gmail.com',
// 'alert': 'New private message from Watson',
// 'event': 'message',
// 'google.message_id': '0:1497506282918178%46869b2df9fd7ecd',
// 'content': 'ONe more',
// 'sender_email': 'watson43517@gmail.com'
// });
//
// NotificationsAndroid.localNotification({
// 'sender_full_name': 'Watson',
// ' google.sent_time': 1497508104254,
// 'sender_avatar_url': '/user_avatars/2/b72674b783578f8c21b96b330823b5f819082fa3.png?x=x&version=2',
// 'content_truncated': 'false',
// 'zulip_message_id': '227954',
// 'recipient_type': 'private',
// 'time': '1497508103',
// 'user': 'kunall.gupta17@gmail.com',
// 'alert': 'New private group message from Watson',
// 'event': 'message',
// 'google.message_id': '0:1497508104262464%46869b2df9fd7ecd',
// 'content': 'group push test,ignore karde bhai :P',
// 'sender_email': 'watson43517@gmail.com'
// });
// const { auth, narrow, operator } = this.props;
// const { text } = this.state;
//
// if (isPrivateOrGroupNarrow(narrow)) {
// sendMessage(auth, 'private', narrow[0].operand, '', text);
// } else if (isTopicNarrow(narrow) || isStreamNarrow(narrow)) {
// if (operator !== null) {
// sendMessage(auth, 'stream', narrow[0].operand,
// (operator === '') ? '(no topic)' : operator, text);
// } else if (isTopicNarrow(narrow)) {
// sendMessage(auth, 'stream', narrow[0].operand, narrow[1].operand, text);
// } else if (isStreamNarrow(narrow)) {
// sendMessage(auth, 'stream', narrow[0].operand, '(no topic)', text);
// }
// }
//
//
// this.clearInput();
}

clearInput = () => {
Expand Down

0 comments on commit 6313c62

Please sign in to comment.