Skip to content

Commit

Permalink
1.0.19
Browse files Browse the repository at this point in the history
Temporarily disabled caching as accessing globalData, stored data for users seems to be broken in VSCode 1.45.1
  • Loading branch information
DeeJayTC committed May 19, 2020
1 parent 1318aa1 commit 4fc20d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Change Log
## 1.0.19
- To get the extension working again in Visual Studio Code 1.45.1 we temporarily disabled all caching in the extension.
You might see slower loading times, we keep to have this updated as soon as possible.
## 1.0.18
- Renamed to Teamwork, replaced icons
## 1.0.17
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"url": "https://twitter.com/Teamwork"
}
],
"version": "1.0.18",
"version": "1.0.19",
"engines": {
"vscode": "^1.33.0"
},
Expand Down
38 changes: 19 additions & 19 deletions src/teamworkProjectsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ export class TeamworkProjectsApi{

let result;
// Load from cache if duration less than 30 minutes
let cachedProjects : Project[] = context.globalState.get("twp.data.project",null);
let lastUpdated : Date = context.globalState.get("twp.data.projects.lastUpdated", new Date() );
if(cachedProjects && cachedProjects.length > 0 && lastUpdated && !force){
if(Utilities.DateCompare(lastUpdated,30)){
result = cachedProjects;
}
}
// let cachedProjects = JSON.parse(await context.globalState.get("twp.data.projectList",null));
// let lastUpdated = await context.globalState.get("twp.data.projectList.lastUpdated", new Date() );
// if(cachedProjects && cachedProjects.length > 0 && lastUpdated && !force){
// if(Utilities.DateCompare(lastUpdated,30)){
// result = cachedProjects;
// }
// }

if(!result){
const url = this.root + '/tasks/projects.json?type=canAddItem&pageSize=200';
Expand All @@ -111,9 +111,9 @@ export class TeamworkProjectsApi{
});
}

if(!isNullOrUndefined(result.data)){ await context.globalState.update("twp.data.project",result.data.projects);}
if(!isNullOrUndefined(result.data)){ await context.globalState.update("twp.data.projects.lastUpdated", new Date() );}
return result.data.projects;
// if(!isNullOrUndefined(result.data)){ await context.globalState.update("twp.data.projectList", JSON.stringify(result.data.projects));}
// if(!isNullOrUndefined(result.data)){ await context.globalState.update("twp.data.projectList.lastUpdated", new Date() );}
return result.data.projects;
}

public async GetPeopleInProject(context: vscode.ExtensionContext,force: boolean = false,id: string) : Promise<Person[]>{
Expand Down Expand Up @@ -144,13 +144,13 @@ export class TeamworkProjectsApi{
let response: TaskListResponse;

// Load from cache if duration less than 30 minutes
let cachedNodes : TaskListResponse = await context.globalState.get("twp.data." + id + ".tasklist",null);
let lastUpdated : Date = await context.globalState.get("twp.data.tasklists." + id + ".lastUpdated",new Date() );
if(cachedNodes !== null && cachedNodes["data"]["tasklists"].length > 0 && lastUpdated && !force){
if(Utilities.DateCompare(lastUpdated,30)){
return cachedNodes["data"]["tasklists"];
}
}
// let cachedNodes : TaskListResponse = await context.globalState.get("twp.data." + id + ".tasklist",null);
// let lastUpdated : Date = await context.globalState.get("twp.data.tasklists." + id + ".lastUpdated",new Date() );
// if(cachedNodes !== null && cachedNodes["data"]["tasklists"].length > 0 && lastUpdated && !force){
// if(Utilities.DateCompare(lastUpdated,30)){
// return cachedNodes["data"]["tasklists"];
// }
// }

const url = this.root + '/projects/api/v1/projects/' + id + '/tasklists.json?page=1&pageSize=100';

Expand All @@ -164,8 +164,8 @@ export class TeamworkProjectsApi{
});


await context.globalState.update("twp.data." + id + ".tasklist",response);
await context.globalState.update("twp.data.tasklists." + id + ".lastUpdated",Date.now());
// context.globalState.update("twp.data." + id + ".tasklist",response);
// context.globalState.update("twp.data.tasklists." + id + ".lastUpdated",Date.now());
return response["data"]["tasklists"];
}

Expand Down

0 comments on commit 4fc20d7

Please sign in to comment.