Skip to content

Commit 7560bb4

Browse files
author
Peter Di Pasquale
committed
Changed subscriptions to always use uppercase keys except in case of undefined key
1 parent 786c629 commit 7560bb4

2 files changed

Lines changed: 42 additions & 6 deletions

File tree

src/realtimeSessions/components/RealtimeSessionIndicator.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default {
7373
this.activeSession = this.sessionService.getActiveTopicOrSession();
7474
this.stopListening = this.sessionService.listen(this.onActiveSessionChange);
7575
76-
this.pollForSessions();
76+
this.pollForSessions(true);
7777
},
7878
beforeUnmount() {
7979
this.stopListening?.();
@@ -84,10 +84,10 @@ export default {
8484
}
8585
},
8686
methods: {
87-
pollForSessions() {
87+
pollForSessions(resolveCachedDatasets = false ) {
8888
if (!this.activeSession) {
8989
this.sessionService
90-
.getTopicsWithSessions()
90+
.getTopicsWithSessions( resolveCachedDatasets )
9191
.then(topics => {
9292
this.hasTopics = topics.length > 0;
9393
});

src/services/session/SessionService.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,49 @@ class SessionService {
243243
*
244244
* @returns {Promise.<Topic[]>}
245245
*/
246-
async getTopicsWithSessions() {
246+
async getTopicsWithSessions(resolveCachedDatasets = false) {
247247
if (this.realtimeSessionConfig.disable) {
248248
return Promise.resolve([]);
249249
}
250+
let datasets = [];
251+
// Need to wait for MIOs to load for the cached datasets to return.
252+
const cachedDatasets = new Promise((resolve) => {
253+
// Check once a second
254+
const pollInterval = 1000;
255+
let currentLength = 0;
256+
let maxIterations = 15;
257+
let currentIteration = 0;
258+
const checkDatasets = () => {
259+
const result = Object.values(this.getDatasets());
260+
if (result.length > 0) {
261+
// Success - we have data
262+
if (currentLength !=0 ) {
263+
if (result.length == currentLength){
264+
resolve(result);
265+
}
266+
} else {
267+
currentLength = result.length;
268+
setTimeout(checkDatasets, pollInterval);
250269

251-
const datasets = Object.values(this.getDatasets());
252-
const validUrls = datasets.map(dataset => dataset.options.sessionLADUrl).filter(url => url);
270+
}
271+
272+
} else {
273+
// Check if we've hit our 15 seconds give up interval
274+
if (currentIteration > maxIterations) {
275+
resolve([]);
276+
}
277+
currentIteration++;
278+
setTimeout(checkDatasets, pollInterval);
279+
}
280+
};
281+
checkDatasets(); // Start polling
282+
});
283+
if (resolveCachedDatasets) {
284+
datasets = await cachedDatasets;
285+
} else {
286+
datasets = Object.values(this.getDatasets());
287+
}
288+
const validUrls = datasets.map(datasets => datasets.options.sessionLADUrl).filter(url => url);
253289
const sessionLADUrls = validUrls.reduce((uniqueUrls, url) => {
254290
return uniqueUrls.includes(url) ? uniqueUrls : [...uniqueUrls, url];
255291
}, []);

0 commit comments

Comments
 (0)