diff --git a/app/components/MessageBox.js b/app/components/MessageBox.js index 32a7fef03..9145ffb5a 100644 --- a/app/components/MessageBox.js +++ b/app/components/MessageBox.js @@ -32,12 +32,8 @@ export default class MessageBox extends React.PureComponent { return; } - this.props.onSubmit(this.state.text) - .then(() => { - this.setState({ - text: '' - }); - }); + this.props.onSubmit(this.state.text); + this.setState({ text: '' }); }; render() { diff --git a/app/lib/meteor.js b/app/lib/meteor.js index 917af4099..f06b94f47 100644 --- a/app/lib/meteor.js +++ b/app/lib/meteor.js @@ -38,6 +38,7 @@ Meteor.Accounts.onLogin(() => { realm.create('subscriptions', subscription, true); }); }); + Meteor.subscribe('stream-notify-user', `${ Meteor.userId() }/subscriptions-changed`, false); }); }); @@ -80,6 +81,14 @@ export function connect(cb) { realm.create('messages', message, true); }); } + + if (ddbMessage.collection === 'stream-notify-user') { + realm.write(() => { + const data = ddbMessage.fields.args[1]; + data._server = { id: RocketChat.currentServer }; + realm.create('subscriptions', data, true); + }); + } }); }); } diff --git a/app/lib/realm.js b/app/lib/realm.js index 3ba3a6f6b..a6b8b286c 100644 --- a/app/lib/realm.js +++ b/app/lib/realm.js @@ -81,8 +81,8 @@ export default realm; // Clear settings realm.write(() => { - const allSettins = realm.objects('settings'); - realm.delete(allSettins); + // const allSettins = realm.objects('settings'); + // realm.delete(allSettins); // realm.create('servers', { id: 'https://demo.rocket.chat', current: false }, true); // realm.create('servers', { id: 'http://localhost:3000', current: false }, true);