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

Commit

Permalink
o-comment-utilities storage wrapper will defend against storage not b…
Browse files Browse the repository at this point in the history
…eing available. Use const for duplicated key name.
  • Loading branch information
Dan Searle committed Oct 4, 2018
1 parent bc830c2 commit e017b4d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/javascripts/utils.js
@@ -1,24 +1,18 @@
const oCommentUtilities = require('o-comment-utilities');

const QUEUE_KEY = 'fyre-action-queue';

/**
* Livefyre creates a queue in localStorage when a user posts a comment without being logged in.
* This method clears the queue.
* @return {undefined}
*/
exports.emptyLivefyreActionQueue = function () {
if (typeof Storage !== 'undefined') {
oCommentUtilities.storageWrapper.localStorage.removeItem('fyre-action-queue');
}
oCommentUtilities.storageWrapper.localStorage.removeItem(QUEUE_KEY);
};

exports.isLivefyreActionQueuePresent = function () {
if (typeof Storage !== 'undefined') {
if (oCommentUtilities.storageWrapper.localStorage.getItem('fyre-action-queue')) {
return true;
}
}

return false;
return !!oCommentUtilities.storageWrapper.localStorage.getItem(QUEUE_KEY);
};

/**
Expand Down

0 comments on commit e017b4d

Please sign in to comment.