Skip to content

Commit

Permalink
chore: remove extra char
Browse files Browse the repository at this point in the history
  • Loading branch information
windily-cloud committed Aug 3, 2023
1 parent 3715beb commit 92e264a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
63 changes: 31 additions & 32 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { end } from "@popperjs/core";
import { requestUrl } from "obsidian";

export interface SearchResponse {
Expand Down Expand Up @@ -168,37 +167,37 @@ export const loadArticles = async (


export const deleteArticleById = async (endpoint: string, apiKey: string, articleId: string) => {
const res = await requestUrl({
url: endpoint,
headers: requestHeaders(apiKey),
body: JSON.stringify({
query: `
mutation SetBookmarkArticle($input: SetBookmarkArticleInput!) {
setBookmarkArticle(input: $input) {
... on SetBookmarkArticleSuccess {
bookmarkedArticle {
id
}
}
... on SetBookmarkArticleError {
errorCodes
}
}
}`,
variables: {
input: {
"articleID": articleId,
"bookmark": false
}
},
}),
method: "POST",
});
const res = await requestUrl({
url: endpoint,
headers: requestHeaders(apiKey),
body: JSON.stringify({
query: `
mutation SetBookmarkArticle($input: SetBookmarkArticleInput!) {
setBookmarkArticle(input: $input) {
... on SetBookmarkArticleSuccess {
bookmarkedArticle {
id
}
}
... on SetBookmarkArticleError {
errorCodes
}
}
}`,
variables: {
input: {
"articleID": articleId,
"bookmark": false
}
},
}),
method: "POST",
});

const jsonRes = res.json as DeleteArticleResponse;
if (jsonRes.data.setBookmarkArticle.bookmarkedArticle.id === articleId) {
return true;
}
const jsonRes = res.json as DeleteArticleResponse;
if (jsonRes.data.setBookmarkArticle.bookmarkedArticle.id === articleId) {
return true;
}

return false
return false
}
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class OmnivorePlugin extends Plugin {
id: "deleteArticle",
name: "Delete Current Article from Omnivore",
callback: () => {
this.deleteCurrentArticle(this.app.workspace.getActiveFile());
this.deleteCurrentArticle(this.app.workspace.getActiveFile());
}
})

Expand Down Expand Up @@ -378,7 +378,7 @@ export default class OmnivorePlugin extends Plugin {
}
}

private deleteCurrentArticle(file: TFile | null) {
private async deleteCurrentArticle(file: TFile | null) {
if(!file) {
return
}
Expand All @@ -389,13 +389,16 @@ export default class OmnivorePlugin extends Plugin {
}

try{
deleteArticleById(this.settings.endpoint, this.settings.apiKey, articleId)
const isDeleted = deleteArticleById(this.settings.endpoint, this.settings.apiKey, articleId)
if(!isDeleted) {
new Notice("Failed to delete article in Omnivore");
}
} catch (e) {
new Notice("Failed to delete article in Omnivore");
console.error(e);
}

this.app.vault.delete(file)
await this.app.vault.delete(file)
}

private async resetSyncingStateSetting() {
Expand Down

0 comments on commit 92e264a

Please sign in to comment.