Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Further fixes to app restore bug

  • Loading branch information...
commit 0290e43bf6c18333f5a536e16171ad2710a993d3 1 parent 099304b
@matthew-dean authored
Showing with 38 additions and 22 deletions.
  1. +2 −2 application.xml
  2. +36 −20 js/scripts.js
View
4 application.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<application xmlns="http://ns.adobe.com/air/application/3.2">
- <versionNumber>1.5.2</versionNumber>
- <versionLabel>1.5.2</versionLabel>
+ <versionNumber>1.5.3</versionNumber>
+ <versionLabel>1.5.3</versionLabel>
<filename>Crunch</filename>
<programMenuFolder>Crunch</programMenuFolder>
View
56 js/scripts.js
@@ -12,6 +12,8 @@ appUpdater.initialize();
var scrollWidth = 100;
// Get stored state
+
+ // Paths are the default folders for open/save file dialogs
var Paths = {
project: air.File.documentsDirectory,
css: air.File.documentsDirectory,
@@ -35,6 +37,7 @@ appUpdater.initialize();
}
};
var storedPrefs = air.EncryptedLocalStore.getItem("state");
+
if(storedPrefs != null) {
var val = storedPrefs.readUTFBytes(storedPrefs.length);
$.extend(true, App, JSON.parse(val));
@@ -47,30 +50,41 @@ appUpdater.initialize();
air.EncryptedLocalStore.setItem("state", bytes);
copyPaths();
}
- function copyPaths() {
+ function checkValidPaths() {
+ var update = false;
var root = Paths.project;
-
- // Add check to make sure folder still exists, else reset App variables
- if(root.resolvePath(App.paths.project).isDirectory) {
- Paths.project = root.resolvePath(App.paths.project);
- if(root.resolvePath(App.paths.css).exists) {
- Paths.css = root.resolvePath(App.paths.css);
- }
- if(root.resolvePath(App.paths.less).exists) {
- Paths.less = root.resolvePath(App.paths.less);
- }
- } else {
+ if(!root.resolvePath(App.paths.project).isDirectory) {
App.paths.project = "";
+ update = true;
+ }
+ if(!root.resolvePath(App.paths.css).isDirectory) {
App.paths.css = "";
+ update = true;
+ }
+ if(!root.resolvePath(App.paths.less).isDirectory) {
App.paths.less = "";
-
- // If you want to keep existing files open then comment out this.
- // The files will still load properly but seems improper to have
- // the project closed but the files still open
- App.openFiles = {};
-
- // Not sure if this is really needed, but it seems appropriate
- updateAppState();
+ update = true;
+ }
+ $.each(App.openFiles, function(idx, val) {
+ if(!root.resolvePath(idx).exists) {
+ delete App.openFiles[idx];
+ update = true;
+ }
+ });
+
+ if(update) updateAppState();
+
+ }
+ function copyPaths() {
+ var root = Paths.project;
+ if(root.resolvePath(App.paths.project).isDirectory) {
+ Paths.project = root.resolvePath(App.paths.project);
+ }
+ if(root.resolvePath(App.paths.css).isDirectory) {
+ Paths.css = root.resolvePath(App.paths.css);
+ }
+ if(root.resolvePath(App.paths.less).isDirectory) {
+ Paths.less = root.resolvePath(App.paths.less);
}
}
@@ -815,6 +829,8 @@ appUpdater.initialize();
}
function initAppState() {
+ checkValidPaths();
+
if(App.paths.project != "")
openProject(Paths.project);
$.each(App.openFiles, function(idx, val) {
Please sign in to comment.
Something went wrong with that request. Please try again.