Skip to content

Commit 351f2e3

Browse files
committed
feat(publish): Force update index.md to update left tree if files deleted in the link list.
1 parent fa989b3 commit 351f2e3

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/main.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,32 +426,41 @@ export default class InvioPlugin extends Plugin {
426426
log.info('selected mode');
427427
log.info('pub list: ', pubPathList, unPubList);
428428
}
429-
430-
await publishFiles(client, this.app.vault, pubPathList, allFiles, '', this.settings, triggerSource, view, (pathName: string, status: string, meta?: any) => {
429+
430+
await unpublishFile(client, this.app.vault, unPubList, (pathName: string, status: string) => {
431431
log.info('publishing ', pathName, status);
432432
if (status === 'START') {
433433
log.info('set file start publishing', pathName);
434434
view?.update(pathName, { syncStatus: 'publishing' })
435435
} else if (status === 'DONE') {
436-
log.info('set file DONE publishing', pathName);
437-
view?.update(pathName, { syncStatus: 'done', remoteLink: meta })
436+
view?.update(pathName, { syncStatus: 'done' })
438437
} else if (status === 'FAIL') {
439438
view?.update(pathName, { syncStatus: 'fail' })
440439
}
441-
});
440+
});
442441

443-
await unpublishFile(client, this.app.vault, unPubList, (pathName: string, status: string) => {
442+
if (pubPathList?.length === 0) {
443+
if (unPubList?.length > 0) {
444+
// Need to update left tree links for unpublish means link deduction
445+
const indexFile = allFiles.find(file => file.name === 'index.md') || allFiles[0];
446+
pubPathList.push(indexFile.path);
447+
}
448+
}
449+
await publishFiles(client, this.app.vault, pubPathList, allFiles, '', this.settings, triggerSource, view, (pathName: string, status: string, meta?: any) => {
444450
log.info('publishing ', pathName, status);
445451
if (status === 'START') {
446452
log.info('set file start publishing', pathName);
447453
view?.update(pathName, { syncStatus: 'publishing' })
448454
} else if (status === 'DONE') {
449-
view?.update(pathName, { syncStatus: 'done' })
455+
log.info('set file DONE publishing', pathName);
456+
view?.update(pathName, { syncStatus: 'done', remoteLink: meta })
450457
} else if (status === 'FAIL') {
451458
view?.update(pathName, { syncStatus: 'fail' })
452459
}
453460
});
454461

462+
463+
455464
if (triggerSource === 'force') {
456465
const forceList: string[] = [];
457466
for (const key in plan.mixedStates) {

0 commit comments

Comments
 (0)