demonstration view fix WIP

This commit is contained in:
Peter Cottle 2013-07-07 23:24:11 -07:00
parent e6942446df
commit d2e418641f
5 changed files with 111 additions and 39 deletions

View file

@ -22529,21 +22529,20 @@ var util = require('../util');
function getMockFactory() { function getMockFactory() {
var mockFactory = {}; var mockFactory = {};
var mockReturn = function() { var mockReturn = function() {
return Q.defer().promise; var d = Q.defer();
// fall through!
d.resolve();
return d.promise;
}; };
for (var key in AnimationFactory) { for (var key in AnimationFactory) {
mockFactory[key] = mockReturn; mockFactory[key] = mockReturn;
} }
// special method that does stuff
mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
aQueue.thenFinish(Q.defer().promise);
};
mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) { mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
var d = Q.defer(); aQueue.finish();
d.resolve(); };
// return a resolved promise here mockFactory.refreshTree = function(aQueue, gitVisuals) {
return d.promise; aQueue.finish();
}; };
mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) { mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) {
@ -22577,16 +22576,43 @@ HeadlessGit.prototype.init = function() {
this.gitEngine.init(); this.gitEngine.init();
}; };
HeadlessGit.prototype.sendCommand = function(value) { // horrible hack so we can just quickly get a tree string for async git
// operations, aka for git demonstration views
var getTreeQuick = function(commandStr, getTreePromise) {
var deferred = Q.defer();
var headless = new HeadlessGit();
headless.sendCommand(commandStr, deferred);
deferred.promise.then(function() {
getTreePromise.resolve(headless.gitEngine.exportTree());
});
};
HeadlessGit.prototype.sendCommand = function(value, entireCommandPromise) {
var deferred = Q.defer();
var chain = deferred.promise;
var startTime = new Date().getTime();
util.splitTextCommand(value, function(commandStr) { util.splitTextCommand(value, function(commandStr) {
var commandObj = new Command({ var commandObj = new Command({
rawStr: commandStr rawStr: commandStr
}); });
this.gitEngine.dispatch(commandObj, Q.defer()); var thisDeferred = Q.defer();
this.gitEngine.dispatch(commandObj, thisDeferred);
chain = chain.then(thisDeferred.promise);
}, this); }, this);
chain.then(function() {
var nowTime = new Date().getTime();
// .log('done with command "' + value + '", took ', nowTime - startTime);
if (entireCommandPromise) {
entireCommandPromise.resolve();
}
});
deferred.resolve();
}; };
exports.HeadlessGit = HeadlessGit; exports.HeadlessGit = HeadlessGit;
exports.getTreeQuick = getTreeQuick;
}); });
@ -23568,21 +23594,20 @@ var util = require('../util');
function getMockFactory() { function getMockFactory() {
var mockFactory = {}; var mockFactory = {};
var mockReturn = function() { var mockReturn = function() {
return Q.defer().promise; var d = Q.defer();
// fall through!
d.resolve();
return d.promise;
}; };
for (var key in AnimationFactory) { for (var key in AnimationFactory) {
mockFactory[key] = mockReturn; mockFactory[key] = mockReturn;
} }
// special method that does stuff
mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
aQueue.thenFinish(Q.defer().promise);
};
mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) { mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
var d = Q.defer(); aQueue.finish();
d.resolve(); };
// return a resolved promise here mockFactory.refreshTree = function(aQueue, gitVisuals) {
return d.promise; aQueue.finish();
}; };
mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) { mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) {
@ -23616,16 +23641,43 @@ HeadlessGit.prototype.init = function() {
this.gitEngine.init(); this.gitEngine.init();
}; };
HeadlessGit.prototype.sendCommand = function(value) { // horrible hack so we can just quickly get a tree string for async git
// operations, aka for git demonstration views
var getTreeQuick = function(commandStr, getTreePromise) {
var deferred = Q.defer();
var headless = new HeadlessGit();
headless.sendCommand(commandStr, deferred);
deferred.promise.then(function() {
getTreePromise.resolve(headless.gitEngine.exportTree());
});
};
HeadlessGit.prototype.sendCommand = function(value, entireCommandPromise) {
var deferred = Q.defer();
var chain = deferred.promise;
var startTime = new Date().getTime();
util.splitTextCommand(value, function(commandStr) { util.splitTextCommand(value, function(commandStr) {
var commandObj = new Command({ var commandObj = new Command({
rawStr: commandStr rawStr: commandStr
}); });
this.gitEngine.dispatch(commandObj, Q.defer()); var thisDeferred = Q.defer();
this.gitEngine.dispatch(commandObj, thisDeferred);
chain = chain.then(thisDeferred.promise);
}, this); }, this);
chain.then(function() {
var nowTime = new Date().getTime();
// .log('done with command "' + value + '", took ', nowTime - startTime);
if (entireCommandPromise) {
entireCommandPromise.resolve();
}
});
deferred.resolve();
}; };
exports.HeadlessGit = HeadlessGit; exports.HeadlessGit = HeadlessGit;
exports.getTreeQuick = getTreeQuick;
}); });

