@@ -11,6 +11,7 @@ import { inputPostSettings } from '../../utils/input-post-settings';
11
11
import { searchPostsByTitle } from '../../services/search-post-by-title' ;
12
12
import * as path from 'path' ;
13
13
import { refreshPostsList } from './refresh-posts-list' ;
14
+ import { PostEditDto } from '../../models/post-edit-dto' ;
14
15
15
16
export const savePostFileToCnblogs = async ( fileUri : Uri ) => {
16
17
if ( ! fileUri || fileUri . scheme !== 'file' ) {
@@ -21,7 +22,7 @@ export const savePostFileToCnblogs = async (fileUri: Uri) => {
21
22
// const fileNameWithoutExt = path.basename(fileName, path.extname(fileName));
22
23
const postId = PostFileMapManager . getPostId ( filePath ) ;
23
24
if ( postId && postId >= 0 ) {
24
- await savePostToCnblogs ( ( await postService . fetchPostEditDto ( postId ) ) . post ) ;
25
+ await savePostToCnblogs ( await postService . fetchPostEditDto ( postId ) ) ;
25
26
} else {
26
27
const options = [ `新建博文` , `关联已有博文` ] ;
27
28
const selected = await window . showInformationMessage (
@@ -84,15 +85,16 @@ export const saveLocalDraftToCnblogs = async (localDraft: LocalDraftFile) => {
84
85
}
85
86
Object . assign ( post , userInputPostConfig ) ;
86
87
87
- if ( ! ( await savePostToCnblogs ( post , true ) ) ) {
88
+ if ( ! ( await savePostToCnblogs ( editDto , true ) ) ) {
88
89
return ;
89
90
}
90
91
await PostFileMapManager . updateOrCreate ( post . id , localDraft . filePath ) ;
91
92
postsDataProvider . fireTreeDataChangedEvent ( undefined ) ;
92
93
await openPostFile ( localDraft ) ;
93
94
} ;
94
95
95
- export const savePostToCnblogs = async ( post : Post , isNewPost = false ) => {
96
+ export const savePostToCnblogs = async ( input : Post | PostEditDto , isNewPost = false ) => {
97
+ const post = input instanceof PostEditDto ? input . post : ( await postService . fetchPostEditDto ( input . id ) ) . post ;
96
98
if ( ! post ) {
97
99
return ;
98
100
}
0 commit comments