diff --git a/src/domain/service/PublishService.ts b/src/domain/service/PublishService.ts index e22742d..d0de1de 100644 --- a/src/domain/service/PublishService.ts +++ b/src/domain/service/PublishService.ts @@ -79,19 +79,10 @@ export class PublishService { private async init() { this.outputDir.value = await this.generator.getOutputDir(); - this.git.on(GitEvents.Progress, (e) => this.refreshPublishingProgress(e)); - this.git.on(GitEvents.Message, (message) => this.refreshPublishingProgress({ message })); - this.git.on(GitEvents.LocalRepoStatusChanged, (e) => { - this.localRepoStatus = e; - - if (this.localRepoStatus === LocalRepoStatus.Initializing) { - this.refreshPublishingProgress({ - phase: 'Local repository initializing...', - message: '', - }); - } - }); + this.git.on(GitEvents.Progress, this.refreshPublishingProgress.bind(this)); + this.git.on(GitEvents.Message, (message) => this.refreshPublishingProgress({ message })); + this.git.on(GitEvents.LocalRepoStatusChanged, this.handleLocalRepoStatusChanged.bind(this)); this.generator.on(GeneratorEvents.PageGenerated, this.refreshGeneratingProgress.bind(this)); this.githubInfo.value = { @@ -105,6 +96,17 @@ export class PublishService { } } + private handleLocalRepoStatusChanged(status: LocalRepoStatus) { + this.localRepoStatus = status; + + if (this.localRepoStatus === LocalRepoStatus.Initializing) { + this.refreshPublishingProgress({ + phase: 'Local repository initializing...', + message: '', + }); + } + } + isGithubInfoValid = computed(() => { const requiredKeys: (keyof Github)[] = ['userName', 'email', 'token']; const keyInfos = pick(this.githubInfo.value, requiredKeys);