Commit 8aa3c21f authored by Robert Knight's avatar Robert Knight

Only check for flag changes before sending feature flags to annotator

Feature flags are now sent to the host frame, which never changes, so
there is no point in re-sending flags when guest frames change. In
future we'll need to figure out how to communicate feature flags to
guest frames and depending on whether the sidebar or host frame does
this, the sidebar may once again need to react to guest frames changing.
parent 46045480
...@@ -23,17 +23,10 @@ export class FeaturesService { ...@@ -23,17 +23,10 @@ export class FeaturesService {
} }
init() { init() {
const currentFlags = () => this._store.profile().features;
const sendFeatureFlags = () => {
this._frameSync.notifyHost('featureFlagsUpdated', currentFlags() || {});
};
// Re-send feature flags to connected frames when flags change or a new
// frame connects.
watch( watch(
this._store.subscribe, this._store.subscribe,
[currentFlags, () => this._store.frames()], () => this._store.profile().features,
sendFeatureFlags flags => this._frameSync.notifyHost('featureFlagsUpdated', flags || {})
); );
} }
} }
...@@ -55,23 +55,4 @@ describe('FeaturesService', () => { ...@@ -55,23 +55,4 @@ describe('FeaturesService', () => {
fakeStore.profile().features fakeStore.profile().features
); );
}); });
it('should broadcast feature flags to annotator if a new frame connects', () => {
createService();
// First update, with no changes to frames.
notifyStoreSubscribers();
assert.notCalled(fakeFrameSync.notifyHost);
// Second update, with changes to frames.
fakeStore.frames.returns([{ uri: 'https://example.com' }]);
notifyStoreSubscribers();
assert.calledWith(
fakeFrameSync.notifyHost,
'featureFlagsUpdated',
fakeStore.profile().features
);
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment