From ab54885411cf188fdb4fc86e4d33b460741570d0 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 21 Aug 2024 11:03:10 +0100 Subject: [PATCH] Fix failure to fetch groups in VitalSource Before loading groups the client waits for the main document frame to connect in order to be able to fetch groups associated with that frame's URL. In VitalSource however there is no "main frame", only the current content frame, so `GroupsService._loadGroupsForUserAndDocument` waited indefinitely. This failure to fetch groups did not happen on the initial launch due to a different bug in `GroupsService._loadGroupsForUserAndDocument`. The `this_store.route()` call returned `null` during startup and hence the code did not wait for the main frame to connect. After a subsequent login/logout however, the `route` call returned "sidebar" and the code did wait for the main frame. This problem also did not happen in the LMS environment because there the client loads a set of groups specified by our LMS app, instead of fetching groups based on the logged-in user and current document. Solve the first problem by using the `defaultContentFrame` method to get the frame instead of `mainFrame`. `defaultContentFrame` returns the main frame if there is one, or the first content frame that connected otherwise. --- src/sidebar/services/groups.ts | 2 +- src/sidebar/services/test/groups-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sidebar/services/groups.ts b/src/sidebar/services/groups.ts index f7ff69ae46c..4fc3ab8274d 100644 --- a/src/sidebar/services/groups.ts +++ b/src/sidebar/services/groups.ts @@ -83,7 +83,7 @@ export class GroupsService { * the site that the user is on. */ private _mainURI(): string | null { - return this._store.mainFrame()?.uri ?? null; + return this._store.defaultContentFrame()?.uri ?? null; } /** diff --git a/src/sidebar/services/test/groups-test.js b/src/sidebar/services/test/groups-test.js index e735d8921f8..87641f0f1cd 100644 --- a/src/sidebar/services/test/groups-test.js +++ b/src/sidebar/services/test/groups-test.js @@ -81,7 +81,7 @@ describe('GroupsService', () => { focusedGroup() { return this.getState().groups.focusedGroup; }, - mainFrame() { + defaultContentFrame() { return this.getState().frames[0]; }, setDefault: sinon.stub(),