Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ylc395 committed Oct 18, 2021
1 parent cc1cc91 commit 4183755
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/domain/service/PublishService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class PublishService {
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.github.on(GithubClientEvents.InfoChanged, () => this.refreshPublishingProgress());
this.generator.on(GeneratorEvents.PageGenerated, this.refreshGeneratingProgress.bind(this));

this.githubInfo.value = {
Expand Down Expand Up @@ -147,11 +148,11 @@ export class PublishService {
return Object.keys(keyInfos).length === requiredKeys.length && !some(keyInfos, isEmpty);
});

async saveGithubInfo(githubInfo: Partial<Github>) {
saveGithubInfo(githubInfo: Partial<Github>) {
const githubInfo_ = omit(githubInfo, ['token']);

Object.assign(this.githubInfo.value, githubInfo_);
await this.pluginDataRepository.saveGithubInfo(omit(toRaw(this.githubInfo.value), ['token']));
this.pluginDataRepository.saveGithubInfo(omit(toRaw(this.githubInfo.value), ['token']));
this.initGithubClient();
}

Expand Down Expand Up @@ -189,6 +190,7 @@ export class PublishService {
this.git.terminate();
}

// must confirmed by user to create repo. so we can not use `isRepositoryMissing` instead
async publish(needToCreateRepo = false) {
if (this.isPublishing.value) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/driver/git/webviewApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class Git extends EventEmitter<GitEvents> {
return this.initRepo();
}

private initRepo(byPublishing = false) {
private initRepo(byPushing = false) {
this.emit(GitEvents.LocalRepoStatusChanged, LocalRepoStatus.Initializing);
// always init worker when init repo
this.initWorker();

Expand Down Expand Up @@ -86,7 +87,6 @@ class Git extends EventEmitter<GitEvents> {
};

this.rejectInitRepoPromise = reject_;
this.emit(GitEvents.LocalRepoStatusChanged, LocalRepoStatus.Initializing);
workerGit
.initRepo({
githubInfo: github.getGithubInfo(),
Expand All @@ -96,7 +96,7 @@ class Git extends EventEmitter<GitEvents> {
url: github.getRepositoryUrl(),
remote: Git.remote,
},
keepDir: byPublishing,
keepDir: byPushing,
})
.then(resolve_, reject_);
});
Expand Down
3 changes: 1 addition & 2 deletions src/driver/github/webviewApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export class Github extends EventEmitter<GithubClientEvents> implements GithubCl
return;
}

this.emit(GithubClientEvents.InfoChanged, githubInfo);
this.githubInfo = githubInfo;
this.emit(GithubClientEvents.InfoChanged, this.githubInfo);
}

async createRepository() {
Expand Down

0 comments on commit 4183755

Please sign in to comment.