Skip to content

Commit 34fd61a

Browse files
committed
Fix retry bug
Conflicts: build/js/messenger.min.js index.html
1 parent 7853d32 commit 34fd61a

File tree

8 files changed

+427
-25
lines changed

8 files changed

+427
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.3.5
2+
-----
3+
4+
- Fix bug in how retry works
5+
16
1.3.4
27
-----
38

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "messenger",
33
"repo": "HubSpot/messenger",
44
"description": "Client-side growl-like notifications with actions and auto-retry.",
5-
"version": "1.3.4",
5+
"version": "1.3.5",
66
"homepage": "http://github.hubspot.com/messenger",
77
"license": "MIT",
88
"keywords": [

build/js/messenger.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! messenger 1.3.4 */
1+
/*! messenger 1.3.5 */
22
/*
33
* This file begins the output concatenated into messenger.js
44
*
@@ -993,23 +993,22 @@ window.Messenger.Events = (function() {
993993
}
994994
handlers = {};
995995
_.each(['error', 'success'], function(type) {
996+
var originalHandler;
997+
originalHandler = opts[type];
996998
return handlers[type] = function() {
997-
var data, defaultOpts, handlerResp, msgOpts, reason, resp, responseOpts, xhr, _ref10, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
999+
var data, defaultOpts, handlerResp, msgOpts, reason, resp, responseOpts, xhr, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
9981000
resp = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
999-
if ((_ref3 = opts[type]) != null ? _ref3._originalHandler : void 0) {
1000-
opts[type] = opts[type]._originalHandler;
1001-
}
1002-
_ref4 = _this._normalizeResponse.apply(_this, resp), reason = _ref4[0], data = _ref4[1], xhr = _ref4[2];
1001+
_ref3 = _this._normalizeResponse.apply(_this, resp), reason = _ref3[0], data = _ref3[1], xhr = _ref3[2];
10031002
if (type === 'success' && !(msg.errorCount != null) && m_opts.showSuccessWithoutError === false) {
10041003
m_opts['successMessage'] = null;
10051004
}
10061005
if (type === 'error') {
1007-
if ((_ref5 = m_opts.errorCount) == null) {
1006+
if ((_ref4 = m_opts.errorCount) == null) {
10081007
m_opts.errorCount = 0;
10091008
}
10101009
m_opts.errorCount += 1;
10111010
}
1012-
handlerResp = m_opts.returnsPromise ? resp[0] : typeof opts[type] === "function" ? opts[type].apply(opts, resp) : void 0;
1011+
handlerResp = m_opts.returnsPromise ? resp[0] : typeof originalHandler === "function" ? originalHandler.apply(null, resp) : void 0;
10131012
responseOpts = _this._getHandlerResponse(handlerResp);
10141013
if (_.isString(responseOpts)) {
10151014
responseOpts = {
@@ -1020,21 +1019,21 @@ window.Messenger.Events = (function() {
10201019
msg.hide();
10211020
return;
10221021
}
1023-
if (type === 'error' && ((m_opts.ignoredErrorCodes != null) && (_ref6 = xhr != null ? xhr.status : void 0, __indexOf.call(m_opts.ignoredErrorCodes, _ref6) >= 0))) {
1022+
if (type === 'error' && ((m_opts.ignoredErrorCodes != null) && (_ref5 = xhr != null ? xhr.status : void 0, __indexOf.call(m_opts.ignoredErrorCodes, _ref5) >= 0))) {
10241023
msg.hide();
10251024
return;
10261025
}
10271026
defaultOpts = {
10281027
message: getMessageText(type, xhr),
10291028
type: type,
1030-
events: (_ref7 = events[type]) != null ? _ref7 : {},
1029+
events: (_ref6 = events[type]) != null ? _ref6 : {},
10311030
hideOnNavigate: type === 'success'
10321031
};
10331032
msgOpts = $.extend({}, m_opts, defaultOpts, responseOpts);
1034-
if (typeof ((_ref8 = msgOpts.retry) != null ? _ref8.allow : void 0) === 'number') {
1033+
if (typeof ((_ref7 = msgOpts.retry) != null ? _ref7.allow : void 0) === 'number') {
10351034
msgOpts.retry.allow--;
10361035
}
1037-
if (type === 'error' && (xhr != null ? xhr.status : void 0) >= 500 && ((_ref9 = msgOpts.retry) != null ? _ref9.allow : void 0)) {
1036+
if (type === 'error' && (xhr != null ? xhr.status : void 0) >= 500 && ((_ref8 = msgOpts.retry) != null ? _ref8.allow : void 0)) {
10381037
if (msgOpts.retry.delay == null) {
10391038
if (msgOpts.errorCount < 4) {
10401039
msgOpts.retry.delay = 10;
@@ -1043,7 +1042,7 @@ window.Messenger.Events = (function() {
10431042
}
10441043
}
10451044
if (msgOpts.hideAfter) {
1046-
if ((_ref10 = msgOpts._hideAfter) == null) {
1045+
if ((_ref9 = msgOpts._hideAfter) == null) {
10471046
msgOpts._hideAfter = msgOpts.hideAfter;
10481047
}
10491048
msgOpts.hideAfter = msgOpts._hideAfter + msgOpts.retry.delay;
@@ -1087,7 +1086,6 @@ window.Messenger.Events = (function() {
10871086
handler = handlers[type];
10881087
old = opts[type];
10891088
opts[type] = handler;
1090-
opts[type]._originalHandler = old;
10911089
}
10921090
}
10931091
msg._actionInstance = m_opts.action.apply(m_opts, [opts].concat(__slice.call(args)));

build/js/messenger.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "messenger",
33
"repo": "HubSpot/messenger",
44
"description": "Client-side growl-like notifications with actions and auto-retry.",
5-
"version": "1.3.4",
5+
"version": "1.3.5",
66
"homepage": "http://github.hubspot.com/messenger",
77
"license": "MIT",
88
"keywords": [

0 commit comments

Comments
 (0)