Listen to subscription updates

This commit is contained in:
Rodrigo Nascimento 2017-08-09 15:15:44 -03:00
parent 1c41214b52
commit b4ffc7985b
3 changed files with 13 additions and 8 deletions

View File

@ -32,12 +32,8 @@ export default class MessageBox extends React.PureComponent {
return; return;
} }
this.props.onSubmit(this.state.text) this.props.onSubmit(this.state.text);
.then(() => { this.setState({ text: '' });
this.setState({
text: ''
});
});
}; };
render() { render() {

View File

@ -38,6 +38,7 @@ Meteor.Accounts.onLogin(() => {
realm.create('subscriptions', subscription, true); 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); 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);
});
}
}); });
}); });
} }

View File

@ -81,8 +81,8 @@ export default realm;
// Clear settings // Clear settings
realm.write(() => { realm.write(() => {
const allSettins = realm.objects('settings'); // const allSettins = realm.objects('settings');
realm.delete(allSettins); // realm.delete(allSettins);
// realm.create('servers', { id: 'https://demo.rocket.chat', current: false }, true); // realm.create('servers', { id: 'https://demo.rocket.chat', current: false }, true);
// realm.create('servers', { id: 'http://localhost:3000', current: false }, true); // realm.create('servers', { id: 'http://localhost:3000', current: false }, true);