Browse Source

Fix handling of recent projects not registering/saving immediately upon open

Josh Engebretson 10 years ago
parent
commit
071a34c6c8
1 changed files with 6 additions and 9 deletions
  1. 6 9
      Script/AtomicEditor/editor/Preferences.ts

+ 6 - 9
Script/AtomicEditor/editor/Preferences.ts

@@ -27,28 +27,25 @@ class Preferences {
             this._prefs.recentProjects.splice(index, 1);
             this._prefs.recentProjects.splice(index, 1);
         }
         }
         this._prefs.recentProjects.unshift(path);
         this._prefs.recentProjects.unshift(path);
-        this.updateRecentProjects();
+        this.updateRecentProjects(true);
     }
     }
 
 
-    unRegisterRecentProject(path: string): void {
-        var index = this._prefs.recentProjects.indexOf(path);
-        if (index >= 0) {
-            this._prefs.recentProjects.splice(index, 1);
-        }
-        this.updateRecentProjects();
-    }
+    updateRecentProjects(write:boolean = false): void {
 
 
-    updateRecentProjects(): void {
         for (var i in this._prefs.recentProjects) {
         for (var i in this._prefs.recentProjects) {
             var path = this._prefs.recentProjects[i];
             var path = this._prefs.recentProjects[i];
             if (!this.fileSystem.exists(path)) {
             if (!this.fileSystem.exists(path)) {
                 this._prefs.recentProjects.splice(i, 1);
                 this._prefs.recentProjects.splice(i, 1);
+                write = true;
             }
             }
         }
         }
+        if (write)
+          this.write();
     }
     }
 
 
     deleteRecentProjects(): void {
     deleteRecentProjects(): void {
         this._prefs.recentProjects.length = 0;
         this._prefs.recentProjects.length = 0;
+        this.write();
     }
     }
 
 
     getPreferencesFullPath(): string {
     getPreferencesFullPath(): string {