Skip to content

Commit

Permalink
Merge pull request #37 from Mearman/handle-failed-sync
Browse files Browse the repository at this point in the history
Handle failed sync state
  • Loading branch information
sywhb authored Mar 31, 2023
2 parents cca8a7d + 8432a16 commit 43a3966
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class OmnivorePlugin extends Plugin {

async onload() {
await this.loadSettings();

await this.resetSyncingStateSetting();
this.addCommand({
id: "sync",
name: "Sync",
Expand Down Expand Up @@ -178,7 +178,10 @@ export default class OmnivorePlugin extends Plugin {
folder,
} = this.settings;

if (syncing) return;
if (syncing) {
new Notice("🐢 Already syncing ...");
return;
}

if (!apiKey) {
new Notice("Missing Omnivore api key");
Expand Down Expand Up @@ -380,6 +383,11 @@ export default class OmnivorePlugin extends Plugin {
return "";
}
}

private async resetSyncingStateSetting() {
this.settings.syncing = false;
await this.saveSettings();
}
}

class OmnivoreSettingTab extends PluginSettingTab {
Expand Down
12 changes: 6 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ export const loadArticle = async (
export const loadArticles = async (
endpoint: string,
apiKey: string,
after = 0,
first = 10,
updatedAt = "",
query = "",
includeContent = false,
format = "html"
after: number = 0,
first: number = 10,
updatedAt: string = "",
query: string = "",
includeContent: boolean = false,
format: string = "html"
): Promise<[Article[], boolean]> => {
const res = await requestUrl({
url: endpoint,
Expand Down

0 comments on commit 43a3966

Please sign in to comment.