|
|
@@ -73,7 +73,7 @@ class Chatter {
|
|
73
|
73
|
this.subscriptions = [MAIN_CHANNEL, 'Channel-LosAngeles']
|
|
74
|
74
|
this.listeners = {
|
|
75
|
75
|
status: async e => {
|
|
76
|
|
- await this.publish(this.subscriptions[0], testMessage)
|
|
|
76
|
+ await this.publish(this.subscriptions[2], testMessage)
|
|
77
|
77
|
if (e.category !== 'PNConnectedCategory') return
|
|
78
|
78
|
},
|
|
79
|
79
|
message: this._onMessage,
|
|
|
@@ -100,11 +100,14 @@ class Chatter {
|
|
100
|
100
|
this.provider = await setupPubnub(this.uuid)
|
|
101
|
101
|
|
|
102
|
102
|
// step 1: build the this.groupings object from the backend
|
|
103
|
|
- this.getGroupingsByProfileId(this.uuid)
|
|
|
103
|
+ // added .then() to wait for the groupings to be fetched before subscribing to channels
|
|
|
104
|
+ this.getGroupingsByProfileId(this.uuid).then(() => {
|
|
|
105
|
+ this._listenFor({ listeners: this.listeners })
|
|
|
106
|
+ this._subscribe(this.subscriptions)
|
|
|
107
|
+ })
|
|
104
|
108
|
|
|
105
|
|
-
|
|
106
|
|
- this._listenFor({ listeners: this.listeners })
|
|
107
|
|
- this._subscribe(this.subscriptions)
|
|
|
109
|
+ console.log('this.subscriptions', this.subscriptions)
|
|
|
110
|
+
|
|
108
|
111
|
}
|
|
109
|
112
|
/**
|
|
110
|
113
|
* Send a message to a channel
|
|
|
@@ -115,6 +118,7 @@ class Chatter {
|
|
115
|
118
|
* @return {object} timestamp
|
|
116
|
119
|
*/
|
|
117
|
120
|
async publish(channel, message) {
|
|
|
121
|
+ console.log('publishing message to channel:', channel)
|
|
118
|
122
|
return await providerMethods['publish']({ channel, message })
|
|
119
|
123
|
}
|
|
120
|
124
|
/**
|