mirror of
https://github.com/memodack/memodack.git
synced 2026-07-22 11:50:25 +00:00
feat: add CheckService
This commit is contained in:
parent
8d4bfc8f27
commit
f263b91c80
1 changed files with 57 additions and 0 deletions
57
src/check.service.ts
Normal file
57
src/check.service.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { ITranslationService } from './translation.service';
|
||||
import { ITtsService } from './tts.service';
|
||||
import { Notice } from 'obsidian';
|
||||
|
||||
export interface ICheckService {
|
||||
check(): Promise<void>;
|
||||
}
|
||||
|
||||
export class CheckService implements ICheckService {
|
||||
private translationService: ITranslationService;
|
||||
private ttsService: ITtsService;
|
||||
|
||||
constructor(
|
||||
translationService: ITranslationService,
|
||||
ttsService: ITtsService,
|
||||
) {
|
||||
this.translationService = translationService;
|
||||
this.ttsService = ttsService;
|
||||
}
|
||||
|
||||
async check(): Promise<void> {
|
||||
this.checkTranslation();
|
||||
this.checkTts();
|
||||
}
|
||||
|
||||
async checkTranslation(): Promise<void> {
|
||||
try {
|
||||
const response = await this.translationService.translate('ping');
|
||||
|
||||
if (!response) {
|
||||
new Notice('The translation service is not working.');
|
||||
return;
|
||||
}
|
||||
|
||||
new Notice('The translation service is working.');
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (e) {
|
||||
new Notice('The translation service is not working.');
|
||||
}
|
||||
}
|
||||
|
||||
async checkTts(): Promise<void> {
|
||||
try {
|
||||
const response = await this.ttsService.tts('ping');
|
||||
|
||||
if (!response) {
|
||||
new Notice('The text-to-speech service is not working.');
|
||||
return;
|
||||
}
|
||||
|
||||
new Notice('The text-to-speech service is working.');
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (e) {
|
||||
new Notice('The text-to-speech service is not working.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue