From ffc43e07f074b60371b2288f5ce44ad1481d27d3 Mon Sep 17 00:00:00 2001 From: ylc395 Date: Sun, 17 Oct 2021 12:46:59 +0800 Subject: [PATCH] handleLocalRepoStatusChanged --- src/domain/service/PublishService.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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);