Browse Source

retry to decode shortened URI if we got null response

readme-update
Simon Grim 9 years ago
parent
commit
c93474d3d5
  1. 12
      js/interface_common.js

12
js/interface_common.js

@ -879,7 +879,7 @@ function fillElemWithTxt(elem, txt, htmlFormatMsgOpt) {
return formatted; return formatted;
} }
function fetchShortenedURI(req) { function fetchShortenedURI(req, attemptCount) {
if (twister.URIs[req]) { if (twister.URIs[req]) {
applyShortenedURI(req, twister.URIs[req]); applyShortenedURI(req, twister.URIs[req]);
return; return;
@ -888,13 +888,15 @@ function fetchShortenedURI(req) {
decodeShortURI(req, decodeShortURI(req,
function (req, ret) { function (req, ret) {
if (ret) { if (ret) {
twister.URIs[req] = ret; twister.URIs[req.shortURI] = ret;
$.localStorage.set('twistaURIs', twister.URIs); $.localStorage.set('twistaURIs', twister.URIs);
applyShortenedURI(req, ret); applyShortenedURI(req.shortURI, ret);
} else { } else {
console.warn('can\'t fetch URI "' + req + '": null response'); console.warn('can\'t fetch URI "' + req.shortURI + '": null response');
if ((req.attemptCount ? ++req.attemptCount : req.attemptCount = 1) < 3) // < $.Options.decodeShortURITriesMax
fetchShortenedURI(req.shortURI, req.attemptCount);
} }
}, req }, {short: req, attemptCount: attemptCount}
); );
} }

Loading…
Cancel
Save