Skip to content

Commit 0b73194

Browse files
committed
workaround for topics issue
1 parent 6389884 commit 0b73194

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

js/build/embark.bundle.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,13 @@ var EmbarkJS =
382382
throw new Error("missing option: data");
383383
}
384384

385-
// do fromAscii to each topics unless it's already a string
386385
if (typeof topics === 'string') {
387386
topics = topics;
388387
} else {
389388
// TODO: better to just send to different channels instead
390389
topics = topics.join(',');
391390
}
392391

393-
// TODO: if it's array then join and send ot several
394-
// keep list of channels joined
395392
this.orbit.join(topics);
396393

397394
var payload = JSON.stringify(data);
@@ -403,14 +400,14 @@ var EmbarkJS =
403400
var self = this;
404401
var topics = options.topic || options.topics;
405402

406-
// do fromAscii to each topics unless it's already a string
407403
if (typeof topics === 'string') {
408404
topics = topics;
409405
} else {
410-
// TODO: better to just send to different channels instead
411406
topics = topics.join(',');
412407
}
413408

409+
this.orbit.join(topics);
410+
414411
var messageEvents = function() {
415412
this.cb = function() {};
416413
};
@@ -425,10 +422,12 @@ var EmbarkJS =
425422

426423
var promise = new messageEvents();
427424

428-
this.orbit.events.on('message', (topics, message) => {
425+
this.orbit.events.on('message', (channel, message) => {
426+
// TODO: looks like sometimes it's receving messages from all topics
427+
if (topics !== channel) return;
429428
self.orbit.getPost(message.payload.value, true).then((post) => {
430429
var data = {
431-
topic: topics,
430+
topic: channel,
432431
data: post.content,
433432
from: post.meta.from.name,
434433
time: (new Date(post.meta.ts))

js/embark.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,13 @@ EmbarkJS.Messages.Orbit.sendMessage = function(options) {
335335
throw new Error("missing option: data");
336336
}
337337

338-
// do fromAscii to each topics unless it's already a string
339338
if (typeof topics === 'string') {
340339
topics = topics;
341340
} else {
342341
// TODO: better to just send to different channels instead
343342
topics = topics.join(',');
344343
}
345344

346-
// TODO: if it's array then join and send ot several
347-
// keep list of channels joined
348345
this.orbit.join(topics);
349346

350347
var payload = JSON.stringify(data);
@@ -356,14 +353,14 @@ EmbarkJS.Messages.Orbit.listenTo = function(options) {
356353
var self = this;
357354
var topics = options.topic || options.topics;
358355

359-
// do fromAscii to each topics unless it's already a string
360356
if (typeof topics === 'string') {
361357
topics = topics;
362358
} else {
363-
// TODO: better to just send to different channels instead
364359
topics = topics.join(',');
365360
}
366361

362+
this.orbit.join(topics);
363+
367364
var messageEvents = function() {
368365
this.cb = function() {};
369366
};
@@ -378,10 +375,12 @@ EmbarkJS.Messages.Orbit.listenTo = function(options) {
378375

379376
var promise = new messageEvents();
380377

381-
this.orbit.events.on('message', (topics, message) => {
378+
this.orbit.events.on('message', (channel, message) => {
379+
// TODO: looks like sometimes it's receving messages from all topics
380+
if (topics !== channel) return;
382381
self.orbit.getPost(message.payload.value, true).then((post) => {
383382
var data = {
384-
topic: topics,
383+
topic: channel,
385384
data: post.content,
386385
from: post.meta.from.name,
387386
time: (new Date(post.meta.ts))

0 commit comments

Comments
 (0)