Commit c19a5a25 authored by Robert Knight's avatar Robert Knight

Rename `showOutsideAssignmentNotice` -> `setOutsideAssignmentNoticeVisible`

The new name is verbose, but it makes it more obvious how the call functions.
parent a02eaffe
...@@ -586,9 +586,12 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable { ...@@ -586,9 +586,12 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable {
this._integration.showContentInfo?.(info), this._integration.showContentInfo?.(info),
); );
this._sidebarRPC.on('showOutsideAssignmentNotice', (show: boolean) => { this._sidebarRPC.on(
this._showOutsideAssignmentNotice(show); 'setOutsideAssignmentNoticeVisible',
}); (show: boolean) => {
this._setOutsideAssignmentNoticeVisible(show);
},
);
this._sidebarRPC.on('navigateToSegment', (annotation: AnnotationData) => this._sidebarRPC.on('navigateToSegment', (annotation: AnnotationData) =>
this._integration.navigateToSegment?.(annotation), this._integration.navigateToSegment?.(annotation),
...@@ -925,13 +928,14 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable { ...@@ -925,13 +928,14 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable {
/** /**
* Handle a potential shortcut trigger. * Handle a potential shortcut trigger.
*/ */
_handleShortcut(event: KeyboardEvent) { private _handleShortcut(event: KeyboardEvent) {
if (matchShortcut(event, 'Ctrl+Shift+H')) { if (matchShortcut(event, 'Ctrl+Shift+H')) {
this.setHighlightsVisible(!this._highlightsVisible); this.setHighlightsVisible(!this._highlightsVisible);
} }
} }
_showOutsideAssignmentNotice(show: boolean) { /** Show or hide banner warning user they are outside page range for assignment. */
private _setOutsideAssignmentNoticeVisible(show: boolean) {
if (!this._outsideAssignmentNotice) { if (!this._outsideAssignmentNotice) {
this._outsideAssignmentNotice = new OutsideAssignmentNoticeController( this._outsideAssignmentNotice = new OutsideAssignmentNoticeController(
this.element, this.element,
......
...@@ -606,11 +606,11 @@ describe('Guest', () => { ...@@ -606,11 +606,11 @@ describe('Guest', () => {
}); });
}); });
describe('on "showOutsideAssignmentNotice" event', () => { describe('on "setOutsideAssignmentNoticeVisible" event', () => {
[true, false].forEach(arg => { [true, false].forEach(arg => {
it('shows notice if argument is `true`', () => { it('shows notice if argument is `true`', () => {
createGuest(); createGuest();
emitSidebarEvent('showOutsideAssignmentNotice', arg); emitSidebarEvent('setOutsideAssignmentNoticeVisible', arg);
assert.calledWith(fakeOutsideAssignmentNotice.setVisible, arg); assert.calledWith(fakeOutsideAssignmentNotice.setVisible, arg);
}); });
}); });
......
...@@ -370,7 +370,7 @@ export class FrameSyncService { ...@@ -370,7 +370,7 @@ export class FrameSyncService {
info.segmentInfo, info.segmentInfo,
focusFilters, focusFilters,
); );
guestRPC.call('showOutsideAssignmentNotice', !match); guestRPC.call('setOutsideAssignmentNoticeVisible', !match);
} }
this._store.connectFrame({ this._store.connectFrame({
......
...@@ -468,7 +468,7 @@ describe('FrameSyncService', () => { ...@@ -468,7 +468,7 @@ describe('FrameSyncService', () => {
it('is not displayed if no focus filter is configured', async () => { it('is not displayed if no focus filter is configured', async () => {
await connectEPUBGuest(); await connectEPUBGuest();
assert.isFalse( assert.isFalse(
guestRPC().call.calledWith('showOutsideAssignmentNotice'), guestRPC().call.calledWith('setOutsideAssignmentNoticeVisible'),
); );
}); });
...@@ -477,7 +477,7 @@ describe('FrameSyncService', () => { ...@@ -477,7 +477,7 @@ describe('FrameSyncService', () => {
await connectEPUBGuest(); await connectEPUBGuest();
assert.calledWith( assert.calledWith(
guestRPC().call, guestRPC().call,
'showOutsideAssignmentNotice', 'setOutsideAssignmentNoticeVisible',
false, false,
); );
}); });
...@@ -487,7 +487,7 @@ describe('FrameSyncService', () => { ...@@ -487,7 +487,7 @@ describe('FrameSyncService', () => {
await connectEPUBGuest(); await connectEPUBGuest();
assert.calledWith( assert.calledWith(
guestRPC().call, guestRPC().call,
'showOutsideAssignmentNotice', 'setOutsideAssignmentNoticeVisible',
true, true,
); );
}); });
......
...@@ -144,7 +144,7 @@ export type SidebarToGuestEvent = ...@@ -144,7 +144,7 @@ export type SidebarToGuestEvent =
* Show a notice that the user is outside the region of the document for the * Show a notice that the user is outside the region of the document for the
* current activity / assignment. * current activity / assignment.
*/ */
| 'showOutsideAssignmentNotice'; | 'setOutsideAssignmentNoticeVisible';
/** /**
* Events that the sidebar sends to the host * Events that the sidebar sends to the host
......
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