Skip to content

Commit

Permalink
Rename showOutsideAssignmentNotice -> `setOutsideAssignmentNoticeVi…
Browse files Browse the repository at this point in the history
…sible`

The new name is verbose, but it makes it more obvious how the call functions.
  • Loading branch information
robertknight committed Feb 6, 2024
1 parent a02eaff commit c19a5a2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/annotator/guest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,12 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable {
this._integration.showContentInfo?.(info),
);

this._sidebarRPC.on('showOutsideAssignmentNotice', (show: boolean) => {
this._showOutsideAssignmentNotice(show);
});
this._sidebarRPC.on(
'setOutsideAssignmentNoticeVisible',
(show: boolean) => {
this._setOutsideAssignmentNoticeVisible(show);
},
);

this._sidebarRPC.on('navigateToSegment', (annotation: AnnotationData) =>
this._integration.navigateToSegment?.(annotation),
Expand Down Expand Up @@ -925,13 +928,14 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable {
/**
* Handle a potential shortcut trigger.
*/
_handleShortcut(event: KeyboardEvent) {
private _handleShortcut(event: KeyboardEvent) {
if (matchShortcut(event, 'Ctrl+Shift+H')) {
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) {
this._outsideAssignmentNotice = new OutsideAssignmentNoticeController(
this.element,
Expand Down
4 changes: 2 additions & 2 deletions src/annotator/test/guest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ describe('Guest', () => {
});
});

describe('on "showOutsideAssignmentNotice" event', () => {
describe('on "setOutsideAssignmentNoticeVisible" event', () => {
[true, false].forEach(arg => {
it('shows notice if argument is `true`', () => {
createGuest();
emitSidebarEvent('showOutsideAssignmentNotice', arg);
emitSidebarEvent('setOutsideAssignmentNoticeVisible', arg);
assert.calledWith(fakeOutsideAssignmentNotice.setVisible, arg);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/services/frame-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class FrameSyncService {
info.segmentInfo,
focusFilters,
);
guestRPC.call('showOutsideAssignmentNotice', !match);
guestRPC.call('setOutsideAssignmentNoticeVisible', !match);
}

this._store.connectFrame({
Expand Down
6 changes: 3 additions & 3 deletions src/sidebar/services/test/frame-sync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ describe('FrameSyncService', () => {
it('is not displayed if no focus filter is configured', async () => {
await connectEPUBGuest();
assert.isFalse(
guestRPC().call.calledWith('showOutsideAssignmentNotice'),
guestRPC().call.calledWith('setOutsideAssignmentNoticeVisible'),
);
});

Expand All @@ -477,7 +477,7 @@ describe('FrameSyncService', () => {
await connectEPUBGuest();
assert.calledWith(
guestRPC().call,
'showOutsideAssignmentNotice',
'setOutsideAssignmentNoticeVisible',
false,
);
});
Expand All @@ -487,7 +487,7 @@ describe('FrameSyncService', () => {
await connectEPUBGuest();
assert.calledWith(
guestRPC().call,
'showOutsideAssignmentNotice',
'setOutsideAssignmentNoticeVisible',
true,
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/types/port-rpc-events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export type SidebarToGuestEvent =
* Show a notice that the user is outside the region of the document for the
* current activity / assignment.
*/
| 'showOutsideAssignmentNotice';
| 'setOutsideAssignmentNoticeVisible';

/**
* Events that the sidebar sends to the host
Expand Down

0 comments on commit c19a5a2

Please sign in to comment.