Skip to content

Commit 7a7bb0e

Browse files
committed
Merge pull request #243 from parallaxinc/user-config-fixes
update user config module and make sure saving is waited on
2 parents e66d5f1 + d2b8717 commit 7a7bb0e

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

client.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ function onRender(err){
7777

7878
// Finish Loading Plugin
7979
// TODO: encapsulate into a startup handler?
80-
const cwd = userConfig.get('cwd') || defaultProject;
81-
const lastFile = userConfig.get('last-file');
80+
const config = userConfig.getState();
81+
const cwd = config.cwd || defaultProject;
82+
const lastFile = config['last-file'];
8283
console.log(cwd, lastFile);
8384
changeProject(cwd)
8485
.then(() => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": "test"
88
},
99
"dependencies": {
10-
"@phated/redux-create-store": "^0.1.1",
10+
"@phated/redux-create-store": "^0.3.0",
1111
"bs2-serial": "^0.11.0",
1212
"codemirror": "^4.13.0",
1313
"frylord": "^0.7.1",
@@ -21,7 +21,7 @@
2121
"react-mfb-iceddev": "^0.1.0",
2222
"react-style": "^0.4.0",
2323
"skrim": "0.0.3",
24-
"snacks": "^0.2.0",
24+
"snacks": "^0.3.0",
2525
"sovereign": "^0.3.0",
2626
"when": "^3.7.2"
2727
},

src/plugins/handlers.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ function handlers(app, opts, done){
7474

7575
const builtName = `untitled${untitledLast + 1}`;
7676

77-
workspace.newFile(builtName, '');
78-
79-
userConfig.set('last-file', builtName);
80-
81-
documents.create(path.join(cwd, builtName), '');
82-
documents.focus();
77+
workspace.newFile(builtName, '')
78+
.then(() => userConfig.set('last-file', builtName))
79+
.then(function(){
80+
documents.create(path.join(cwd, builtName), '');
81+
documents.focus();
82+
});
8383
}
8484

8585
function saveFile(){
@@ -165,10 +165,9 @@ function handlers(app, opts, done){
165165

166166
// TODO: handle error
167167
workspace.changeFile(filename)
168+
.then(() => userConfig.set('last-file', filename))
168169
.then(() => {
169170
const { content } = workspace.getState();
170-
userConfig.set('last-file', filename);
171-
172171
documents.create(path.join(cwd, filename), content);
173172
documents.focus();
174173
});
@@ -183,10 +182,8 @@ function handlers(app, opts, done){
183182
const dirpath = path.join('/', projectName);
184183

185184
return workspace.changeDirectory(dirpath)
186-
.then(() => {
187-
userConfig.set('cwd', dirpath);
188-
userConfig.set('last-file', '');
189-
});
185+
.then(() => userConfig.set('cwd', dirpath))
186+
.then(() => userConfig.unset('last-file'));
190187
}
191188

192189
function deleteProject(projectName){

0 commit comments

Comments
 (0)