repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
TickTickSync | github_2023 | thesamim | typescript | FileOperation.addTasksToFile | async addTasksToFile(tasks: ITask[]): Promise<boolean> {
if (!tasks) {
console.error("No tasks to add.")
return false;
}
//sort by project id and task id
tasks.sort((taskA, taskB) => (taskA.projectId.localeCompare(taskB.projectId) ||
taskA.id.localeCompare(taskB.id)));
/... | // sync updated task content to file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L173-L215 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.updateTaskInFile | async updateTaskInFile(task: ITask, toBeProcessed: string[]) {
const taskId = task.id
// Get the task file path
const currentTask: ITask = this.plugin.cacheOperation?.loadTaskFromCacheID(taskId)
this.plugin.dateMan?.addDateHolderToTask(task, currentTask);
if (currentTask) {
//Only check... | // update task content to file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L417-L490 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.hasChildren | private hasChildren(currentTask: ITask) {
if (currentTask.childIds) {
return currentTask.childIds?.length > 0;
} else {
return false;
}
} | //Yes, I know this belongs in taskParser, but I don't feel like messing with it right now. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L544-L551 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.deleteTaskFromSpecificFile | async deleteTaskFromSpecificFile(filePath: string, taskId: string, taskTitle: string, numItems: number, bConfirmDialog: boolean) {
// Get the file object and update the content
if (bConfirmDialog) {
const bConfirm = await this.confirmDeletion(taskTitle + "in File: " + filePath);
if (!bConfirm) {
new ... | // delete task from file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L554-L588 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.searchTickTickIdFromFilePath | async searchTickTickIdFromFilePath(filepath: string, searchTerm: string): Promise<string | null> {
const file = this.app.vault.getAbstractFileByPath(filepath)
const fileContent = await this.app.vault.read(file)
const fileLines = fileContent.split('\n');
let TickTickId: string | null = nu... | //search TickTick_id by content | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L608-L629 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.getAllFilesInTheVault | async getAllFilesInTheVault() {
const files = this.app.vault.getFiles()
return (files)
} | //get all files in the vault | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L632-L635 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.searchFilepathsByTaskidInVault | async searchFilepathsByTaskidInVault(taskId: string) {
// console.log(`preprare to search task ${taskId}`)
const files = await this.getAllFilesInTheVault()
//console.log(files)
const tasks = files.map(async (file) => {
if (!this.isMarkdownFile(file.path)) {
re... | //search filepath by taskid in vault | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L639-L657 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FileOperation.handleTickTickStructureMove | private async handleTickTickStructureMove(newTask: ITask, oldTask: ITask, toBeProcessed: string[]) {
//TODO: this is Kludgy as hell. In the fulness of time, I want to get rid of all this and have something
// like: if there are updates, and there's parent/child or project changes; build a linked list of the
// p... | /*
*Task has been moved in TickTick. Or it's parentage has changed.
* Need to delete it from the old file.
* Add it to the new project file.
* This magically handles parentage as well.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/fileOperation.ts#L694-L746 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSync.reloadLogging | reloadLogging() {
const options: LogOptions = {
minLevels: {
'': getSettings().logLevel,
ticktick: getSettings().logLevel,
},
};
logging.configure(options);
} | // Configure logging. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/main.ts#L144-L152 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSync.initializePlugin | async initializePlugin(): Promise<boolean> {
if (!getSettings().token) {
return false;
}
const isProjectsSaved = await this.saveProjectsToCache();
if (!isProjectsSaved) {// invalid token or offline?
this.tickTickRestAPI = undefined;
new Notice(`TickTickSync plugin initialization failed, please check u... | // return true of false | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/main.ts#L409-L435 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSync.checkModuleClass | checkModuleClass() {
if (!getSettings().token){
new Notice(`Please login from settings.`);
return false;
}
if (!this.service.initialized) {
this.service.initialize();
}
if (this.tickTickRestAPI === undefined) {
this.initializeModuleClass();
}
return true;
} | //return true | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/main.ts#L553-L566 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.convertTaskToLine | async convertTaskToLine(task: ITask, direction: string): Promise<string> {
let resultLine = '';
task.title = this.stripOBSUrl(task.title);
resultLine = `- [${task.status > 0 ? 'x' : ' '}] ${task.title}`;
//add Tags
if (task.tags) {
resultLine = this.addTagsToLine(resultLine, task.tags);
}
resultLi... | //convert a task object to a task line. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L166-L196 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getTaskContentFromLineText | getTaskContentFromLineText(lineText: string) {
let taskContent = lineText.replace(REGEX.TASK_CONTENT.REMOVE_INLINE_METADATA, '')
.replace(REGEX.TASK_CONTENT.REMOVE_TickTick_LINK, '')
.replace(REGEX.TASK_CONTENT.REMOVE_PRIORITY, '')
.replace(REGEX.TASK_CONTENT.REMOVE_TAGS, '')
.replace(REGEX.TASK_CONTENT.R... | //Remove Extraneous data from line. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L221-L233 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.convertLineToTask | async convertLineToTask(lineText: string, filepath: string, lineNumber?: number, fileContent?: string) {
let hasParent = false;
let parentId = null;
let parentTaskObject = null;
let taskItems = [];
const lines = fileContent.split('\n');
const lineTextTabIndentation = this.getTabIndentation(lineText);
let ... | //convert line text to a task object | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L256-L406 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getProjectNameFromLineText | getProjectNameFromLineText(text: string) {
const result = REGEX.PROJECT_NAME.exec(text);
return result ? result[1] : null;
} | //pretty sure this is surplus to requirements. Kill it next time. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L443-L446 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getAllTagsFromLineText | getAllTagsFromLineText(lineText: string) {
// console.log("Line Text: ", lineText);
// let tags = lineText.matchAll(REGEX.ALL_TAGS);
// if (tags) {
// // Remove '#' from each tag
// tags = tags.map(tag => tag.replace('#', ''));
// }
const tags = [...lineText.matchAll(REGEX.ALL_TAGS)];
let tagAr... | //get all tags from task text | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L468-L482 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isTaskCheckboxChecked | isTaskCheckboxChecked(lineText: string) {
return (REGEX.TASK_CHECKBOX_CHECKED.test(lineText));
} | //get checkbox status | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L485-L487 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isTitleChanged | isTitleChanged(lineTask: ITask, TickTickTask: ITask) {
//TODO: This is ugly, but I'm tired of chasing it. There's still a place where
// we're adding the OBSUrl to the tile when we don't need to. Everything else
// works, so just kludge it for now.
const lineTaskTitle = this.stripOBSUrl(lineTask.titl... | //task content compare | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L490-L500 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isTagsChanged | isTagsChanged(lineTask: ITask, TickTickTask: ITask) {
const lineTaskTags = lineTask.tags ? lineTask.tags : [];
const TickTickTaskTags = TickTickTask.tags ? TickTickTask.tags : [];
if (!lineTaskTags && !TickTickTaskTags) {
return false; //no tags.
} else if ((lineTaskTags && !TickTickTaskTags) || (!lineTaskTa... | //tag compare | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L503-L516 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isStatusChanged | isStatusChanged(lineTask: Object, TickTickTask: Object) {
//Whether status is modified?
const statusModified = (lineTask.status === TickTickTask.status);
//console.log(lineTask)
//console.log(TickTickTask)
return (!statusModified);
} | //task status compare | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L519-L525 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isProjectIdChanged | isProjectIdChanged(lineTask: ITask, TickTickTask: ITask) {
//project whether to modify
// if (!(lineTask.projectId === TickTickTask.projectId)) {
// console.log("line: ", lineTask.projectId, "saved; ", TickTickTask.projectId)
// }
return !(lineTask.projectId === TickTickTask.projectId);
} | //task project id compare | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L536-L542 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isIndentedTask | isIndentedTask(text: string) {
return (REGEX.TASK_INDENTATION.test(text));
} | //Determine whether the task is indented | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L545-L547 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getTabIndentation | getTabIndentation(lineText: string) {
const match = REGEX.TAB_INDENTATION.exec(lineText);
return match ? match[1].length : 0;
} | //console.log(getTabIndentation(" - [x] This is a task without tabs")); // 0 | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L550-L553 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getTaskPriority | getTaskPriority(lineText: string) {
let priority = '0';
const priorityMatch = lineText.match(REGEX.priorityRegex);
if (priorityMatch !== null) {
priority = this.parsePriority(priorityMatch[1]);
}
return priority;
} | // Task priority from 0 (none) to 4 (urgent). | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L565-L573 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.removeTaskIndentation | removeTaskIndentation(text) {
const regex = /^([ \t]*)?- \[(x| )\] /;
return text.replace(regex, '- [$2] ');
} | //remove task indentation | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L580-L583 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.isLineBlank | isLineBlank(lineText: string) {
return (REGEX.BLANK_LINE.test(lineText));
} | //Judge whether line is a blank line | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L586-L588 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.hasTickTickLink | hasTickTickLink(lineText: string) {
return (REGEX.TickTick_LINK.test(lineText));
} | //Check whether TickTick link is included | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L625-L627 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.createURL | createURL(newTaskId: string, projectId: string): string {
let url = '';
if (projectId) {
url = `https://${getSettings().baseURL}/webapp/#p/${projectId}/tasks/${newTaskId}`;
} else {
url = `https://${getSettings().baseURL}/webapp/#q/all/tasks/${newTaskId}`;
}
return url;
} | //ticktick specific url | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L630-L638 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getItemFromLine | private getItemFromLine(itemLine: string) {
const matches = REGEX.ITEM_LINE.exec(itemLine);
let item = {};
if (matches) {
const status = matches[1];
const text = matches[2];
const id = matches[3];
const itemStatus = ' ' ? 0 : 2;
item = {
id: id, title: text, status: itemStatus
};
}
r... | // But I don't want to make too many changes right now | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L709-L727 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskParser.getAllTags | getAllTags() {
// const tags = Object.keys(this.app.metadataCache.getTags())
// tags.forEach(tag => console.log(tag))
// // foo.forEach(tag => console.log(tag));
} | // with tag management. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/taskParser.ts#L756-L760 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Tick.login | async login(): Promise<{ inboxId: string; token: string } | null> {
try {
const url = `${this.loginUrl}/${signInEndPoint}`;
const body = {
username: this.username,
password: this.password
};
const response = await this.makeRequest('Login', url, 'POST', body);
console.log('Signed in Response: ',... | // USER ====================================================================== | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/index.ts#L126-L147 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Tick.getProjectGroups | async getProjectGroups(): Promise<IProjectGroup[]> {
try {
const url = `${this.apiUrl}/${allProjectGroupsEndPoint}`;
const response = await this.makeRequest('Get Project Groups', url, 'GET', undefined);
if (response) {
return response;
}
} catch (e) {
console.error('Get Project Groups failed: ', ... | // PROJECTS ================================================================== | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/index.ts#L206-L218 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Tick.getAllResources | async getAllResources(): Promise<IBatch | null> {
try {
let retry = 10; //TODO: really need to do this better. MB move to makeRequest and add delay?
while (retry > 0) {
const url = `${this.apiUrl}/${allTasksEndPoint}` + this._checkpoint;
const response = await this.makeRequest('Get All Resources', url, ... | // RESOURCES ================================================================= | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/index.ts#L252-L269 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Tick.getTaskDetails | async getTaskDetails(): Promise<ITask[]> {
try {
let retry = 10;
while (retry > 0) {
const url = `${this.apiUrl}/${allTasksEndPoint}` + this._checkpoint;
const response = await this.makeRequest('Get Task Details', url, 'GET', undefined);
if (response) {
const numReturns = response['syncTaskBean... | // TASKS ===================================================================== | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/index.ts#L272-L298 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Tick.getTasks | async getTasks(): Promise<ITask[]> {
try {
let retry = 3;
while (retry > 0) {
const url = `${this.apiUrl}/${allTasksEndPoint}` + this._checkpoint;
const response = await this.makeRequest('Get Tasks', url, 'GET', undefined);
if (response) {
console.log("Got: ", response['syncTaskBean'].update.le... | // enough to actually do the deletion. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/index.ts#L303-L326 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Tick.getPreviousCheckPoint | private getPreviousCheckPoint() {
let dtDate = new Date();
// console.log("Date: ", dtDate)
dtDate.setDate(dtDate.getDate() - 15);
// console.log("Date: ", dtDate)
this._checkpoint = dtDate.getTime();
console.warn('Check point has been changed.', this._checkpoint);
return this._checkpoint;
} | // is actually going to work. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/index.ts#L728-L736 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncAPI.getAllResources | async getAllResources() {
try {
let data = this.plugin.tickTickRestAPI?.getAllResources();
return data;
} catch (error) {
console.error(error);
throw new Error('Failed to fetch all resources due to network error');
}
} | //backup TickTick | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/old/TicktickSyncAPI.ts#L34-L43 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncAPI.getCompletedItemsActivity | async getCompletedItemsActivity() {
const data = this.plugin.tickTickRestAPI?.getAllCompletedItems();
return data;
} | //result {count:number,events:[]} | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/old/TicktickSyncAPI.ts | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncAPI.getUncompletedItemsActivity | async getUncompletedItemsActivity() : any[] {
const data = this.plugin.tickTickRestAPI?.getTasks();
return data;
} | //result {count:number,events:[]} | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/old/TicktickSyncAPI.ts#L103-L108 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncAPI.getNonObsidianCompletedItemsActivity | async getNonObsidianCompletedItemsActivity() {
const completedItemsActivity = await this.getCompletedItemsActivity()
const completedItemsActivityEvents = completedItemsActivity.events
//client does not contain obsidian's activity
const filteredArray = completedItemsActivi... | //todo: this is getting all tasks | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/old/TicktickSyncAPI.ts#L113-L119 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncAPI.getNonObsidianUncompletedItemsActivity | async getNonObsidianUncompletedItemsActivity() {
const uncompletedItemsActivity = await this.getUncompletedItemsActivity()
const uncompletedItemsActivityEvents = uncompletedItemsActivity.events
//client does not contain obsidian's activity
const filteredArray = uncomplete... | //get non-obsidian uncompleted event | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/old/TicktickSyncAPI.ts#L123-L129 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncAPI.getNonObsidianUpdatedItemsActivity | async getNonObsidianUpdatedItemsActivity() {
const updatedItemsActivity = await this.getUpdatedItemsActivity()
const updatedItemsActivityEvents = updatedItemsActivity.events
//client does not contain obsidian's activity
const filteredArray = updatedItemsActivityEvents.fil... | //get non-obsidian updated event | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/api/old/TicktickSyncAPI.ts#L169-L178 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | ConfirmFullSyncModal.onOpen | onOpen() {
const {titleEl, contentEl} = this;
titleEl.setText(this.title);
contentEl.createEl('p', {text: this.message});
new Setting(contentEl).addButton(cancelBtn => {
cancelBtn.setClass('ts_button');
cancelBtn.setButtonText(this.cancelLabel);
cancelBtn.onClick( () => {
this.result = false;
... | /**
* Called automatically by the Modal class when modal is opened.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/ConfirmFullSyncModal.ts#L24-L50 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | ConfirmFullSyncModal.onClose | onClose() {
this.titleEl.empty();
this.contentEl.empty();
super.onClose()
this.resolvePromise(this.result);
} | /**
* Called automatically by the Modal class when modal is closed.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/ConfirmFullSyncModal.ts#L55-L60 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FoundDuplicatesModal.onOpen | onOpen() {
const {titleEl, contentEl} = this;
titleEl.setText(this.title);
contentEl.createEl('p', {text: `${this.message}`});
// const unorderedList = contentEl.createEl('ul');
// this.projects.forEach((project) => {unorderedList.createEl('li', {text: `${project.id} \t ${project.name}`})})
const project... | /**
* Called automatically by the Modal class when modal is opened.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/FoundDuplicatesModal.ts#L30-L68 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | FoundDuplicatesModal.onClose | onClose() {
this.titleEl.empty();
this.contentEl.empty();
super.onClose()
this.resolvePromise(this.result);
} | /**
* Called automatically by the Modal class when modal is closed.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/FoundDuplicatesModal.ts#L73-L78 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | LatestChangesModal.onOpen | onOpen() {
const notableChangesURL = "https://github.com/thesamim/TickTickSync/wiki/Notable-Changes#"
let {titleEl, contentEl} = this;
titleEl.setText(this.title);
let changesText = contentEl.createEl('p');
changesText.innerHTML = `${this.intro}`;
changesText = contentEl.createEl('ol');
this.notableChang... | /**
* Called automatically by the Modal class when modal is opened.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/LatestChangesModal.ts#L26-L53 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | LatestChangesModal.onClose | onClose() {
this.titleEl.empty();
this.contentEl.empty();
super.onClose()
this.resolvePromise(this.result);
} | /**
* Called automatically by the Modal class when modal is closed.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/LatestChangesModal.ts#L58-L63 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskDeletionModal.onOpen | onOpen() {
const {titleEl, contentEl} = this;
titleEl.setText(this.title);
contentEl.createEl('p', {text: `${this.message}${this.reason}`});
const unorderedList = contentEl.createEl('ul');
this.taskTitles.forEach((task) => {unorderedList.createEl('li', {text: task})})
new Setting(contentEl).addButton(... | /**
* Called automatically by the Modal class when modal is opened.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/TaskDeletionModal.ts#L27-L58 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TaskDeletionModal.onClose | onClose() {
this.titleEl.empty();
this.contentEl.empty();
super.onClose()
this.resolvePromise(this.result);
} | /**
* Called automatically by the Modal class when modal is closed.
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/modals/TaskDeletionModal.ts#L63-L68 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | QueryRender.constructor | constructor(
container: HTMLElement,
plugin: TickTickSync,
component: Component,
props: T,
interceptEditButton: boolean,
) {
super(container);
this.plugin = plugin;
this.component = component;
this.props = props;
// this.root = createRoot(this.containerEl);
// this.store = create(() => {
// r... | // private readonly store: UseBoundStore<StoreApi<MarkdownEditButton>>; | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/query/injector.ts#L48-L82 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.GetActiveTasks | async GetActiveTasks() {
await this.initializeAPI();
try {
//TODO: ALL Tasks are fetched. Evaluate filtering.
// console.log("getting all tasks, look into filtering.")
const result = await this.api?.getTasks();
return result;
} catch (error) {
throw new Error(`Error get active tasks: ${error.messag... | // async GetActiveTasks(options:{ projectId?: string, section_id?: string, label?: string , filter?: string,lang?: string, ids?: Array<string>}) { | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L137-L147 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.UpdateTask | async UpdateTask(taskToUpdate: ITask) {
await this.initializeAPI();
try {
// @ts-ignore
let updatedTask: ITask | null | undefined = {};
const saveDateHolder = taskToUpdate.dateHolder;
const updateResult = await this.api?.updateTask(taskToUpdate);
// console.log("update result: ", updateResult.id2err... | //api does not have a function to update task project id | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L153-L177 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.OpenTask | async OpenTask(taskId: string, projectId: string) {
await this.initializeAPI();
try {
this.modifyTaskStatus(taskId, projectId, 0)
} catch (error) {
console.error('Error open a task:', error);
return
}
} | //open a task | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L200-L208 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.CloseTask | async CloseTask(taskId: string, projectId: string): Promise<boolean> {
await this.initializeAPI();
try {
let result = this.modifyTaskStatus(taskId, projectId, 2);
return result;
} catch (error) {
console.error('Error closing task:', error);
throw error; // Throw an error so that the caller can catch a... | // Close a task in TickTick API | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L211-L220 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.getTaskById | async getTaskById(taskId: string, projectId?: string): Promise<ITask|null|undefined> {
await this.initializeAPI();
if (!taskId) {
throw new Error('taskId is required');
}
try {
const task = await this.api?.getTask(taskId, projectId);
return task;
} catch (error) {
if (error.response && error.resp... | // get a task by Id | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L224-L241 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.getTaskDueById | async getTaskDueById(taskId: string) {
await this.initializeAPI();
if (!taskId) {
throw new Error('taskId is required');
}
try {
const task = await this.api?.getTask(taskId, null);
const due = task?.dueDate ?? null
return due;
} catch (error) {
throw new Error(`Error get Task Due By ID: ${error... | //get a task due by id | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L244-L256 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.GetAllProjects | async GetAllProjects(): Promise<IProject[]> {
await this.initializeAPI();
try {
return await this.api?.getProjects() ?? []
} catch (error) {
console.error('Error get all projects', error);
return []
}
} | //get all projects | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L260-L268 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.GetProjectGroups | async GetProjectGroups() {
await this.initializeAPI();
try {
const result = await this.api?.getProjectGroups()
if ((result?.length == 0) && (this.api?.lastError)) {
if (this.api?.lastError.statusCode != 200) {
let lastError = this.api?.lastError;
console.error("Error: ", lastError.operation, l... | //get project groups | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L271-L290 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.getUserResources | async getUserResources(): Promise<any[]> {
await this.initializeAPI();
try {
const result = await this.api?.getUserSettings();
return (result)
} catch (error) {
console.error('Error get user resources', error);
return []
}
} | //TODO: Added for completeness. Evaluate use later. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L293-L304 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.getAllCompletedItems | async getAllCompletedItems(): Promise<any[]> {
await this.initializeAPI();
try {
const result = await this.api?.getAllCompletedItems();
return (result)
} catch (error) {
console.error('Error get all completed items', error);
return []
}
} | //TODO: Added for completeness. Evaluate use later. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L307-L318 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.getAllResources | async getAllResources(): Promise<IBatch | null> {
await this.initializeAPI();
if (!this.api){
console.error("getAllResources No API.")
return null;
}
try {
const result = await this.api.getAllResources();
if (!result || (this.api.lastError && this.api.lastError.statusCode != 200)) {
throw new Er... | //TODO: Will need interpretation | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L321-L344 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickRestAPI.getAllTasks | async getAllTasks(): Promise<any[]> {
await this.initializeAPI();
try {
//This returns the SyncBean object, which has ALL the task details
const result = await this.api?.getTaskDetails();
if (!result || result.length === 0 && this.api?.lastError.statusCode!= 200) {
throw new Error("No Results.")
}
... | //TODO: Will need interpretation | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/TicktickRestAPI.ts#L347-L366 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.removeTaskItem | async removeTaskItem(fileMetaData: FileDetail, taskId: string, taskItemIds: string[]) {
if (!fileMetaData) {
return undefined;
}
const taskIndex = fileMetaData.TickTickTasks.findIndex(task => task.taskId === taskId);
if (taskIndex !== -1) {
const task = this.loadTaskFromCacheID(taskId)
if (!task || !ta... | //assumes file metadata has been looked up. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L69-L91 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.deleteFilepathFromMetadata | async deleteFilepathFromMetadata(filepath: string): Promise<FileMetadata> {
const fileMetaData: FileMetadata = getSettings().fileMetadata;
const newFileMetadata: FileMetadata = {};
for (const filename in fileMetaData) {
if (filename !== filepath) {
newFileMetadata[filename] = fileMetaData[filename];
}
... | //delete filepath from filemetadata | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L184-L199 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.checkForDuplicates | checkForDuplicates(fileMetadata: FileMetadata) {
if (!fileMetadata) {
return;
}
const taskIds: Record<string, string> = {};
const duplicates: Record<string, string[]> = {};
for (const file in fileMetadata) {
fileMetadata[file].TickTickTasks?.forEach(task => {
if (!taskIds.hasOwnProperty(task.taskI... | //Check for duplicates | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L203-L225 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.checkFileMetadata | async checkFileMetadata(): Promise<number> {
const metadatas = await this.getFileMetadatas()
// console.log("md: ", metadatas)
for (const filepath in metadatas) {
const value = metadatas[filepath];
// console.log("File: ", value)
const file = this.app.vault.getAbstractFileByPath(filepath)
if (!file &... | //Check errors in filemata where the filepath is incorrect. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L228-L276 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.loadTasksFromCache | async loadTasksFromCache() {
try {
const savedTasks = getTasks()
return savedTasks;
} catch (error) {
console.error(`Error loading tasks from Cache: ${error}`);
return [];
}
} | //Read all tasks from Cache | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L347-L355 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.saveTasksToCache | async saveTasksToCache(newTasks) {
try {
updateTasks(newTasks)
} catch (error) {
console.error(`Error saving tasks to Cache: ${error}`);
return false;
}
} | // Overwrite and save all tasks to cache | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L359-L367 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.appendTaskToCache | async appendTaskToCache(task: ITask, filePath: string) {
try {
if (task === null) {
return
}
const savedTasks = getTasks();
task.title = this.plugin.taskParser.stripOBSUrl(task.title);
savedTasks.push(task);
updateTasks(savedTasks);
await this.addTaskToMetadata(filePath, task)
await this.... | //Append to Cache file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L371-L387 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.loadTaskFromCacheID | loadTaskFromCacheID(taskId?: string): ITask | undefined {
if (!taskId) return undefined;
try {
const savedTasks = getTasks()
return savedTasks.find((task: ITask) => task.id === taskId);
} catch (error) {
log('error', `Error finding task from Cache:`, error);
}
return undefined;
} | //Read the task with the specified id | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L390-L399 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.getTaskTitles | async getTaskTitles(taskIds: string []): Promise<string []> {
const savedTasks = getTasks();
let titles = savedTasks.filter(task => taskIds.includes(task.id)).map(task => task.title);
titles = titles.map((task: string) => {
return this.plugin.taskParser.stripOBSUrl(task);
});
return titles;
} | //get Task titles | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L402-L412 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.updateTaskToCache | async updateTaskToCache(task: ITask, movedPath: string | null = null) {
try {
let filePath: string | null = ""
if (!movedPath) {
filePath = await this.getFilepathForTask(task.id)
if (!filePath) {
filePath = await this.getFilepathForProjectId(task.projectId);
}
if (!filePath) {
//we're ... | //Overwrite the task with the specified id in update | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L416-L442 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.reopenTaskToCacheByID | async reopenTaskToCacheByID(taskId: string): Promise<string> {
let projectId = null;
try {
const savedTasks = getTasks()
const taskIndex = savedTasks.findIndex((task) => task.id === taskId);
if (taskIndex > -1) {
savedTasks[taskIndex].status = 0;
projectId = savedTasks[taskIndex].projectId;
}
... | //open a task status | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L501-L520 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.closeTaskToCacheByID | async closeTaskToCacheByID(taskId: string): Promise<string> {
let projectId = null;
try {
const savedTasks = getTasks();
const taskIndex = savedTasks.findIndex((task) => task.id === taskId);
if (taskIndex > -1) {
savedTasks[taskIndex].status = 2;
projectId = savedTasks[taskIndex].projectId;
}
... | //close a task status | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L524-L542 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.deleteTaskFromCache | async deleteTaskFromCache(taskId: string) {
try {
const savedTasks = getTasks()
const newSavedTasks = savedTasks.filter((t) => t.id !== taskId);
updateTasks(newSavedTasks)
//Also clean up meta data
await this.deleteTaskIdFromMetadataByTaskId(taskId);
} catch (error) {
console.error(`Error deleting... | //Delete task by ID | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L546-L556 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.deleteTaskFromCacheByIDs | async deleteTaskFromCacheByIDs(deletedTaskIds: string[]) {
try {
const savedTasks = getTasks()
const newSavedTasks = savedTasks.filter((t) => !deletedTaskIds.includes(t.id))
updateTasks(newSavedTasks)
//clean up file meta data
deletedTaskIds.forEach(async taskId => {
await this.deleteTaskIdFromMeta... | //Delete task through ID array | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L560-L574 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.getProjectIdByNameFromCache | async getProjectIdByNameFromCache(projectName: string) {
try {
const savedProjects = getProjects()
const targetProject = savedProjects.find((obj: IProject) => obj.name.toLowerCase() === projectName.toLowerCase());
const projectId = targetProject ? targetProject.id : null;
return (projectId)
} catch (err... | //Find project id by name | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L578-L588 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.saveProjectsToCache | async saveProjectsToCache(projects: IProject[]) {
try {
const inboxProject = {
id: getSettings().inboxID,
name: getSettings().inboxName
} as IProject;
projects.push(inboxProject);
//TODO: this really need?
const duplicates = projects.reduce((acc, obj, index, arr) => {
const duplicateIndex ... | //save projects data to json file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L609-L673 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | CacheOperation.findTaskInMetada | findTaskInMetada(taskId: string, filePath: string) {
const fileMetadata = getSettings().fileMetadata;
for (const file in fileMetadata) {
console.log("in file: :", file)
if (file == filePath) {
console.log("breaking")
continue;
}
const tasks = fileMetadata[file].TickTickTasks;
for (const task ... | // TODO: why did I think I needed this? | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/cacheOperation.ts#L706-L724 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickService.login | async login(baseUrl: string, username: string, password: string):
Promise<{ inboxId: string; token: string } | null> {
try {
const api = new Tick({
username: username,
password: password,
baseUrl: baseUrl,
token: "",
checkPoint: 0
});
//try login
return await api.login();
} catch (... | //MB can be static | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/index.ts#L62-L78 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickService.checkDataBase | async checkDataBase() {
// Add code here to handle exporting TickTick data
//reinstall plugin
const vault = this.plugin.app.vault;
const fileNum = await this.plugin.cacheOperation?.checkFileMetadata()
log('debug', `checking metadata for ${fileNum} files`);
if (!fileNum || fileNum < 1){ //nothing? really?
... | //TODO: refactor | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/index.ts#L181-L307 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickService.syncTickTickToObsidian | private async syncTickTickToObsidian(): Promise<boolean> {
return this.tickTickSync.syncTickTickToObsidian();
} | /*
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/index.ts#L313-L315 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.updateTaskLine | private async updateTaskLine(newTask: ITask, lineTxt: string, editor: Editor | null, cursor: EditorPosition | null, fileContent: string, line: number| null, filePath: string) {
let newTaskCopy = {...newTask}
newTaskCopy.items = []
// console.log("TRACETHIS: dateStruct in: ", newTask.dateHolder);
let text = awai... | //get the TickTick data into the task line. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L220-L248 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.closeTask | async closeTask(taskId: string): Promise<void> {
try {
let projectId = await this.plugin.cacheOperation?.closeTaskToCacheByID(taskId);
await this.plugin.tickTickRestAPI?.CloseTask(taskId, projectId);
await this.plugin.fileOperation?.completeTaskInTheFile(taskId)
this.plugin.saveSettings()
new Notice(`... | // Close a task by calling API and updating JSON file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L850-L862 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.reopenTask | async reopenTask(taskId: string): Promise<void> {
try {
let projectId = await this.plugin.cacheOperation?.reopenTaskToCacheByID(taskId)
await this.plugin.tickTickRestAPI?.OpenTask(taskId, projectId)
await this.plugin.fileOperation.uncompleteTaskInTheFile(taskId)
this.plugin.saveSettings()
new Notice(`... | //open task | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L865-L877 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.deleteTasksByIds | async deleteTasksByIds(taskIds: string[]): Promise<string[]> {
const deletedTaskIds = [];
const bConfirm = await this.confirmDeletion(taskIds, "The tasks were removed from the file");
if (!bConfirm) {
new Notice("Tasks will not be deleted. Please rectify the issue before the next sync.", 0)
return [];
}
... | /**
* Delete the task with the specified ID from the task list and update the JSON file
* @param taskIds array of task IDs to be deleted
* @returns Returns the successfully deleted task ID array
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L885-L928 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.syncCompletedTaskStatusToObsidian | async syncCompletedTaskStatusToObsidian(unSynchronizedEvents) {
// Get unsynchronized events
//console.log(unSynchronizedEvents)
try {
// Handle unsynchronized events and wait for all processing to complete
const processedEvents = []
for (const e of unSynchronizedEvents) { //If you want to modify the co... | // Synchronize completed task status to Obsidian file | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L933-L958 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.syncUncompletedTaskStatusToObsidian | async syncUncompletedTaskStatusToObsidian(unSynchronizedEvents) {
//console.log(unSynchronizedEvents)
try {
// Handle unsynchronized events and wait for all processing to complete
const processedEvents = []
for (const e of unSynchronizedEvents) { //If you want to modify the code so that uncompleteTaskIn... | //TODO: Determine deletion candidate | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L963-L988 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.syncTickTickToObsidian | async syncTickTickToObsidian(): Promise<boolean> {
//Tasks in Obsidian, not in TickTick: upload
//Tasks in TickTick, not in Obsidian: Download
//Tasks in both: check for updates.
try {
const res = await this.plugin.saveProjectsToCache();
if (!res) {
console.error("probable network connection error.")
... | /*
* Synchronizes the tasks between TickTick and Obsidian.
* //TODO: split this function into smaller functions
* return:
* true if the function is in the process of modifying files
* false otherwise
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L997-L1257 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.backupTickTickAllResources | async backupTickTickAllResources() {
try {
// console.log("backing up.")
// if (this.plugin.tickTickSyncAPI) {
// console.log("It's defined", this.plugin.tickTickSyncAPI)
// }
const bkupData = await this.plugin.tickTickRestAPI?.exportData()
if (bkupData) {
const now: Date = new Date();
cons... | ///End of Test | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L1278-L1301 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | SyncMan.updateTaskContent | async updateTaskContent(filepath: string) {
const metadata = await this.plugin.cacheOperation?.getFileMetadata(filepath)
if (!metadata || !metadata.TickTickTasks) {
return
}
const taskURL = this.plugin.taskParser?.getObsidianUrlFromFilepath(filepath)
try {
for (const taskDetail of metadata.TickTickTasks... | //After renaming the file, check all tasks in the file and update all links. | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/services/syncModule.ts#L1305-L1332 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncSettingTab.addAuthBlock | private addAuthBlock(containerEl: HTMLElement) {
containerEl.createEl('hr');
containerEl.createEl('h1', {text: 'Access Control'});
let userLogin: string;
let userPassword: string;
new Setting(containerEl)
.setName("TickTick/Dida")
.setDesc("Select home server")
.setHeading()
.addDropdown(compone... | /*
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/ui/settings/index.ts#L38-L95 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncSettingTab.saveSettings | private async saveSettings(update?: boolean): Promise<void> {
await this.plugin.saveSettings();
if (update) {
await this.display();
}
} | /*
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/ui/settings/index.ts#L410-L415 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | TickTickSyncSettingTab.loginHandler | private async loginHandler(baseUrl?: string, username?: string, password?: string) {
if (!baseUrl || !username || !password ||
baseUrl.length < 1 || username.length < 1 || password.length < 1) {
new Notice("Please fill in both Username and Password")
return;
}
const info = await this.plugin.service.logi... | /*
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/ui/settings/index.ts#L421-L447 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | unlock | let unlock = () => {}; | // Create the lock, which is simply a promise. Obtain the promise's resolve method which | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/locks.ts#L49-L49 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | LogManager.configure | public configure(options: LogOptions): LogManager {
this.options = Object.assign({}, this.options, options);
return this;
} | /**
* Set the minimum log levels for the module name or global.
*
* @param {LogOptions} options
* @return {*} {LogManager}
* @memberof LogManager
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L87-L90 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | LogManager.getLogger | public getLogger(module: string): Logger {
let minLevel = 'none';
let match = '';
for (const key in this.options.minLevels) {
if (module.startsWith(key) && key.length >= match.length) {
minLevel = this.options.minLevels[key];
match = key;
... | /**
* Returns a logger instance for the given module name.
*
* @param {string} module
* @return {*} {Logger}
* @memberof LogManager
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L99-L110 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | LogManager.onLogEntry | public onLogEntry(listener: (logEntry: LogEntry) => void): LogManager {
this.on('log', listener);
return this;
} | /**
*
*
* @param {(logEntry: LogEntry) => void} listener
* @return {*} {LogManager}
* @memberof LogManager
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L119-L122 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | LogManager.registerConsoleLogger | public registerConsoleLogger(): LogManager {
if (this.consoleLoggerRegistered) return this;
this.onLogEntry((logEntry) => {
let msg = `[${window.moment().format('YYYY-MM-DD-HH:mm:ss.SSS')}][${logEntry.level}][${logEntry.module}]`;
if (logEntry.traceId) {
msg += ... | /**
* Registers a logger that write to the console.
*
* @return {*} {LogManager}
* @memberof LogManager
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L132-L170 | a094e6542e42ecf8a6a48e537ac94928648a282a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.