Skip to content

Commit

Permalink
fix: fix siyuan note create document
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondYuan committed Aug 12, 2021
1 parent 094658c commit d45a6ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/common/backend/clients/siyuan/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ export class SiYuanClient {
});
}

listNotebooks = async (): Promise<string[]> => {
listNotebooks = async (): Promise<{ id: string; name: string }[]> => {
const res = await this.request.post<ISiyuanFetchNotesResponse>(`api/notebook/ls`, {
data: {},
});
return res.data.files.map(p => p.split('/')[p.split('/').length - 1]);
return res.data.files.map(p => {
if (typeof p === 'object') {
return p;
}
return {
name: p.split('/')[p.split('/').length - 1],
id: p.split('/')[p.split('/').length - 1],
};
});
};

createNote = async (data: CreateDocumentRequest) => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/backend/clients/siyuan/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export interface ISiyuanUploadImageResponse {
}

export interface ISiyuanFetchNotesResponse {
data: { files: string[] };
data: { files: string[] | { name: string; id: string }[] };
}
7 changes: 3 additions & 4 deletions src/common/backend/services/siyuan/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ export default class SiYuanDocumentService implements DocumentService {

getRepositories = async () => {
let response = await this.client.listNotebooks();
console.log('response', response);
return response.map(
(name): Repository => {
({ name, id }): Repository => {
return {
groupId: 'siyuan',
groupName: localeService.format({
id: 'backend.services.siyuan.notes',
}),
id: name,
name: name,
id,
name,
};
}
);
Expand Down

0 comments on commit d45a6ec

Please sign in to comment.