File diff suppressed because one or more lines are too long

1
build/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -434,7 +434,7 @@
For a much easier time perusing the source, see the individual files at: For a much easier time perusing the source, see the individual files at:
https://github.com/pcottle/learnGitBranching https://github.com/pcottle/learnGitBranching
--> -->
<script src="build/bundle.min.6a95366c.js"></script> <script src="build/bundle.js"></script>
<!-- The advantage of github pages: super-easy, simple, slick static hostic. <!-- The advantage of github pages: super-easy, simple, slick static hostic.
The downside? No raw logs to parse for analytics, so I have to include The downside? No raw logs to parse for analytics, so I have to include

View file

@ -19,21 +19,20 @@ var util = require('../util');
function getMockFactory() { function getMockFactory() {
var mockFactory = {}; var mockFactory = {};
var mockReturn = function() { var mockReturn = function() {
return Q.defer().promise; var d = Q.defer();
// fall through!
d.resolve();
return d.promise;
}; };
for (var key in AnimationFactory) { for (var key in AnimationFactory) {
mockFactory[key] = mockReturn; mockFactory[key] = mockReturn;
} }
// special method that does stuff
mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
aQueue.thenFinish(Q.defer().promise);
};
mockFactory.playCommitBirthPromiseAnimation = function(commit, visuals) { mockFactory.playRefreshAnimationAndFinish = function(gitVisuals, aQueue) {
var d = Q.defer(); aQueue.finish();
d.resolve(); };
// return a resolved promise here mockFactory.refreshTree = function(aQueue, gitVisuals) {
return d.promise; aQueue.finish();
}; };
mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) { mockFactory.highlightEachWithPromise = function(chain, toRebase, destBranch) {
@ -67,18 +66,41 @@ HeadlessGit.prototype.init = function() {
this.gitEngine.init(); this.gitEngine.init();
}; };
HeadlessGit.prototype.sendCommand = function(value, cb) { // horrible hack so we can just quickly get a tree string for async git
// operations, aka for git demonstration views
var getTreeQuick = function(commandStr, getTreePromise) {
var deferred = Q.defer();
var headless = new HeadlessGit();
headless.sendCommand(commandStr, deferred);
deferred.promise.then(function() {
getTreePromise.resolve(headless.gitEngine.exportTree());
});
};
HeadlessGit.prototype.sendCommand = function(value, entireCommandPromise) {
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
var startTime = new Date().getTime();
util.splitTextCommand(value, function(commandStr) { util.splitTextCommand(value, function(commandStr) {
var commandObj = new Command({ var commandObj = new Command({
rawStr: commandStr rawStr: commandStr
}); });
var thisDeferred = Q.defer(); var thisDeferred = Q.defer();
this.gitEngine.dispatch(commandObj, thisDeferred); this.gitEngine.dispatch(commandObj, thisDeferred);
chain = chain.then(thisPromise); chain = chain.then(thisDeferred.promise);
}, this); }, this);
chain.then(function() {
var nowTime = new Date().getTime();
// .log('done with command "' + value + '", took ', nowTime - startTime);
if (entireCommandPromise) {
entireCommandPromise.resolve();
}
});
deferred.resolve();
}; };
exports.HeadlessGit = HeadlessGit; exports.HeadlessGit = HeadlessGit;
exports.getTreeQuick = getTreeQuick;