Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Remove unnecesary highlightThread.onMouseDown() #291

Merged
merged 2 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,11 @@ class DocAnnotator extends Annotator {
this.isCreatingHighlight = true;

if (this.plainHighlightEnabled) {
this.modeControllers[TYPES.highlight].applyActionToThreads((thread) => thread.onMousedown());
this.modeControllers[TYPES.highlight].destroyPendingThreads();
}

if (this.commentHighlightEnabled) {
this.modeControllers[TYPES.highlight_comment].applyActionToThreads((thread) => thread.onMousedown());
this.modeControllers[TYPES.highlight_comment].destroyPendingThreads();
}
};

Expand Down
12 changes: 0 additions & 12 deletions src/doc/DocHighlightThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ class DocHighlightThread extends AnnotationThread {
}
};

/**
* Mousedown handler for thread. Deletes this thread if it is still pending.
*
* @return {void}
*/
onMousedown() {
// Destroy pending highlights on mousedown
if (this.state === STATES.pending) {
this.destroy();
}
}

/**
* Click handler for thread. If click is inside this highlight, set the
* state to be active, and return true. If not, hide the delete highlight
Expand Down
4 changes: 2 additions & 2 deletions src/doc/__tests__/DocAnnotator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,13 @@ describe('doc/DocAnnotator', () => {

it('should do nothing if highlights are disabled', () => {
annotator.highlightMousedownHandler({ clientX: 1, clientY: 1 });
expect(thread.onMousedown).not.toBeCalled();
expect(controller.destroyPendingThreads).not.toBeCalled();
});

it('should get highlights on page and call their onMouse down method', () => {
annotator.plainHighlightEnabled = true;
annotator.highlightMousedownHandler({ clientX: 1, clientY: 1 });
expect(controller.applyActionToThreads).toBeCalled();
expect(controller.destroyPendingThreads).toBeCalled();
});
});

Expand Down
9 changes: 0 additions & 9 deletions src/doc/__tests__/DocHighlightThread-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ describe('doc/DocHighlightThread', () => {
});
});

describe('onMousedown()', () => {
it('should destroy the thread when annotation is in pending state', () => {
thread.state = STATES.pending;
thread.destroy = jest.fn();
thread.onMousedown();
expect(thread.destroy).toBeCalled();
});
});

describe('onClick()', () => {
it('should set annotation to inactive if event has already been consumed', () => {
thread.state = STATES.active;
Expand Down