Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Feb 13, 2024
1 parent 4ecd3b8 commit 7ff89d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class API {
}
const response: RequestUrlResponse = await requestUrl(options);
if (response.json.error) {
console.error("API server returned an error");
console.error("API server returned an error", response.json.error.message);
new Notice("API returned an error: " + response.json.error.message);
return null;
}
Expand All @@ -70,7 +70,7 @@ export class API {
}
const response: RequestUrlResponse = await requestUrl(options);
if (response.json.error) {
console.error("API server returned an error");
console.error("API server returned an error", response.json.error.message);
new Notice("API returned an error: " + response.json.error.message);
return null;
}
Expand All @@ -88,7 +88,7 @@ export class API {
}
const response: RequestUrlResponse = await requestUrl(options);
if (response.json.error) {
console.error("API server returned an error");
console.error("API server returned an error", response.json.error.message);
new Notice("API returned an error: " + response.json.error.message);
return null;
}
Expand All @@ -110,7 +110,7 @@ export class API {
const response: RequestUrlResponse = await requestUrl(options);
if (content_type == "application/json") {
if (response.json.error) {
console.error("API server returned an error");
console.error("API server returned an error", response.json.error.message);
new Notice("API returned an error: " + response.json.error.message);
return null;
}
Expand Down
9 changes: 2 additions & 7 deletions src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,14 @@ export class DocumentRepo {
// Either we POST a new document or we PUT an existing document
let response;
if (id) {
// In this case, we also need to check if we maybe have to update the assets we originally had in the document as well
// TODO: this also means that we may have to delete embeds that have been removed from the note since it has been last
// TODO: In this case, we also need to check if we maybe have to update the assets we originally had in the document as well
// this also means that we may have to delete embeds that have been removed from the note since it has been last
// sent to the API
response = await this.api.put('/v1/doc/' + id, body);
} else {
response = await this.api.post('/v1/doc?filename=' + encodeURIComponent(activeFile.path), body);
}
if (!response) return;
if (response.json.error) {
console.error("API server returned an error");
new Notice("API returned an error: " + response.json.error.message);
return;
}

console.log("Successfully sent to " + this.plugin.settings.base_uri);

Expand Down
2 changes: 1 addition & 1 deletion src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class EmbedRepo {

async upload_asset(id: string, link: string, file: TFile) {
const content = await this.plugin.app.vault.readBinary(file);
const response = await this.api.postRaw('/v1/assets/' + id, content)
const response = await this.api.postRaw('/v1/assets/' + id + '?filename=' + encodeURIComponent(file.path), content)
if (!response) return;
console.log("Successfully uploaded " + file.path + " as " + response.json.result.id);
}
Expand Down

0 comments on commit 7ff89d5

Please sign in to comment.