Skip to content

Commit

Permalink
[FIX] Start loop searching for rooms updates only when connection goe…
Browse files Browse the repository at this point in the history
…s down and SDK has userId (#613)
  • Loading branch information
diegolmello committed Feb 7, 2019
1 parent b4d9259 commit 6580718
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/lib/methods/subscriptions/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@ export default async function subscribeRooms() {
timer = setTimeout(() => {
clearTimeout(timer);
timer = false;
if (this.sdk.userId) {
store.dispatch(roomsRequest());
loop();
}
store.dispatch(roomsRequest());
loop();
}, 5000);
};

this.sdk.onStreamData('connected', () => {
if (this.sdk.userId) {
store.dispatch(roomsRequest());
}
store.dispatch(roomsRequest());
clearTimeout(timer);
timer = false;
});

this.sdk.onStreamData('close', () => {
loop();
if (this.sdk.userId) {
loop();
}
});

this.sdk.onStreamData('stream-notify-user', protectedFunction((ddpMessage) => {
Expand Down

0 comments on commit 6580718

Please sign in to comment.