Skip to content

Commit

Permalink
Remove demo project from recents list
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Oct 12, 2020
1 parent 2467011 commit 1d6d7db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export default class SearchConfigFileSystemWriter implements SearchConfiguration
) {}

public async visitSearchConfiguration(config: SearchConfiguration): Promise<void> {
console.log("Writing config: ");
console.log(config);

let insertNew: boolean = true;

// Check if the search configuration already exists in the database.
Expand Down
2 changes: 1 addition & 1 deletion src/logic/filesystem/project/ProjectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class ProjectManager {
* @param projectLocation Path to root directory of project.
* @param addToRecents Should this project be added to the list of recent projects? Set to false for no.
*/
public async initializeProject(projectLocation: string, addToRecents: boolean): Promise<void> {
public async initializeProject(projectLocation: string, addToRecents: boolean = true): Promise<void> {
if (!projectLocation.endsWith("/")) {
projectLocation += "/";
}
Expand Down
10 changes: 8 additions & 2 deletions src/logic/filesystem/project/RecentProjectsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default class RecentProjectsManager {

const recentProjects: RecentProject[] = JSON.parse(projectData)
.map((obj: any) => new RecentProject(obj.name, obj.path, new Date(parseInt(obj.lastOpened))));
return recentProjects.filter(rp => fs.existsSync(rp.path));
const filteredProjects = recentProjects.filter(rp => fs.existsSync(rp.path));
this.writeRecentProjects(filteredProjects);
return filteredProjects;
} catch (err) {
throw new IOException(err);
}
Expand Down Expand Up @@ -55,7 +57,11 @@ export default class RecentProjectsManager {
recentProjects.push(new RecentProject(path.basename(projectPath), projectPath, new Date()));
}

const toWrite = recentProjects.sort((a, b) => b.lastOpened.getTime() - a.lastOpened.getTime())
this.writeRecentProjects(recentProjects);
}

private writeRecentProjects(projects: RecentProject[]): void {
const toWrite = projects.sort((a, b) => b.lastOpened.getTime() - a.lastOpened.getTime())
.slice(0, RecentProjectsManager.AMOUNT_OF_RECENTS)
.map(p => {
return {
Expand Down

0 comments on commit 1d6d7db

Please sign in to comment.