Skip to content

Commit

Permalink
Close codefire files when tab is closed (Fix #45)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse committed Nov 12, 2013
1 parent 34a3865 commit da29187
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion addons/editor/addon-built.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions addons/editor/views/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ define([
this.parent.on("tab:state", function(state) {
if (state) this.editor.focus();
}, this);
this.parent.on("tab:close", function() {
this.editor.sync.close();
}, this);
this.editor.focus();
},

Expand Down
11 changes: 9 additions & 2 deletions client/utils/filesync.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ define([
if (this.file != null) {
return this.file.codebox.socket("filesync");
} else {
throw new Error("need 'file' to creat sync socket");
throw new Error("need 'file' to create sync socket");
}
},

Expand Down Expand Up @@ -600,7 +600,14 @@ define([
sendSync: function() {
this.send("sync");
return true;
}
},

/*
* Close the connexion
*/
close: function() {
return this.send("close");
},
});

return FileSync;
Expand Down
4 changes: 2 additions & 2 deletions core/cb.addons/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ var Addon = function(logger, _rootPath) {
};

// Optimize the addon
this.optimizeClient = function() {
this.optimizeClient = function(force) {
var that = this;
var d = Q.defer();

if (!this.isClientside()
|| this.isOptmized()) {
|| (this.isOptmized() && !force)) {
return Q(this);
}

Expand Down
2 changes: 1 addition & 1 deletion core/cb.addons/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function setup(options, imports, register, app) {
if (options.dev) {
logger.log("Optmize defaults addons for production");
first = first.then(runAddonsOperation(function(addon) {
return addon.optimizeClient();
return addon.optimizeClient(true);
}));
}

Expand Down

0 comments on commit da29187

Please sign in to comment.