Skip to content

Commit

Permalink
Chore: Remove unecesary highlightThread.onMouseDown() (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum authored Nov 16, 2018
1 parent eaff0f0 commit a01db9f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
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

0 comments on commit a01db9f

Please sign in to comment.