Skip to content

Commit 0364396

Browse files
karenrasmussensanticomp2014
authored andcommitted
Address PR comments
1 parent ebdd8da commit 0364396

File tree

5 files changed

+7
-29
lines changed

5 files changed

+7
-29
lines changed

src/sidebar/components/KeyboardShortcutsModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { useMemo, useState } from 'preact/hooks';
1010
import ModalDialog from '../../annotator/components/ModalDialog';
1111
import {
1212
getAllShortcuts,
13-
getDefaultShortcuts,
1413
parseShortcutInputEvent,
1514
repeatableShortcutGroups,
1615
resetShortcuts,
@@ -159,7 +158,7 @@ function ShortcutActions({
159158
onClick={async () => {
160159
resetShortcuts();
161160
try {
162-
await session.updateShortcutPreferences(getDefaultShortcuts());
161+
await session.updateShortcutPreferences({});
163162
onSaveError(null);
164163
} catch {
165164
onSaveError('Unable to save keyboard shortcuts');

src/sidebar/components/test/KeyboardShortcutsModal-test.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ describe('KeyboardShortcutsModal', () => {
88
let fakeSession;
99
let fakeStore;
1010
let fakeShortcuts;
11-
let fakeDefaultShortcuts;
1211
let fakeShortcutDefinitions;
1312
let fakeGetAllShortcuts;
14-
let fakeGetDefaultShortcuts;
1513
let fakeParseShortcutInputEvent;
1614
let fakeRepeatableShortcutGroups;
1715
let fakeResetShortcuts;
@@ -43,11 +41,6 @@ describe('KeyboardShortcutsModal', () => {
4341
annotateSelection: 'a',
4442
};
4543

46-
fakeDefaultShortcuts = {
47-
applyUpdates: 'l',
48-
annotateSelection: 'a',
49-
};
50-
5144
fakeShortcutDefinitions = [
5245
{
5346
id: 'applyUpdates',
@@ -69,7 +62,6 @@ describe('KeyboardShortcutsModal', () => {
6962
};
7063

7164
fakeGetAllShortcuts = sinon.stub().returns(fakeShortcuts);
72-
fakeGetDefaultShortcuts = sinon.stub().returns(fakeDefaultShortcuts);
7365
fakeParseShortcutInputEvent = sinon.stub();
7466
fakeResetShortcuts = sinon.stub();
7567
fakeSetAllShortcuts = sinon.stub();
@@ -80,7 +72,6 @@ describe('KeyboardShortcutsModal', () => {
8072
'../store': { useSidebarStore: () => fakeStore },
8173
'../../shared/shortcut-config': {
8274
getAllShortcuts: fakeGetAllShortcuts,
83-
getDefaultShortcuts: fakeGetDefaultShortcuts,
8475
parseShortcutInputEvent: fakeParseShortcutInputEvent,
8576
repeatableShortcutGroups: fakeRepeatableShortcutGroups,
8677
resetShortcuts: fakeResetShortcuts,
@@ -140,10 +131,7 @@ describe('KeyboardShortcutsModal', () => {
140131
resetButton.props().onClick();
141132

142133
assert.called(fakeResetShortcuts);
143-
assert.calledWith(
144-
fakeSession.updateShortcutPreferences,
145-
fakeGetDefaultShortcuts.returnValues[0],
146-
);
134+
assert.calledWith(fakeSession.updateShortcutPreferences, {});
147135
});
148136

149137
it('does not save shortcuts when duplicates exist', () => {

src/sidebar/components/test/UserMenu-test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,6 @@ describe('UserMenu', () => {
412412
}
413413
});
414414
});
415-
416-
it('calls onLogout when clicked', () => {
417-
fakeIsThirdPartyUser.returns(false);
418-
fakeServiceConfig.returns(null);
419-
const wrapper = createUserMenu();
420-
421-
const logOutMenuItem = findMenuItem(wrapper, 'Log out');
422-
logOutMenuItem.props().onClick();
423-
424-
assert.calledOnce(fakeOnLogout);
425-
});
426415
});
427416

428417
describe('open dashboard menu item', () => {

src/sidebar/services/test/session-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('SessionService', () => {
205205

206206
it('applies shortcut preferences from the profile', () => {
207207
const session = createService();
208-
const shortcuts = { sidebar: { createAnnotation: ['c'] } };
208+
const shortcuts = { applyUpdates: 'c' };
209209

210210
session.update({
211211
userid: 'anne',
@@ -231,7 +231,7 @@ describe('SessionService', () => {
231231
const updatedProfile = {
232232
userid: 'acct:user@hypothes.is',
233233
preferences: {
234-
shortcuts_preferences: { sidebar: { createAnnotation: ['c'] } },
234+
shortcuts_preferences: { applyUpdates: 'c' },
235235
},
236236
};
237237
fakeApi.profile.update.resolves(updatedProfile);

src/types/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ export type Annotation = ClientAnnotationData & APIAnnotationData;
359359
*/
360360
export type SavedAnnotation = Annotation & { id: string };
361361

362-
export type ShortcutsPreferences = Partial<Record<string, string | null>>;
362+
export type ShortcutsPreferences = Partial<
363+
Record<string, string | null>
364+
> | null;
363365

364366
export type Profile = {
365367
userid: string | null;

0 commit comments

Comments
 (0)