Skip to content

Commit

Permalink
fix(pubsub): Apply localStorage fix for error when cookies are disabled
Browse files Browse the repository at this point in the history
Original PR: eclipse/paho.mqtt.javascript#247

Co-authored-by: Sam Dawson <sam.dawson181@gmail.com>
  • Loading branch information
stocaaro and Samic8 committed Jan 9, 2023
1 parent 51a1418 commit 8f74aea
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/pubsub/src/vendor/paho-mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ function onMessageArrived(message) {
// which is used to define the module.
var version = '@VERSION@-@BUILDLEVEL@';

// 2023-01-05: AWS Amplify change to incorporate upstream pull request:
// https://github.com/eclipse/paho.mqtt.javascript/pull/247

/**
* @private
*/
var localStorage =
global.localStorage ||
(function () {
var localStorage = (function () {
try {
// When third-party cookies are disabled accessing localStorage will cause an error
if (global.localStorage) return global.localStorage;
} catch (e) {
var data = {};

return {
Expand All @@ -118,7 +123,10 @@ function onMessageArrived(message) {
delete data[key];
},
};
})();
}
})();

// End of AWS Amplify change

/**
* Unique message type identifiers, with associated
Expand Down

0 comments on commit 8f74aea

Please sign in to comment.