Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(toast): replace cancel with hide on hideDelay #3558

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function MdToastDirective() {
/**
* @ngdoc method
* @name $mdToast#showSimple
*
*
* @description
* Convenience method which builds and shows a simple toast.
*
Expand Down Expand Up @@ -83,7 +83,7 @@ function MdToastDirective() {
/**
* @ngdoc method
* @name $mdToast#updateContent
*
*
* @description
* Updates the content of an existing toast. Useful for updating things like counts, etc.
*
Expand Down
6 changes: 3 additions & 3 deletions src/components/toast/toast.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('$mdToast service', function() {
theme: 'some-theme',
capsule: true
})
).catch(function() {
rejected = true;
).then(function() {
resolved = true;
});
$rootScope.$digest();
expect(parent.find('span').text()).toBe('Do something');
Expand All @@ -35,7 +35,7 @@ describe('$mdToast service', function() {
$animate.triggerCallbacks();
$timeout.flush();
$animate.triggerCallbacks();
expect(rejected).toBe(true);
expect(resolved).toBe(true);
}));

it('supports dynamicly updating the content', inject(function($mdToast, $rootScope, $rootElement) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/services/interimElement/interimElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function InterimElementProvider() {
show: function() {
var compilePromise;
if (options.skipCompile) {
compilePromise = $q(function(resolve) {
compilePromise = $q(function(resolve) {
resolve({
locals: {},
link: function() { return options.element; }
Expand Down Expand Up @@ -386,7 +386,7 @@ function InterimElementProvider() {

function startHideTimeout() {
if (options.hideDelay) {
hideTimeout = $timeout(service.cancel, options.hideDelay) ;
hideTimeout = $timeout(service.hide, options.hideDelay);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rschmukler - this changes seems reasonable: hide === close.
As the author of interimElement.js, can you describe the difference [wrt interimElement] between cancel() and hide()).


Btw, a promise wrapper is also needed in hide() change is also needed:

function hide(response) {
  var interimElement = stack.shift();
  return $q.when(interimElement && interimElement.remove().then(function() {
    interimElement.deferred.resolve(response);
  }));
}

}
}
},
Expand Down
7 changes: 3 additions & 4 deletions src/core/services/interimElement/interimElement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('$$interimElement service', function() {
expect(interimTest.show).toBeOfType('function');

var builder = interimTest.build();
[ 'controller', 'controllerAs', 'onRemove', 'onShow', 'resolve',
[ 'controller', 'controllerAs', 'onRemove', 'onShow', 'resolve',
'template', 'templateUrl', 'themable', 'transformTemplate', 'parent'
].forEach(function(methodName) {
expect(builder[methodName]).toBeOfType('function');
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('$$interimElement service', function() {
flush();
expect($compilerSpy.calls.mostRecent().args[0].key).toBe('newValue');
expect($compilerSpy.calls.mostRecent().args[0].key2).toBe('newValue2');

$compilerSpy.calls.reset();
flush();
flush();
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('$$interimElement service', function() {
}));

it('calls hide after hideDelay', inject(function($animate, $timeout, $rootScope) {
var hideSpy = spyOn(Service, 'cancel').and.callThrough();
var hideSpy = spyOn(Service, 'hide').and.callThrough();
Service.show({hideDelay: 1000});
expect(hideSpy).toHaveBeenCalled();
}));
Expand Down Expand Up @@ -540,4 +540,3 @@ describe('$$interimElement service', function() {
}

});