mirror of
https://github.com/heroblackink/ultimate-todoist-sync-for-obsidian.git
synced 2026-07-22 07:40:27 +00:00
You can check database in the settings.
This commit is contained in:
parent
4fb8bd6079
commit
051adb4e57
4 changed files with 54 additions and 8 deletions
|
|
@ -29,7 +29,9 @@ export class CacheOperation {
|
|||
return this.settings.fileMetadata[filepath] ?? null
|
||||
}
|
||||
|
||||
|
||||
async getFileMetadatas(){
|
||||
return this.settings.fileMetadata ?? null
|
||||
}
|
||||
|
||||
async newEmptyFileMetadata(filepath:string){
|
||||
const metadatas = this.settings.fileMetadata
|
||||
|
|
|
|||
|
|
@ -207,10 +207,10 @@ export class UltimateTodoistSyncSettingTab extends PluginSettingTab {
|
|||
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Scan all tasks in the vault')
|
||||
.setDesc('Scan tasks in all files in the vault and add `#todoist`. In general, you do not need to perform this operation.')
|
||||
.setName('Check Database')
|
||||
.setDesc('Check for possible issues: file renaming not updated, or missed tasks not synchronized.')
|
||||
.addButton(button => button
|
||||
.setButtonText('Scan')
|
||||
.setButtonText('Check Database')
|
||||
.onClick(async () => {
|
||||
// Add code here to handle exporting Todoist data
|
||||
if(!this.plugin.settings.apiInitialized){
|
||||
|
|
@ -218,7 +218,44 @@ export class UltimateTodoistSyncSettingTab extends PluginSettingTab {
|
|||
return
|
||||
}
|
||||
if (!await this.plugin.checkAndHandleSyncLock()) return;
|
||||
|
||||
|
||||
|
||||
try{
|
||||
//check renamed files
|
||||
const metadatas = await this.plugin.cacheOperation.getFileMetadatas()
|
||||
for (const key in metadatas) {
|
||||
const value = metadatas[key];
|
||||
const newDescription = this.plugin.taskParser.getObsidianUrlFromFilepath(key)
|
||||
value.todoistTasks.forEach(async(taskId) => {
|
||||
const taskObject = await this.plugin.cacheOperation.loadTaskFromCacheyID(taskId)
|
||||
const oldDescription = taskObject.description
|
||||
if(newDescription != oldDescription){
|
||||
console.log('Preparing to update description.')
|
||||
console.log(oldDescription)
|
||||
console.log(newDescription)
|
||||
try{
|
||||
await this.plugin.todoistSync.updateTaskDescription(key)
|
||||
}catch(error){
|
||||
console.error(`An error occurred while updating task discription: ${error.message}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//check empty file metadata
|
||||
|
||||
//check calendar format
|
||||
|
||||
|
||||
|
||||
//check omitted tasks
|
||||
if(!this.plugin.settings.enableFullVaultSync){
|
||||
return
|
||||
}
|
||||
const files = this.app.vault.getFiles()
|
||||
files.forEach(async (v, i) => {
|
||||
if(v.extension == "md"){
|
||||
|
|
@ -236,7 +273,7 @@ export class UltimateTodoistSyncSettingTab extends PluginSettingTab {
|
|||
this.plugin.syncLock = false
|
||||
new Notice(`All files have been scanned.`)
|
||||
}catch(error){
|
||||
new Notice(`An error occurred while scanning the vault.:${error}`)
|
||||
console.error(`An error occurred while scanning the vault.:${error}`)
|
||||
this.plugin.syncLock = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -850,13 +850,14 @@ export class TodoistSync {
|
|||
if(!metadata || !metadata.todoistTasks){
|
||||
return
|
||||
}
|
||||
const url = encodeURI(`obsidian://open?vault=${this.app.vault.getName()}&file=${filepath}`)
|
||||
const description =`[${filepath}](${url})`;
|
||||
const description = this.taskParser.getObsidianUrlFromFilepath(filepath)
|
||||
let updatedContent = {}
|
||||
updatedContent.description = description
|
||||
try {
|
||||
metadata.todoistTasks.forEach(async(taskId) => {
|
||||
await this.todoistRestAPI.UpdateTask(taskId,updatedContent)
|
||||
const updatedTask = await this.todoistRestAPI.UpdateTask(taskId,updatedContent)
|
||||
updatedTask.path = filepath
|
||||
this.cacheOperation.updateTaskToCacheByID(updatedTask);
|
||||
|
||||
});
|
||||
} catch(error) {
|
||||
|
|
|
|||
|
|
@ -528,4 +528,10 @@ export class TaskParser {
|
|||
addTodoistTag(str: string): string {
|
||||
return(str +` ${keywords.TODOIST_TAG}`);
|
||||
}
|
||||
|
||||
getObsidianUrlFromFilepath(filepath:string){
|
||||
const url = encodeURI(`obsidian://open?vault=${this.app.vault.getName()}&file=${filepath}`)
|
||||
const obsidianUrl =`[${filepath}](${url})`;
|
||||
return(obsidianUrl)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue