Skip to content

Commit

Permalink
apply changes from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
joethei committed Dec 7, 2021
1 parent 23cc414 commit 5b2a4b9
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,39 @@ export default class TTSPlugin extends Plugin {
this.addCommand({
id: 'start-tts-playback',
name: 'Start playback',
checkCallback: (checking: boolean) => {
const markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!markdownView) return;
if (checking)
return !!(markdownView);
this.ttsService.play(markdownView);

editorCallback: (editor, view) => {
this.ttsService.play(view);
}
});

this.addCommand({
id: 'cancel-tts-playback',
name: 'Stop playback',
checkCallback: (checking: boolean) => {
if (checking)
return this.ttsService.isSpeaking();
this.ttsService.stop();
if (!checking)
this.ttsService.stop();
return this.ttsService.isSpeaking();

}
});

this.addCommand({
id: 'pause-tts-playback',
name: 'pause playback',
checkCallback: (checking: boolean) => {
if (checking)
return this.ttsService.isSpeaking();
this.ttsService.pause();
if (!checking)
this.ttsService.pause();
return this.ttsService.isSpeaking();
}
});

this.addCommand({
id: 'resume-tts-playback',
name: 'Resume playback',
checkCallback: (checking: boolean) => {
if (checking)
return this.ttsService.isPaused();
this.ttsService.resume();
if (!checking)
this.ttsService.resume();
return this.ttsService.isPaused();
}
});

Expand Down

0 comments on commit 5b2a4b9

Please sign in to comment.