Skip to content

Commit

Permalink
fix(octokit): await octokit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li authored Jun 8, 2023
1 parent 8aff3c2 commit 81f0cc3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/commands/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export async function purgeNotesRemoteCallback(plugin: GithubPublisher, repo: Re
checkCallback: (checking) => {
if (plugin.settings.upload.autoclean.enable && plugin.settings.upload.behavior !== FolderSettings.fixed) {
if (!checking) {
const publisher = plugin.reloadOctokit();
//@ts-ignore
const publisher = await plugin.reloadOctokit();
purgeNotesRemote(
publisher,
plugin.settings,
Expand Down Expand Up @@ -118,7 +119,8 @@ export async function shareOneNoteCallback(repo: Repository|null, plugin: Github
if (!checking) {
shareOneNote(
branchName,
plugin.reloadOctokit(),
//@ts-ignore
await plugin.reloadOctokit(),
plugin.settings,
file,
repo,
Expand Down Expand Up @@ -235,7 +237,8 @@ export async function checkRepositoryValidityCallback(plugin: GithubPublisher, r
if (!checking) {
checkRepositoryValidity(
branchName,
plugin.reloadOctokit(),
//@ts-ignore
await plugin.reloadOctokit(),
plugin.settings,
repo,
plugin.app.workspace.getActiveFile(),
Expand Down
16 changes: 8 additions & 8 deletions src/commands/plugin_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function shareActiveFile(plugin: GithubPublisher, repo: Repository
if (file && frontmatter && isShared(frontmatter, plugin.settings, file, repo)) {
await shareOneNote(
branchName,
plugin.reloadOctokit(),
await plugin.reloadOctokit(),
plugin.settings,
file,
repo,
Expand All @@ -80,7 +80,7 @@ export async function shareActiveFile(plugin: GithubPublisher, repo: Repository
*/
export async function deleteCommands(plugin : GithubPublisher, repo: Repository | null, branchName: string) {
const repoFrontmatter = getRepoFrontmatter(plugin.settings, repo);
const publisher = plugin.reloadOctokit();
const publisher = await plugin.reloadOctokit();
await purgeNotesRemote(
publisher,
plugin.settings,
Expand All @@ -102,7 +102,7 @@ export async function deleteCommands(plugin : GithubPublisher, repo: Repository

export async function uploadAllNotes(plugin: GithubPublisher, repo: Repository | null, branchName: string) {
const statusBarItems = plugin.addStatusBarItem();
const publisher = plugin.reloadOctokit();
const publisher = await plugin.reloadOctokit();
const sharedFiles = publisher.getSharedFiles();
await shareAllMarkedNotes(
publisher,
Expand All @@ -128,7 +128,7 @@ export async function uploadAllNotes(plugin: GithubPublisher, repo: Repository |
*/

export async function uploadNewNotes(plugin: GithubPublisher, branchName: string, repo: Repository|null) {
const publisher = plugin.reloadOctokit();
const publisher = await plugin.reloadOctokit();
await shareNewNote(
publisher,
publisher.octokit,
Expand All @@ -153,7 +153,7 @@ export async function repositoryValidityActiveFile(plugin:GithubPublisher, branc
if (file) {
await checkRepositoryValidity(
branchName,
plugin.reloadOctokit(),
await plugin.reloadOctokit(),
plugin.settings,
repo,
file,
Expand All @@ -171,7 +171,7 @@ export async function repositoryValidityActiveFile(plugin:GithubPublisher, branc
* @return {Promise<void>}
*/
export async function uploadAllEditedNotes(plugin: GithubPublisher ,branchName: string, repo: Repository|null=null) {
const publisher = plugin.reloadOctokit();
const publisher = await plugin.reloadOctokit();
await shareAllEditedNotes(
publisher,
publisher.octokit,
Expand All @@ -192,14 +192,14 @@ export async function uploadAllEditedNotes(plugin: GithubPublisher ,branchName:
* @return {Promise<void>}
*/
export async function shareEditedOnly(branchName: string, repo: Repository|null, plugin: GithubPublisher) {
const publisher = this.reloadOctokit();
const publisher = await plugin.reloadOctokit();
await shareOnlyEdited(
publisher,
publisher.octokit,
branchName,
plugin.app.vault,
plugin,
getRepoFrontmatter(this.settings, repo) as RepoFrontmatter,
getRepoFrontmatter(plugin.settings, repo) as RepoFrontmatter,
repo
);
}
8 changes: 7 additions & 1 deletion src/settings/modals/manage_repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ class ModalEditingRepository extends Modal {
.setButtonText(i18next.t("settings.github.testConnection"))
.setClass("github-publisher-connect-button")
.onClick(async () => {
await checkRepositoryValidity(this.branchName, this.plugin.reloadOctokit(), this.plugin.settings, this.repository, null, this.app.metadataCache);
await checkRepositoryValidity(
this.branchName,
await this.plugin.reloadOctokit(),
this.plugin.settings,
this.repository,
null,
this.app.metadataCache);
})
);
new Setting(contentEl)
Expand Down

0 comments on commit 81f0cc3

Please sign in to comment.