Skip to content

Commit da29187

Browse files
committed
Close codefire files when tab is closed (Fix #45)
1 parent 34a3865 commit da29187

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

addons/editor/addon-built.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

addons/editor/views/file.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ define([
4545
this.parent.on("tab:state", function(state) {
4646
if (state) this.editor.focus();
4747
}, this);
48+
this.parent.on("tab:close", function() {
49+
this.editor.sync.close();
50+
}, this);
4851
this.editor.focus();
4952
},
5053

client/utils/filesync.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ define([
293293
if (this.file != null) {
294294
return this.file.codebox.socket("filesync");
295295
} else {
296-
throw new Error("need 'file' to creat sync socket");
296+
throw new Error("need 'file' to create sync socket");
297297
}
298298
},
299299

@@ -600,7 +600,14 @@ define([
600600
sendSync: function() {
601601
this.send("sync");
602602
return true;
603-
}
603+
},
604+
605+
/*
606+
* Close the connexion
607+
*/
608+
close: function() {
609+
return this.send("close");
610+
},
604611
});
605612

606613
return FileSync;

core/cb.addons/addon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ var Addon = function(logger, _rootPath) {
5353
};
5454

5555
// Optimize the addon
56-
this.optimizeClient = function() {
56+
this.optimizeClient = function(force) {
5757
var that = this;
5858
var d = Q.defer();
5959

6060
if (!this.isClientside()
61-
|| this.isOptmized()) {
61+
|| (this.isOptmized() && !force)) {
6262
return Q(this);
6363
}
6464

core/cb.addons/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function setup(options, imports, register, app) {
7373
if (options.dev) {
7474
logger.log("Optmize defaults addons for production");
7575
first = first.then(runAddonsOperation(function(addon) {
76-
return addon.optimizeClient();
76+
return addon.optimizeClient(true);
7777
}));
7878
}
7979

0 commit comments

Comments
 (0)