Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle failed sync state #37

Merged
merged 4 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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