Skip to content

Commit

Permalink
refactor: adding noticeMessage for workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed May 23, 2022
1 parent cd7eb66 commit 7d45722
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions mkdocsPublisher/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
import {
App,
TFile
App,
TFile,
Notice
} from 'obsidian'
import { MkdocsPublicationSettings } from '../settings'
import MkdocsPublish from "./publication";


function disablePublish (app: App, settings: MkdocsPublicationSettings, file:TFile) {
const fileCache = app.metadataCache.getFileCache(file)
const meta = fileCache?.frontmatter
const folderList = settings.ExcludedFolder.split(',').filter(x => x!=='')
if (meta === undefined) {
return false
} else if (folderList.length > 0) {
for (let i = 0; i < folderList.length; i++) {
if (file.path.contains(folderList[i].trim())) {
return false
}
}
}
return meta[settings.shareKey]
const fileCache = app.metadataCache.getFileCache(file)
const meta = fileCache?.frontmatter
const folderList = settings.ExcludedFolder.split(',').filter(x => x!=='')
if (meta === undefined) {
return false
} else if (folderList.length > 0) {
for (let i = 0; i < folderList.length; i++) {
if (file.path.contains(folderList[i].trim())) {
return false
}
}
}
return meta[settings.shareKey]
}

export {disablePublish }
async function noticeMessage(publish: MkdocsPublish, file: TFile | string, settings: MkdocsPublicationSettings) {
const noticeValue = (file instanceof TFile) ? '"' + file.basename + '"' : file
const msg = settings.workflowName.length>0? '.\nNow, waiting for the workflow to be completed...':'.'
new Notice('Send ' + noticeValue + ' to ' + settings.githubRepo + msg);
const successWorkflow = await publish.workflowGestion();
if (successWorkflow) {
new Notice(
"Successfully published " + noticeValue + " to " + settings.githubRepo + "."
);
}
}

export {disablePublish, noticeMessage }

0 comments on commit 7d45722

Please sign in to comment.